ZGlmZiAtLWdpdCBhL2FyY2gvYXJtL3BsYXQtb21hcC9LY29uZmlnIGIvYXJjaC9hcm0vcGxhdC1vbWFwL0tjb25maWcKbmV3IGZpbGUgbW9kZSAxMDA2NDQKaW5kZXggMDAwMDAwMC4uYTcyZmU1NQotLS0gL2Rldi9udWxsCisrKyBiL2FyY2gvYXJtL3BsYXQtb21hcC9LY29uZmlnCkBAIC0wLDAgKzEsOTkgQEAKK2lmIEFSQ0hfT01BUAorCittZW51ICJUSSBPTUFQIEltcGxlbWVudGF0aW9ucyIKKworY29uZmlnIEFSQ0hfT01BUF9PVEcKKwlib29sCisKK2Nob2ljZQorCXByb21wdCAiT01BUCBTeXN0ZW0gVHlwZSIKKwlkZWZhdWx0IEFSQ0hfT01BUDEKKworY29uZmlnIEFSQ0hfT01BUDEKKwlib29sICJUSSBPTUFQMSIKKworY29uZmlnIEFSQ0hfT01BUDIKKwlib29sICJUSSBPTUFQMiIKKworZW5kY2hvaWNlCisKK2NvbW1lbnQgIk9NQVAgRmVhdHVyZSBTZWxlY3Rpb25zIgorCitjb25maWcgT01BUF9NVVgKKwlib29sICJPTUFQIG11bHRpcGxleGluZyBzdXBwb3J0IgorICAgICAgICBkZXBlbmRzIG9uIEFSQ0hfT01BUAorCWRlZmF1bHQgeQorICAgICAgICBoZWxwCisgICAgICAgICAgUGluIG11bHRpcGxleGluZyBzdXBwb3J0IGZvciBPTUFQIGJvYXJkcy4gSWYgeW91ciBib290bG9hZGVyCisgICAgICAgICAgc2V0cyB0aGUgbXVsdGlwbGV4aW5nIGNvcnJlY3RseSwgc2F5IE4uIE90aGVyd2lzZSwgb3IgaWYgdW5zdXJlLAorICAgICAgICAgIHNheSBZLgorCitjb25maWcgT01BUF9NVVhfREVCVUcKKwlib29sICJNdWx0aXBsZXhpbmcgZGVidWcgb3V0cHV0IgorICAgICAgICBkZXBlbmRzIG9uIE9NQVBfTVVYCisgICAgICAgIGRlZmF1bHQgbgorICAgICAgICBoZWxwCisgICAgICA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QX01QVUlPX01BU0spID4gMTYpCisJCQlyZXR1cm4gLTE7CisJCXJldHVybiAwOworCX0KKyNpZmRlZiBDT05GSUdfQVJDSF9PTUFQMTUxMAorCWlmIChjcHVfaXNfb21hcDE1MTAoKSAmJiBncGlvIDwgMTYpCisJCXJldHVybiAwOworI2VuZGlmCisjaWYgZGVmaW5lZChDT05GSUdfQVJDSF9PTUFQMTZYWCkKKwlpZiAoKGNwdV9pc19vbWFwMTZ4eCgpKSAmJiBncGlvIDwgNjQpCisJCXJldHVybiAwOworI2VuZGlmCisjaWZkZWYgQ09ORklHX0FSQ0hfT01BUDczMAorCWlmIChjcHVfaXNfb21hcDczMCgpICYmIGdwaW8gPCAxOTIpCisJCXJldHVybiAwOworI2VuZGlmCisJcmV0dXJuIC0xOworfQorCitzdGF0aWMgaW50IGNoZWNrX2dwaW8oaW50IGdwaW8pCit7CisJaWYgKHVubGlrZWx5KGdwaW9fdmFsaWQoZ3BpbykpIDwgMCkgeworCQlwcmludGsoS0VSTl9FUlIgIm9tYXAtZ3BpbzogaW52YWxpZCBHUElPICVkXG4iLCBncGlvKTsKKwkJZHVtcF9zdGFjaygpOworCQlyZXR1cm4gLTE7CisJfQorCXJldHVybiAwOworfQorCitzdGF0aWMgdm9pZCBfc2V0X2dwaW9fZGlyZWN0aW9uKHN0cnVjdCBncGlvX2JhbmsgKmJhbmssIGludCBncGlvLCBpbnQgaXNfaW5wdXQpCit7CisJdTMyIHJlZyA9IGJhbmstPmJhc2U7CisJdTMyIGw7CisKKwlzd2l0Y2ggKGJhbmstPm1ldGhvZCkgeworCWNhc2UgTUVUSE9EX01QVUlPOgorCQlyZWcgKz0gT01BUF9NUFVJT19JT19DTlRMOworCQlicmVhazsKKwljYXNlIE1FVEhPRF9HUElPXzE1MTA6CisJCXJlZyArPSBPTUFQMTUxMF9HUElPX0RJUl9DT05UUk9MOworCQlicmVhazsKKwljYXNlIE1FVEhPRF9HUElPXzE2MTA6CisJCXJlZyArPSBPTUFQMTYxM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Y29tcGxldGlvbi5oPgorI2luY2x1ZGUgPGxpbnV4L2ludGVycnVwdC5oPgorI2luY2x1ZGUgPGxpbnV4L2Vyci5oPgorCisjaW5jbHVkZSA8YXNtL2RlbGF5Lmg+CisjaW5jbHVkZSA8YXNtL2lvLmg+CisjaW5jbHVkZSA8YXNtL2lycS5oPgorCisjaW5jbHVkZSA8YXNtL2FyY2gvZG1hLmg+CisjaW5jbHVkZSA8YXNtL2FyY2gvbXV4Lmg+CisjaW5jbHVkZSA8YXNtL2FyY2gvaXJxcy5oPgorI2luY2x1ZGUgPGFzbS9hcmNoL21jYnNwLmg+CisKKyNpbmNsdWRlIDxhc20vaGFyZHdhcmUvY2xvY2suaD4KKworI2lmZGVmIENPTkZJR19NQ0JTUF9ERUJVRworI2RlZmluZSBEQkcoeC4uLikJcHJpbnRrKHgpCisjZWxzZQorI2RlZmluZSBEQkcoeC4uLikJZG8geyB9IHdoaWxlICgwKQorI2VuZGlmCisKK3N0cnVjdCBvbWFwX21jYnNwIHsKKwl1MzIgICAgICAgICAgICAgICAgICAgICAgICAgIGlvX2Jhc2U7CisJdTggICAgICAgICAgICAgICAgICAgICAgICAgICBpZDsKKwl1OCAgICAgICAgICAgICAgICAgICAgICAgICAgIGZyZWU7CisJb21hcF9tY2JzcF93b3JkX2xlbmd0aCAgICAgICByeF93b3JkX2xlbmd0aDsKKwlvbWFwX21jYnNwX3dvcmRfbGVuZ3RoICAgICAgIHR4X3dvcmRfbGVuZ3RoOworCisJLyogSVJRIGJhc2VkIFRYL1JYICovCisJaW50ICAgICAgICAgICAgICAgICAgICAgICAgICByeF9pcnE7CisJaW50ICAgICAgICAgICAgICAgICAgICAgICAgICB0eF9pcnE7CisKKwkvKiBETUEgc3R1ZmYgKi8KKwl1OCAgICAgICAgICAgICAgICAgICAgICAgICAgIGRtYV9yeF9zeW5jOworCXNob3J0ICAgICAgICAgICAgICAgICAgICAgICAgZG1hX3J4X2xjaDsKKwl1OCAgICAgICAgICAgICAgICAgICAgICAgICAgIGRtYV90eF9zeW5jOworCXNob3J0ICAgICAgICAgICAgICAgICAgICAgICAgZG1hX3R4X2xjaDsKKworCS8qIENvbXBsZXRpb24gcXVldWVzICovCisJc3RydWN0IGNvbXBsZXRpb24gICAgICAgICAgICB0eF9pcnFfY29tcGxldGlvbjsKKwlzdHJ1Y3QgY29tcGxldGlvbiAgICAgICAgICAgIHJ4X2lycV9jb21wbGV0aW9uOworCXN0cnVjdCBjb21wbGV0aW9uICAgICAgICAgICAgdHhfZG1hX2NvbXBsZXRpb247CisJc3RydWN0IGNvbXBsZXRpb24gICAgICAgICAgICByeF9kbWFfY29tcGxldGlvbjsKKworCXNwaW5sb2NrX3QgICAgICAgICAgICAgICAgICAgbG9jazsKK307CisKK3N0YXRpYyBzdHJ1Y3Qgb21hcF9tY2JzcCBtY2JzcFtPTUFQX01BWF9NQ0JTUF9DT1VOVF07CitzdGF0aWMgc3RydWN0IGNsayAqbWNic3BfZHNwX2NrID0gMDsKK3N0YXRpYyBzdHJ1Y3QgY2xrICptY2JzcF9hcGlfY2sgPSAwOworCisKK3N0YXRpYyB2b2lkIG9tYXBfbWNic3BfZHVtcF9yZWcodTggaWQpCit7CisJREJHKCIqKioqIE1DQlNQJWQgcmVncyAqKioqXG4iLCBtY2JzcFtpZF0uaWQpOworCURCRygiRFJSMjogIDB4JTA0eFxuIiwgT01BUF9NQ0JTUF9SRUFEKG1jYnNwW2lkXS5pb19iYXNlLCBEUlIyKSk7CisJREJHKCJEUlIxOiAgMHglMDR4XG4iLCBPTUFQX01DQlNQX1JFQUQobWNic3BbaWRdLmlvX2Jhc2UsIERSUjEpKTsKKwlEQkcoIkRYUjI6ICAweCUwNHhcbiIsIE9NQVBfTUNCU1BfUkVBRChtY2JzcFtpZF0uaW9fYmFzZSwgRFhSMikpOworCURCRygiRFhSMTogIDB4JTA0eFxuIiwgT01BUF9NQ0JTUF9SRUFEKG1jYnNwW2lkXS5pb19iYXNlLCBEWFIxKSk7CisJREJHKCJTUENS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FVJMTYxMF9TQVZFKEVNSUZTX0NPTkZJRyk7CisJfQorCisJaWYgKHZpcnR1YWxfc3RhcnQgPT0gMCkgeworCQlnX3JlYWRfY29tcGxldGVkID0gMDsKKworCQlteV9idWZmZXJfb2Zmc2V0ICs9IHNwcmludGYobXlfYmFzZSArIG15X2J1ZmZlcl9vZmZzZXQsCisJCSAgICJBUk1fQ0tDVExfUkVHOiAgICAgICAgICAgIDB4JS04eCAgICAgXG4iCisJCSAgICJBUk1fSURMRUNUMV9SRUc6ICAgICAgICAgIDB4JS04eCAgICAgXG4iCisJCSAgICJBUk1fSURMRUNUMl9SRUc6ICAgICAgICAgIDB4JS04eCAgICAgXG4iCisJCSAgICJBUk1fRVdVUENUX1JFRzogICAgICAgICAgIDB4JS04eCAgICAgXG4iCisJCSAgICJBUk1fUlNUQ1QxX1JFRzogICAgICAgICAgIDB4JS04eCAgICAgXG4iCisJCSAgICJBUk1fUlNUQ1QyX1JFRzogICAgICAgICAgIDB4JS04eCAgICAgXG4iCisJCSAgICJBUk1fU1lTU1RfUkVHOiAgICAgICAgICAgIDB4JS04eCAgICAgXG4iCisJCSAgICJVTFBEX0lUX1NUQVRVU19SRUc6ICAgICAgIDB4JS00eCAgICAgXG4iCisJCSAgICJVTFBEX0NMT0NLX0NUUkxfUkVHOiAgICAgIDB4JS00eCAgICAgXG4iCisJCSAgICJVTFBEX1NPRlRfUkVRX1JFRzogICAgICAgIDB4JS00eCAgICAgXG4iCisJCSAgICJVTFBEX0RQTExfQ1RSTF9SRUc6ICAgICAgIDB4JS00eCAgICAgXG4iCisJCSAgICJVTFBEX1NUQVRVU19SRVFfUkVHOiAgICAgIDB4JS00eCAgICAgXG4iCisJCSAgICJVTFBEX1BPV0VSX0NUUkxfUkVHOiAgICAgIDB4JS00eCAgICAgXG4iLAorCQkgICBBUk1fU0hPVyhBUk1fQ0tDVEwpLAorCQkgICBBUk1fU0hPVyhBUk1fSURMRUNUMSksCisJCSAgIEFSTV9TSE9XKEFSTV9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