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KKwkgICAgIHRjcC5vIHRjcF9pbnB1dC5vIHRjcF9vdXRwdXQubyB0Y3BfdGltZXIubyB0Y3BfaXB2NC5vIHRjcF9taW5pc29ja3MubyBcCisJICAgICBkYXRhZ3JhbS5vIHJhdy5vIHVkcC5vIGFycC5vIGljbXAubyBkZXZpbmV0Lm8gYWZfaW5ldC5vIGlnbXAubyBcCisJICAgICBzeXNjdGxfbmV0X2lwdjQubyBmaWJfZnJvbnRlbmQubyBmaWJfc2VtYW50aWNzLm8gZmliX2hhc2gubworCitvYmotJChDT05GSUdfUFJPQ19GUykgKz0gcHJvYy5vCitvYmotJChDT05GSUdfSVBfTVVMVElQTEVfVEFCTEVTKSArPSBmaWJfcnVsZXMubworb2JqLSQoQ09ORklHX0lQX01ST1VURSkgKz0gaXBtci5vCitvYmotJChDT05GSUdfTkVUX0lQSVApICs9IGlwaXAubworb2JqLSQoQ09ORklHX05FVF9JUEdSRSkgKz0gaXBfZ3JlLm8KK29iai0kKENPTkZJR19TWU5fQ09PS0lFUykgKz0gc3luY29va2llcy5vCitvYmotJChDT05GSUdfSU5FVF9BSCkgKz0gYWg0Lm8KK29iai0kKENPTkZJR19JTkVUX0VTUCkgKz0gZXNwNC5vCitvYmotJChDT05GSUdfSU5FVF9JUENPTVApICs9IGlwY29tcC5vCitvYmotJChDT05GSUdfSU5FVF9UVU5ORUwpICs9IHhmcm00X3R1bm5lbC5vIAorb2JqLSQoQ09ORklHX0lQX1BOUCkgKz0gaXBjb25maWcubworb2JqLSQoQ09ORklHX0lQX1JPVVRFX01VTFRJUEFUSF9SUikgKz0gbXVsdGlwYXRoX3JyLm8KK29iai0kKENPTkZJR19JUF9ST1VURV9NVUxUSVBBVEhfUkFORE9NKSArPSBtdWx0aXBhdGhfcmFuZG9tLm8KK29iai0kKENPTkZJR19JUF9ST1VURV9NVUxUSVBBVEhfV1JBTkRPTSkgKz0gbXVsdGlwYXRoX3dyYW5kb20ubworb2JqLSQoQ09ORklHX0lQX1JPVVRFX01V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nJlY3Ztc2cgPQlzb2NrX2NvbW1vbl9yZWN2bXNnLAorCS5tbWFwID0JCXNvY2tfbm9fbW1hcCwKKwkuc2VuZHBhZ2UgPQlpbmV0X3NlbmRwYWdlLAorfTsKKworc3RhdGljIHN0cnVjdCBuZXRfcHJvdG9fZmFtaWx5IGluZXRfZmFtaWx5X29wcyA9IHsKKwkuZmFtaWx5ID0gUEZfSU5FVCwKKwkuY3JlYXRlID0gaW5ldF9jcmVhdGUsCisJLm93bmVyCT0gVEhJU19NT0RVTEUsCit9OworCisKK2V4dGVybiB2b2lkIHRjcF9pbml0KHZvaWQpOworZXh0ZXJuIHZvaWQgdGNwX3Y0X2luaXQoc3RydWN0IG5ldF9wcm90b19mYW1pbHkgKik7CisKKy8qIFVwb24gc3RhcnR1cCB3ZSBpbnNlcnQgYWxsIHRoZSBlbGVtZW50cyBpbiBpbmV0c3dfYXJyYXlbXSBpbnRvCisgKiB0aGUgbGlua2VkIGxpc3QgaW5ldHN3LgorICovCitzdGF0aWMgc3RydWN0IGluZXRfcHJvdG9zdyBpbmV0c3dfYXJyYXlbXSA9Cit7CisgICAgICAgIHsKKyAgICAgICAgICAgICAgICAudHlwZSA9ICAgICAgIFNPQ0tfU1RSRUFNLAorICAgICAgICAgICAgICAgIC5wcm90b2NvbCA9ICAgSVBQUk9UT19UQ1AsCisgICAgICAgICAgICAgICAgLnByb3QgPSAgICAgICAmdGNwX3Byb3QsCisgICAgICAgICAgICAgICAgLm9wcyA9ICAgICAgICAmaW5ldF9zdHJlYW1fb3BzLAorICAgICAgICAgICAgICAgIC5jYXBhYmlsaXR5ID0gLTEsCisgICAgICAgICAgICAgICAgLm5vX2NoZWNrID0gICAwLAorICAgICAgICAgICAgICAgIC5mbGFncyA9ICAgICAgSU5FVF9QUk9UT1NXX1BFUk1BTkVOVCwKKyAgICAgICAgfSwKKworICAgICAgICB7CisgICAgICAgICAgICAgICAgLnR5cGUgPSAgICAgICBTT0NLX0RHUkFNLAorICAgICAgICAgICAgICAgIC5wcm90b2NvbCA9ICAgSVBQUk9UT19VRFAsCisgICAgICAgICAgICAgICAgLnByb3QgPSAgICAgICAmdWRwX3Byb3QsCisgICAgICAgICAgICAgICAgLm9wcyA9ICAgICAgICAmaW5ldF9kZ3JhbV9vcHMsCisgICAgICAgICAgICAgICAgLmNhcGFiaWxpdHkgPSAtMSwKKyAgICAgICAgICAgICAgICAubm9fY2hlY2sgPSAgIFVEUF9DU1VNX0RFRkFVTFQsCisgICAgICAgICAgICAgICAgLmZsYWdzID0gICAgICBJTkVUX1BST1RPU1dfUEVSTUFORU5ULAorICAgICAgIH0sCisgICAgICAgIAorCisgICAgICAgeworICAgICAgICAgICAgICAgLnR5cGUgPSAgICAgICBTT0NLX1JBVywKKyAgICAgICAgICAgICAgIC5wcm90b2NvbCA9ICAgSVBQUk9UT19JUCwJLyogd2lsZCBjYXJkICovCisgICAgICAgICAgICAgICAucHJvdCA9ICAgICAgICZyYXdfcHJvdCwKKyAgICAgICAgICAgICAgIC5vcHMgPSAgICAgICAgJmluZXRfc29ja3Jhd19vcHMsCisgICAgICAgICAgICAgICAuY2FwYWJpbGl0eSA9IENBUF9ORVRfUkFXLAorICAgICAgICAgICAgICAgLm5vX2NoZWNrID0gICBVRFBfQ1NVTV9ERUZBVUxULAorICAgICAgICAgICAgICAgLmZsYWdzID0gICAgICBJTkVUX1BST1RPU1dfUkVVU0UsCisgICAgICAgfQorfTsKKworI2RlZmluZSBJTkVUU1dfQVJSQVlfTEVOIChzaXplb2YoaW5ldHN3X2FycmF5KSAvIHNpemVvZihzdHJ1Y3QgaW5ldF9wcm90b3N3KSkKKwordm9pZCBpbmV0X3JlZ2lzdGVyX3Byb3Rvc3coc3RydWN0IGluZXRfcHJvdG9zdyAqcCkKK3sKKwlzdHJ1Y3QgbGlzdF9oZWFkICpsaDsKKwlzdHJ1Y3QgaW5ldF9wcm90b3N3ICphbnN3ZXI7CisJaW50IHByb3RvY29sID0gcC0+cHJvdG9jb2w7CisJc3RydWN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SUZGX1BPSU5UT1BPSU5UKSkKKwkJCW5leHRob3AgPSAwOworCQluID0gX19uZWlnaF9sb29rdXBfZXJybm8oCisjaWYgZGVmaW5lZChDT05GSUdfQVRNX0NMSVApIHx8IGRlZmluZWQoQ09ORklHX0FUTV9DTElQX01PRFVMRSkKKwkJICAgIGRldi0+dHlwZSA9PSBBUlBIUkRfQVRNID8gY2xpcF90YmxfaG9vayA6CisjZW5kaWYKKwkJICAgICZhcnBfdGJsLCAmbmV4dGhvcCwgZGV2KTsKKwkJaWYgKElTX0VSUihuKSkKKwkJCXJldHVybiBQVFJfRVJSKG4pOworCQlkc3QtPm5laWdoYm91ciA9IG47CisJfQorCXJldHVybiAwOworfQorCisvKgorICogQ2hlY2sgaWYgd2UgY2FuIHVzZSBwcm94eSBBUlAgZm9yIHRoaXMgcGF0aAorICovCisKK3N0YXRpYyBpbmxpbmUgaW50IGFycF9md2RfcHJveHkoc3RydWN0IGluX2RldmljZSAqaW5fZGV2LCBzdHJ1Y3QgcnRhYmxlICpydCkKK3sKKwlzdHJ1Y3QgaW5fZGV2aWNlICpvdXRfZGV2OworCWludCBpbWksIG9taSA9IC0xOworCisJaWYgKCFJTl9ERVZfUFJPWFlfQVJQKGluX2RldikpCisJCXJldHVybiAwOworCisJaWYgKChpbWkgPSBJTl9ERVZfTUVESVVNX0lEKGluX2RldikpID09IDApCisJCXJldHVybiAxOworCWlmIChpbWkgPT0gLTEpCisJCXJldHVybiAwOworCisJLyogcGxhY2UgdG8gY2hlY2sgZm9yIHByb3h5X2FycCBmb3Igcm91dGVzICovCisKKwlpZiAoKG91dF9kZXYgPSBpbl9kZXZfZ2V0KHJ0LT51LmRzdC5kZXYpKSAhPSBOVUxMKSB7CisJCW9taSA9IElOX0RFVl9NRURJVU1fSUQob3V0X2Rldik7CisJCWluX2Rldl9wdXQob3V0X2Rldik7CisJfQorCXJldHVybiAob21pICE9IGltaSAmJiBvbWkgIT0gLTEpOworfQorCisvKgorICoJSW50ZXJmYWNlI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tcF9zdGFydF90aW1lcihzdHJ1Y3QgaXBfbWNfbGlzdCAqaW0sIGludCBtYXhfZGVsYXkpCit7CisJaW50IHR2PW5ldF9yYW5kb20oKSAlIG1heF9kZWxheTsKKworCWltLT50bV9ydW5uaW5nPTE7CisJaWYgKCFtb2RfdGltZXIoJmltLT50aW1lciwgamlmZmllcyt0disyKSkKKwkJYXRvbWljX2luYygmaW0tPnJlZmNudCk7Cit9CisKK3N0YXRpYyB2b2lkIGlnbXBfZ3Ffc3RhcnRfdGltZXIoc3RydWN0IGluX2RldmljZSAqaW5fZGV2KQoreworCWludCB0diA9IG5ldF9yYW5kb20oKSAlIGluX2Rldi0+bXJfbWF4ZGVsYXk7CisKKwlpbl9kZXYtPm1yX2dxX3J1bm5pbmcgPSAxOworCWlmICghbW9kX3RpbWVyKCZpbl9kZXYtPm1yX2dxX3RpbWVyLCBqaWZmaWVzK3R2KzIpKQorCQlpbl9kZXZfaG9sZChpbl9kZXYpOworfQorCitzdGF0aWMgdm9pZCBpZ21wX2lmY19zdGFydF90aW1lcihzdHJ1Y3QgaW5fZGV2aWNlICppbl9kZXYsIGludCBkZWxheSkKK3sKKwlpbnQgdHYgPSBuZXRfcmFuZG9tKCkgJSBkZWxheTsKKworCWlmICghbW9kX3RpbWVyKCZpbl9kZXYtPm1yX2lmY190aW1lciwgamlmZmllcyt0disyKSkKKwkJaW5fZGV2X2hvbGQoaW5fZGV2KTsKK30KKworc3RhdGljIHZvaWQgaWdtcF9tb2RfdGltZXIoc3RydWN0IGlwX21jX2xpc3QgKmltLCBpbnQgbWF4X2RlbGF5KQoreworCXNwaW5fbG9ja19iaCgmaW0tPmxvY2spOworCWltLT51bnNvbGljaXRfY291bnQgPSAwOworCWlmIChkZWxfdGltZXIoJmltLT50aW1lcikpIHsKKwkJaWYgKChsb25nKShpbS0+dGltZXIuZXhwaXJlcy1qaWZmaWVzKSA8IG1heF9kZWxheSkgeworCQkJYWRkX3RpbWVyKCZpbS0+dGltZXIpOworCQkJ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Cwgc3RydWN0IHNrX2J1ZmYgKnNrYikKK3sKKwlpbnQgZXJyOworCXN0cnVjdCBpcGhkciAqaXBoOworCXN0cnVjdCBpcF9jb21wX2hkciAqaXBjaDsKKwlzdHJ1Y3QgaXBjb21wX2RhdGEgKmlwY2QgPSB4LT5kYXRhOworCWludCBoZHJfbGVuID0gMDsKKworCWlwaCA9IHNrYi0+bmguaXBoOworCWlwaC0+dG90X2xlbiA9IGh0b25zKHNrYi0+bGVuKTsKKwloZHJfbGVuID0gaXBoLT5paGwgKiA0OworCWlmICgoc2tiLT5sZW4gLSBoZHJfbGVuKSA8IGlwY2QtPnRocmVzaG9sZCkgeworCQkvKiBEb24ndCBib3RoZXIgY29tcHJlc3NpbmcgKi8KKwkJZ290byBvdXRfb2s7CisJfQorCisJaWYgKChza2JfaXNfbm9ubGluZWFyKHNrYikgfHwgc2tiX2Nsb25lZChza2IpKSAmJgorCSAgICBza2JfbGluZWFyaXplKHNrYiwgR0ZQX0FUT01JQykgIT0gMCkgeworCQlnb3RvIG91dF9vazsKKwl9CisJCisJZXJyID0gaXBjb21wX2NvbXByZXNzKHgsIHNrYik7CisJaXBoID0gc2tiLT5uaC5pcGg7CisKKwlpZiAoZXJyKSB7CisJCWdvdG8gb3V0X29rOworCX0KKworCS8qIEluc3RhbGwgaXBjb21wIGhlYWRlciwgY29udmVydCBpbnRvIGlwY29tcCBkYXRhZ3JhbS4gKi8KKwlpcGgtPnRvdF9sZW4gPSBodG9ucyhza2ItPmxlbik7CisJaXBjaCA9IChzdHJ1Y3QgaXBfY29tcF9oZHIgKikoKGNoYXIgKilpcGggKyBpcGgtPmlobCAqIDQpOworCWlwY2gtPm5leHRoZHIgPSBpcGgtPnByb3RvY29sOworCWlwY2gtPmZsYWdzID0gMDsKKwlpcGNoLT5jcGkgPSBodG9ucygodTE2ICludG9obCh4LT5pZC5zcGkpKTsKKwlpcGgtPnByb3RvY29sID0gSVBQUk9UT19DT01QOworCWlwX3NlbmRfY2hlY2soaXBo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UREUl9OT05FOwkvKiBBZGRyZXNzIG9mIE5GUyBzZXJ2ZXIgKi8KK3U4IHJvb3Rfc2VydmVyX3BhdGhbMjU2XSA9IHsgMCwgfTsJLyogUGF0aCB0byBtb3VudCBhcyByb290ICovCisKKy8qIFBlcnNpc3RlbnQgZGF0YTogKi8KKworc3RhdGljIGludCBpY19wcm90b191c2VkOwkJCS8qIFByb3RvY29sIHVzZWQsIGlmIGFueSAqLworc3RhdGljIHUzMiBpY19uYW1lc2VydmVyc1tDT05GX05BTUVTRVJWRVJTX01BWF07IC8qIEROUyBTZXJ2ZXIgSVAgYWRkcmVzc2VzICovCitzdGF0aWMgdTggaWNfZG9tYWluWzY0XTsJCS8qIEROUyAobm90IE5JUykgZG9tYWluIG5hbWUgKi8KKworLyoKKyAqIFByaXZhdGUgc3RhdGUuCisgKi8KKworLyogTmFtZSBvZiB1c2VyLXNlbGVjdGVkIGJvb3QgZGV2aWNlICovCitzdGF0aWMgY2hhciB1c2VyX2Rldl9uYW1lW0lGTkFNU0laXSBfX2luaXRkYXRhID0geyAwLCB9OworCisvKiBQcm90b2NvbHMgc3VwcG9ydGVkIGJ5IGF2YWlsYWJsZSBpbnRlcmZhY2VzICovCitzdGF0aWMgaW50IGljX3Byb3RvX2hhdmVfaWYgX19pbml0ZGF0YSA9IDA7CisKKyNpZmRlZiBJUENPTkZJR19EWU5BTUlDCitzdGF0aWMgREVGSU5FX1NQSU5MT0NLKGljX3JlY3ZfbG9jayk7CitzdGF0aWMgdm9sYXRpbGUgaW50IGljX2dvdF9yZXBseSBfX2luaXRkYXRhID0gMDsgICAgLyogUHJvdG8ocykgdGhhdCByZXBsaWVkICovCisjZW5kaWYKKyNpZmRlZiBJUENPTkZJR19ESENQCitzdGF0aWMgaW50IGljX2RoY3BfbXNndHlwZSBfX2luaXRkYXRhID0gMDsJLyogREhDUCBtc2cgdHlwZSByZWNlaXZlZCAqLworI2VuZGlmCisKKworLyoKKyAqCU5ldHdvcmsgZGV2aWNlcworICov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dCAqLworCSplKysgPSAzMjsKKwllICs9IDMyOworCSplKysgPSA0MDsJCS8qIE5JUyBEb21haW4gbmFtZSByZXF1ZXN0ICovCisJKmUrKyA9IDMyOworCWUgKz0gMzI7CisJKmUrKyA9IDE3OwkJLyogQm9vdCBwYXRoICovCisJKmUrKyA9IDQwOworCWUgKz0gNDA7CisKKwkqZSsrID0gNTc7CQkvKiBzZXQgZXh0ZW5zaW9uIGJ1ZmZlciBzaXplIGZvciByZXBseSAqLyAKKwkqZSsrID0gMjsKKwkqZSsrID0gMTsJCS8qIDEyOCsyMzYrOCsyMCsxNCwgc2VlIGRoY3BkIHNvdXJjZXMgKi8gCisJKmUrKyA9IDE1MDsKKworCSplKysgPSAyNTU7CQkvKiBFbmQgb2YgdGhlIGxpc3QgKi8KK30KKworCisvKgorICogIEluaXRpYWxpemUgdGhlIERIQ1AvQk9PVFAgbWVjaGFuaXNtLgorICovCitzdGF0aWMgaW5saW5lIHZvaWQgaWNfYm9vdHBfaW5pdCh2b2lkKQoreworCWludCBpOworCisJZm9yIChpID0gMDsgaSA8IENPTkZfTkFNRVNFUlZFUlNfTUFYOyBpKyspCisJCWljX25hbWVzZXJ2ZXJzW2ldID0gSU5BRERSX05PTkU7CisKKwlkZXZfYWRkX3BhY2soJmJvb3RwX3BhY2tldF90eXBlKTsKK30KKworCisvKgorICogIERIQ1AvQk9PVFAgY2xlYW51cC4KKyAqLworc3RhdGljIGlubGluZSB2b2lkIGljX2Jvb3RwX2NsZWFudXAodm9pZCkKK3sKKwlkZXZfcmVtb3ZlX3BhY2soJmJvb3RwX3BhY2tldF90eXBlKTsKK30KKworCisvKgorICogIFNlbmQgREhDUC9CT09UUCByZXF1ZXN0IHRvIHNpbmdsZSBpbnRlcmZhY2UuCisgKi8KK3N0YXRpYyB2b2lkIF9faW5pdCBpY19ib290cF9zZW5kX2lmKHN0cnVjdCBpY19kZXZpY2UgKmQsIHVuc2lnbmVkIGxvbmcgamlmZmllc19kaWZmKQoreworCXN0cn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JlYWs7CisKKwkJCWRlZmF1bHQ6CisJCQkJLyogVXJxdWUuICBGb3JnZXQgaXQqLworCQkJCWljX215YWRkciA9IElOQUREUl9OT05FOworCQkJCWljX3NlcnZhZGRyID0gSU5BRERSX05PTkU7CisJCQkJZ290byBkcm9wX3VubG9jazsKKwkJCX07CisKKwkJCWljX2RoY3BfbXNndHlwZSA9IG10OworCisJCX0KKyNlbmRpZiAvKiBJUENPTkZJR19ESENQICovCisKKwkJZXh0ID0gJmItPmV4dGVuWzRdOworCQl3aGlsZSAoZXh0IDwgZW5kICYmICpleHQgIT0gMHhmZikgeworCQkJdTggKm9wdCA9IGV4dCsrOworCQkJaWYgKCpvcHQgPT0gMCkJLyogUGFkZGluZyAqLworCQkJCWNvbnRpbnVlOworCQkJZXh0ICs9ICpleHQgKyAxOworCQkJaWYgKGV4dCA8IGVuZCkKKwkJCQlpY19kb19ib290cF9leHQob3B0KTsKKwkJfQorCX0KKworCS8qIFdlIGhhdmUgYSB3aW5uZXIhICovCisJaWNfZGV2ID0gZGV2OworCWljX215YWRkciA9IGItPnlvdXJfaXA7CisJaWNfc2VydmFkZHIgPSBiLT5zZXJ2ZXJfaXA7CisJaWYgKGljX2dhdGV3YXkgPT0gSU5BRERSX05PTkUgJiYgYi0+cmVsYXlfaXApCisJCWljX2dhdGV3YXkgPSBiLT5yZWxheV9pcDsKKwlpZiAoaWNfbmFtZXNlcnZlcnNbMF0gPT0gSU5BRERSX05PTkUpCisJCWljX25hbWVzZXJ2ZXJzWzBdID0gaWNfc2VydmFkZHI7CisJaWNfZ290X3JlcGx5ID0gSUNfQk9PVFA7CisKK2Ryb3BfdW5sb2NrOgorCS8qIFNob3cncyBvdmVyLiAgTm90aGluZyB0byBzZWUgaGVyZS4gICovCisJc3Bpbl91bmxvY2soJmljX3JlY3ZfbG9jayk7CisKK2Ryb3A6CisJLyogVGhyb3cgdGhlIHBhY2tldCBvdXQuICovCisJa2ZyZWVfc2tiKHNrYik7CisKKwlyZXR1cm4g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IiIsCisJICAgICAgIChkb19ib290cCAmJiBkb19yYXJwKSA/ICIgYW5kICIgOiAiIiwKKwkgICAgICAgZG9fcmFycCA/ICJSQVJQIiA6ICIiKTsKKworCXN0YXJ0X2ppZmZpZXMgPSBqaWZmaWVzOworCWQgPSBpY19maXJzdF9kZXY7CisJcmV0cmllcyA9IENPTkZfU0VORF9SRVRSSUVTOworCWdldF9yYW5kb21fYnl0ZXMoJnRpbWVvdXQsIHNpemVvZih0aW1lb3V0KSk7CisJdGltZW91dCA9IENPTkZfQkFTRV9USU1FT1VUICsgKHRpbWVvdXQgJSAodW5zaWduZWQpIENPTkZfVElNRU9VVF9SQU5ET00pOworCWZvcig7OykgeworI2lmZGVmIElQQ09ORklHX0JPT1RQCisJCWlmIChkb19ib290cCAmJiAoZC0+YWJsZSAmIElDX0JPT1RQKSkKKwkJCWljX2Jvb3RwX3NlbmRfaWYoZCwgamlmZmllcyAtIHN0YXJ0X2ppZmZpZXMpOworI2VuZGlmCisjaWZkZWYgSVBDT05GSUdfUkFSUAorCQlpZiAoZG9fcmFycCAmJiAoZC0+YWJsZSAmIElDX1JBUlApKQorCQkJaWNfcmFycF9zZW5kX2lmKGQpOworI2VuZGlmCisKKwkJamlmZiA9IGppZmZpZXMgKyAoZC0+bmV4dCA/IENPTkZfSU5URVJfVElNRU9VVCA6IHRpbWVvdXQpOworCQl3aGlsZSAodGltZV9iZWZvcmUoamlmZmllcywgamlmZikgJiYgIWljX2dvdF9yZXBseSkgeworCQkJc2V0X2N1cnJlbnRfc3RhdGUoVEFTS19VTklOVEVSUlVQVElCTEUpOworCQkJc2NoZWR1bGVfdGltZW91dCgxKTsKKwkJfQorI2lmZGVmIElQQ09ORklHX0RIQ1AKKwkJLyogREhDUCBpc24ndCBkb25lIHVudGlsIHdlIGdldCBhIERIQ1BBQ0suICovCisJCWlmICgoaWNfZ290X3JlcGx5ICYgSUNfQk9PVFApCisJCSAgICAmJiAoaWNfcHJvdG9fZW5hYmxlZCAmIElDX1VTRV9ESENQKQorCQkgICAgJiYgaWNfZGhjcF9tc2d0eXBlICE9IERIQ1BBQ0spCisJCXsKKwkJCWljX2dvdF9yZXBseSA9IDA7CisJCQlwcmludGsoIiwiKTsKKwkJCWNvbnRpbnVlOworCQl9CisjZW5kaWYgLyogSVBDT05GSUdfREhDUCAqLworCisJCWlmIChpY19nb3RfcmVwbHkpIHsKKwkJCXByaW50aygiIE9LXG4iKTsKKwkJCWJyZWFrOworCQl9CisKKwkJaWYgKChkID0gZC0+bmV4dCkpCisJCQljb250aW51ZTsKKworCQlpZiAoISAtLXJldHJpZXMpIHsKKwkJCXByaW50aygiIHRpbWVkIG91dCFcbiIpOworCQkJYnJlYWs7CisJCX0KKworCQlkID0gaWNfZmlyc3RfZGV2OworCisJCXRpbWVvdXQgPSB0aW1lb3V0IENPTkZfVElNRU9VVF9NVUxUOworCQlpZiAodGltZW91dCA+IENPTkZfVElNRU9VVF9NQVgpCisJCQl0aW1lb3V0ID0gQ09ORl9USU1FT1VUX01BWDsKKworCQlwcmludGsoIi4iKTsKKwl9CisKKyNpZmRlZiBJUENPTkZJR19CT09UUAorCWlmIChkb19ib290cCkKKwkJaWNfYm9vdHBfY2xlYW51cCgpOworI2VuZGlmCisjaWZkZWYgSVBDT05GSUdfUkFSUAorCWlmIChkb19yYXJwKQorCQlpY19yYXJwX2NsZWFudXAoKTsKKyNlbmRpZgorCisJaWYgKCFpY19nb3RfcmVwbHkpCisJCXJldHVybiAtMTsKKworCXByaW50aygiSVAtQ29uZmlnOiBHb3QgJXMgYW5zd2VyIGZyb20gJXUuJXUuJXUuJXUsICIsCisJCSgoaWNfZ290X3JlcGx5ICYgSUNfUkFSUCkgPyAiUkFSUCIgCisJCSA6IChpY19wcm90b19lbmFibGVkICYgSUNfVVNFX0RIQ1ApID8gIkRIQ1AiIDogIkJPT1RQIiksCisJCU5JUFFVQUQoaWNfc2VydmFkZHIpKTsKKwlwcmludGsoIm15IGFkZHJlc3MgaXMgJXUuJXUuJXUuJ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cGFybXMuaXBoLnNhZGRyICYmIHJlbW90ZSA9PSB0LT5wYXJtcy5pcGguZGFkZHIpCisJCQlyZXR1cm4gdDsKKwl9CisJaWYgKCFjcmVhdGUpCisJCXJldHVybiBOVUxMOworCisJaWYgKHBhcm1zLT5uYW1lWzBdKQorCQlzdHJsY3B5KG5hbWUsIHBhcm1zLT5uYW1lLCBJRk5BTVNJWik7CisJZWxzZSB7CisJCWludCBpOworCQlmb3IgKGk9MTsgaTwxMDA7IGkrKykgeworCQkJc3ByaW50ZihuYW1lLCAidHVubCVkIiwgaSk7CisJCQlpZiAoX19kZXZfZ2V0X2J5X25hbWUobmFtZSkgPT0gTlVMTCkKKwkJCQlicmVhazsKKwkJfQorCQlpZiAoaT09MTAwKQorCQkJZ290byBmYWlsZWQ7CisJfQorCisJZGV2ID0gYWxsb2NfbmV0ZGV2KHNpemVvZigqdCksIG5hbWUsIGlwaXBfdHVubmVsX3NldHVwKTsKKwlpZiAoZGV2ID09IE5VTEwpCisJCXJldHVybiBOVUxMOworCisJbnQgPSBkZXYtPnByaXY7CisJU0VUX01PRFVMRV9PV05FUihkZXYpOworCWRldi0+aW5pdCA9IGlwaXBfdHVubmVsX2luaXQ7CisJbnQtPnBhcm1zID0gKnBhcm1zOworCisJaWYgKHJlZ2lzdGVyX25ldGRldmljZShkZXYpIDwgMCkgeworCQlmcmVlX25ldGRldihkZXYpOworCQlnb3RvIGZhaWxlZDsKKwl9CisKKwlkZXZfaG9sZChkZXYpOworCWlwaXBfdHVubmVsX2xpbmsobnQpOworCS8qIERvIG5vdCBkZWNyZW1lbnQgTU9EX1VTRV9DT1VOVCBoZXJlLiAqLworCXJldHVybiBudDsKKworZmFpbGVkOgorCXJldHVybiBOVUxMOworfQorCitzdGF0aWMgdm9pZCBpcGlwX3R1bm5lbF91bmluaXQoc3RydWN0IG5ldF9kZXZpY2UgKmRldikKK3sKKwlpZiAoZGV2ID09IGlwaXBfZmJfdHVubmVsX2RldikgeworCQl3cml0ZV9sb2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iwgc2tiKTsKKwkJCXJlYWRfdW5sb2NrKCZtcnRfbG9jayk7CisKKwkJCXJldHVybiBlcnI7CisJCX0KKwkJcmVhZF91bmxvY2soJm1ydF9sb2NrKTsKKwkJa2ZyZWVfc2tiKHNrYik7CisJCXJldHVybiAtRU5PREVWOworCX0KKworCWlwX21yX2ZvcndhcmQoc2tiLCBjYWNoZSwgbG9jYWwpOworCisJcmVhZF91bmxvY2soJm1ydF9sb2NrKTsKKworCWlmIChsb2NhbCkKKwkJcmV0dXJuIGlwX2xvY2FsX2RlbGl2ZXIoc2tiKTsKKworCXJldHVybiAwOworCitkb250X2ZvcndhcmQ6CisJaWYgKGxvY2FsKQorCQlyZXR1cm4gaXBfbG9jYWxfZGVsaXZlcihza2IpOworCWtmcmVlX3NrYihza2IpOworCXJldHVybiAwOworfQorCisjaWZkZWYgQ09ORklHX0lQX1BJTVNNX1YxCisvKgorICogSGFuZGxlIElHTVAgbWVzc2FnZXMgb2YgUElNdjEKKyAqLworCitpbnQgcGltX3Jjdl92MShzdHJ1Y3Qgc2tfYnVmZiAqIHNrYikKK3sKKwlzdHJ1Y3QgaWdtcGhkciAqcGltOworCXN0cnVjdCBpcGhkciAgICplbmNhcDsKKwlzdHJ1Y3QgbmV0X2RldmljZSAgKnJlZ19kZXYgPSBOVUxMOworCisJaWYgKCFwc2tiX21heV9wdWxsKHNrYiwgc2l6ZW9mKCpwaW0pICsgc2l6ZW9mKCplbmNhcCkpKSAKKwkJZ290byBkcm9wOworCisJcGltID0gKHN0cnVjdCBpZ21waGRyKilza2ItPmgucmF3OworCisgICAgICAgIGlmICghbXJvdXRlX2RvX3BpbSB8fAorCSAgICBza2ItPmxlbiA8IHNpemVvZigqcGltKSArIHNpemVvZigqZW5jYXApIHx8CisJICAgIHBpbS0+Z3JvdXAgIT0gUElNX1YxX1ZFUlNJT04gfHwgcGltLT5jb2RlICE9IFBJTV9WMV9SRUdJU1RFUikgCisJCWdvdG8gZHJvcDsKKworCWVuY2FwID0gK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RpbWVyIG9yIG5ldCBzb2Z0aXJxKQorICovCit2b2lkIGlwX3ZzX2FwcF9pbmNfcHV0KHN0cnVjdCBpcF92c19hcHAgKmluYykKK3sKKwlpcF92c19hcHBfcHV0KGluYy0+YXBwKTsKKwlhdG9taWNfZGVjKCZpbmMtPnVzZWNudCk7Cit9CisKKworLyoKKyAqCVJlZ2lzdGVyIGFuIGFwcGxpY2F0aW9uIGluY2FybmF0aW9uIGluIHByb3RvY29sIGFwcGxpY2F0aW9ucworICovCitpbnQKK3JlZ2lzdGVyX2lwX3ZzX2FwcF9pbmMoc3RydWN0IGlwX3ZzX2FwcCAqYXBwLCBfX3UxNiBwcm90bywgX191MTYgcG9ydCkKK3sKKwlpbnQgcmVzdWx0OworCisJZG93bigmX19pcF92c19hcHBfbXV0ZXgpOworCisJcmVzdWx0ID0gaXBfdnNfYXBwX2luY19uZXcoYXBwLCBwcm90bywgcG9ydCk7CisKKwl1cCgmX19pcF92c19hcHBfbXV0ZXgpOworCisJcmV0dXJuIHJlc3VsdDsKK30KKworCisvKgorICoJaXBfdnNfYXBwIHJlZ2lzdHJhdGlvbiByb3V0aW5lCisgKi8KK2ludCByZWdpc3Rlcl9pcF92c19hcHAoc3RydWN0IGlwX3ZzX2FwcCAqYXBwKQoreworCS8qIGluY3JlYXNlIHRoZSBtb2R1bGUgdXNlIGNvdW50ICovCisJaXBfdnNfdXNlX2NvdW50X2luYygpOworCisJZG93bigmX19pcF92c19hcHBfbXV0ZXgpOworCisJbGlzdF9hZGQoJmFwcC0+YV9saXN0LCAmaXBfdnNfYXBwX2xpc3QpOworCisJdXAoJl9faXBfdnNfYXBwX211dGV4KTsKKworCXJldHVybiAwOworfQorCisKKy8qCisgKglpcF92c19hcHAgdW5yZWdpc3RyYXRpb24gcm91dGluZQorICoJV2UgYXJlIHN1cmUgdGhlcmUgYXJlIG5vIGFwcCBpbmNhcm5hdGlvbnMgYXR0YWNoZWQgdG8gc2VydmljZXMKKyAqLwordm9pZCB1bnJlZ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dHMgdG8gdGhlIG9yaWdpbmFsIHNlcnZlciBkaXJlY3RseS4KKyAqCisgKi8KKworI2luY2x1ZGUgPGxpbnV4L21vZHVsZS5oPgorI2luY2x1ZGUgPGxpbnV4L2tlcm5lbC5oPgorCisjaW5jbHVkZSA8bmV0L2lwX3ZzLmg+CisKKworLyoKKyAqICAgICAgSVBWUyBESCBidWNrZXQKKyAqLworc3RydWN0IGlwX3ZzX2RoX2J1Y2tldCB7CisJc3RydWN0IGlwX3ZzX2Rlc3QgICAgICAgKmRlc3Q7ICAgICAgICAgIC8qIHJlYWwgc2VydmVyIChjYWNoZSkgKi8KK307CisKKy8qCisgKiAgICAgZm9yIElQVlMgREggZW50cnkgaGFzaCB0YWJsZQorICovCisjaWZuZGVmIENPTkZJR19JUF9WU19ESF9UQUJfQklUUworI2RlZmluZSBDT05GSUdfSVBfVlNfREhfVEFCX0JJVFMgICAgICAgIDgKKyNlbmRpZgorI2RlZmluZSBJUF9WU19ESF9UQUJfQklUUyAgICAgICAgICAgICAgIENPTkZJR19JUF9WU19ESF9UQUJfQklUUworI2RlZmluZSBJUF9WU19ESF9UQUJfU0laRSAgICAgICAgICAgICAgICgxIDw8IElQX1ZTX0RIX1RBQl9CSVRTKQorI2RlZmluZSBJUF9WU19ESF9UQUJfTUFTSyAgICAgICAgICAgICAgIChJUF9WU19ESF9UQUJfU0laRSAtIDEpCisKKworLyoKKyAqCVJldHVybnMgaGFzaCB2YWx1ZSBmb3IgSVBWUyBESCBlbnRyeQorICovCitzdGF0aWMgaW5saW5lIHVuc2lnbmVkIGlwX3ZzX2RoX2hhc2hrZXkoX191MzIgYWRkcikKK3sKKwlyZXR1cm4gKG50b2hsKGFkZHIpKjI2NTQ0MzU3NjFVTCkgJiBJUF9WU19ESF9UQUJfTUFTSzsKK30KKworCisvKgorICogICAgICBHZXQgaXBfdnNfZGVzdCBhc3NvY2lhdGVkIHdpdGggc3VwcGxpZWQgcGFyYW1ldGVycy4KKyAqLworc3RhdGljIGlubG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ZSBTb2Z0d2FyZSBGb3VuZGF0aW9uOyBlaXRoZXIgdmVyc2lvbgorICogICAgICAgICAgICAgIDIgb2YgdGhlIExpY2Vuc2UsIG9yIChhdCB5b3VyIG9wdGlvbikgYW55IGxhdGVyIHZlcnNpb24uCisgKgorICogQ2hhbmdlczoKKyAqICAgICBNYXJ0aW4gSGFtaWx0b24gICAgICAgICA6ICAgIGZpeGVkIHRoZSB0ZXJyaWJsZSBsb2NraW5nIGJ1Z3MKKyAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqbG9jayh0YmwtPmxvY2spID09PiAqbG9jaygmdGJsLT5sb2NrKQorICogICAgIFdlbnNvbmcgWmhhbmcgICAgICAgICAgIDogICAgZml4ZWQgdGhlIHVuaW5pdGlsaXplZCB0YmwtPmxvY2sgYnVnCisgKiAgICAgV2Vuc29uZyBaaGFuZyAgICAgICAgICAgOiAgICBhZGRlZCBkb2luZyBmdWxsIGV4cGlyYXRpb24gY2hlY2sgdG8KKyAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb2xsZWN0IHN0YWxlIGVudHJpZXMgb2YgMjQrIGhvdXJzIHdoZW4KKyAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBubyBwYXJ0aWFsIGV4cGlyZSBjaGVjayBpbiBhIGhhbGYgaG91cgorICogICAgIEp1bGlhbiBBbmFzdGFzb3YgICAgICAgIDogICAgcmVwbGFjZWQgZGVsX3RpbWVyIGNhbGwgd2l0aCBkZWxfdGltZXJfc3luYworICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRvIGF2b2lkIHRoZSBwb3NzaWJsZSByYWNlIGJldHdlZW4gdGltZXIKKyAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYW5kbGVyIGFuZCBkZWxfdGltZXIgdGhyZWFkIGluIFNNUAorICoKKyAqLworCisvKgorICogVGhlIGxibGMgYWxnb3JpdGhtIGlzIGFzIGZvbGxvd3MgKH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aW9uIHNlcnZlcgorICovCitzdHJ1Y3QgaXBfdnNfbGJsY19lbnRyeSB7CisJc3RydWN0IGxpc3RfaGVhZCAgICAgICAgbGlzdDsKKwlfX3UzMiAgICAgICAgICAgICAgICAgICBhZGRyOyAgICAgICAgICAgLyogZGVzdGluYXRpb24gSVAgYWRkcmVzcyAqLworCXN0cnVjdCBpcF92c19kZXN0ICAgICAgICpkZXN0OyAgICAgICAgICAvKiByZWFsIHNlcnZlciAoY2FjaGUpICovCisJdW5zaWduZWQgbG9uZyAgICAgICAgICAgbGFzdHVzZTsgICAgICAgIC8qIGxhc3QgdXNlZCB0aW1lICovCit9OworCisKKy8qCisgKiAgICAgIElQVlMgbGJsYyBoYXNoIHRhYmxlCisgKi8KK3N0cnVjdCBpcF92c19sYmxjX3RhYmxlIHsKKwlyd2xvY2tfdAkgICAgICAgIGxvY2s7ICAgICAgICAgICAvKiBsb2NrIGZvciB0aGlzIHRhYmxlICovCisJc3RydWN0IGxpc3RfaGVhZCAgICAgICAgYnVja2V0W0lQX1ZTX0xCTENfVEFCX1NJWkVdOyAgLyogaGFzaCBidWNrZXQgKi8KKwlhdG9taWNfdCAgICAgICAgICAgICAgICBlbnRyaWVzOyAgICAgICAgLyogbnVtYmVyIG9mIGVudHJpZXMgKi8KKwlpbnQgICAgICAgICAgICAgICAgICAgICBtYXhfc2l6ZTsgICAgICAgLyogbWF4aW11bSBzaXplIG9mIGVudHJpZXMgKi8KKwlzdHJ1Y3QgdGltZXJfbGlzdCAgICAgICBwZXJpb2RpY190aW1lcjsgLyogY29sbGVjdCBzdGFsZSBlbnRyaWVzICovCisJaW50ICAgICAgICAgICAgICAgICAgICAgcm92ZXI7ICAgICAgICAgIC8qIHJvdmVyIGZvciBleHBpcmUgY2hlY2sgKi8KKwlpbnQgICAgICAgICAgICAgICAgICAgICBjb3VudGVyOyAgICAgICAgLyogY291bnRlciBmb3Igbm8gZXhwaXJlICovCit9OworCisKKy8qCisgKiAgICAgIElQVlMgTEJMQy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ICoKKyAqIEF1dGhvcnM6ICAgICBXZW5zb25nIFpoYW5nIDx3ZW5zb25nQGdudWNoaW5hLm9yZz4KKyAqCisgKiAgICAgICAgICAgICAgVGhpcyBwcm9ncmFtIGlzIGZyZWUgc29mdHdhcmU7IHlvdSBjYW4gcmVkaXN0cmlidXRlIGl0IGFuZC9vcgorICogICAgICAgICAgICAgIG1vZGlmeSBpdCB1bmRlciB0aGUgdGVybXMgb2YgdGhlIEdOVSBHZW5lcmFsIFB1YmxpYyBMaWNlbnNlCisgKiAgICAgICAgICAgICAgYXMgcHVibGlzaGVkIGJ5IHRoZSBGcmVlIFNvZnR3YXJlIEZvdW5kYXRpb247IGVpdGhlciB2ZXJzaW9uCisgKiAgICAgICAgICAgICAgMiBvZiB0aGUgTGljZW5zZSwgb3IgKGF0IHlvdXIgb3B0aW9uKSBhbnkgbGF0ZXIgdmVyc2lvbi4KKyAqCisgKiBDaGFuZ2VzOgorICogICAgIEp1bGlhbiBBbmFzdGFzb3YgICAgICAgIDogICAgQWRkZWQgdGhlIG1pc3NpbmcgKGRlc3QtPndlaWdodD4wKQorICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uZGl0aW9uIGluIHRoZSBpcF92c19kZXN0X3NldF9tYXguCisgKgorICovCisKKy8qCisgKiBUaGUgbGJsYy9yIGFsZ29yaXRobSBpcyBhcyBmb2xsb3dzIChwc2V1ZG8gY29kZSk6CisgKgorICogICAgICAgaWYgc2VydmVyU2V0W2Rlc3RfaXBdIGlzIG51bGwgdGhlbgorICogICAgICAgICAgICAgICBuLCBzZXJ2ZXJTZXRbZGVzdF9pcF0gPC0ge3dlaWdodGVkIGxlYXN0LWNvbm4gbm9kZX07CisgKiAgICAgICBlbHNlCisgKiAgICAgICAgICAgICAgIG4gPC0ge2xlYXN0LWNvbm4gKGFsaXZlKSBub2RlIGluIHNlcnZlclNldFtkZXN0X2lwXX07CisgKiAgICAgICAgICAgICAgIGlmIChuIGlzIG51bGwpIE9SCisgKi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LyoKKyAqICAgICAgSVBWUyBsYmxjciBlbnRyeSByZXByZXNlbnRzIGFuIGFzc29jaWF0aW9uIGJldHdlZW4gZGVzdGluYXRpb24KKyAqICAgICAgSVAgYWRkcmVzcyBhbmQgaXRzIGRlc3RpbmF0aW9uIHNlcnZlciBzZXQKKyAqLworc3RydWN0IGlwX3ZzX2xibGNyX2VudHJ5IHsKKwlzdHJ1Y3QgbGlzdF9oZWFkICAgICAgICBsaXN0OworCV9fdTMyICAgICAgICAgICAgICAgICAgIGFkZHI7ICAgICAgICAgICAvKiBkZXN0aW5hdGlvbiBJUCBhZGRyZXNzICovCisJc3RydWN0IGlwX3ZzX2Rlc3Rfc2V0ICAgc2V0OyAgICAgICAgICAgIC8qIGRlc3RpbmF0aW9uIHNlcnZlciBzZXQgKi8KKwl1bnNpZ25lZCBsb25nICAgICAgICAgICBsYXN0dXNlOyAgICAgICAgLyogbGFzdCB1c2VkIHRpbWUgKi8KK307CisKKworLyoKKyAqICAgICAgSVBWUyBsYmxjciBoYXNoIHRhYmxlCisgKi8KK3N0cnVjdCBpcF92c19sYmxjcl90YWJsZSB7CisJcndsb2NrX3QJICAgICAgICBsb2NrOyAgICAgICAgICAgLyogbG9jayBmb3IgdGhpcyB0YWJsZSAqLworCXN0cnVjdCBsaXN0X2hlYWQgICAgICAgIGJ1Y2tldFtJUF9WU19MQkxDUl9UQUJfU0laRV07ICAvKiBoYXNoIGJ1Y2tldCAqLworCWF0b21pY190ICAgICAgICAgICAgICAgIGVudHJpZXM7ICAgICAgICAvKiBudW1iZXIgb2YgZW50cmllcyAqLworCWludCAgICAgICAgICAgICAgICAgICAgIG1heF9zaXplOyAgICAgICAvKiBtYXhpbXVtIHNpemUgb2YgZW50cmllcyAqLworCXN0cnVjdCB0aW1lcl9saXN0ICAgICAgIHBlcmlvZGljX3RpbWVyOyAvKiBjb2xsZWN0IHN0YWxlIGVudHJpZXMgKi8KKwlpbnQgICAgICAgICAgICAgICAgICAgICByb3ZlcjsgICAgIC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NfY29ubiB7CisJX191OAkJCXJlc2VydmVkOworCisJLyogUHJvdG9jb2wsIGFkZHJlc3NlcyBhbmQgcG9ydCBudW1iZXJzICovCisJX191OAkJCXByb3RvY29sOyAgICAgICAvKiBXaGljaCBwcm90b2NvbCAoVENQL1VEUCkgKi8KKwlfX3UxNgkJCWNwb3J0OworCV9fdTE2ICAgICAgICAgICAgICAgICAgIHZwb3J0OworCV9fdTE2ICAgICAgICAgICAgICAgICAgIGRwb3J0OworCV9fdTMyICAgICAgICAgICAgICAgICAgIGNhZGRyOyAgICAgICAgICAvKiBjbGllbnQgYWRkcmVzcyAqLworCV9fdTMyICAgICAgICAgICAgICAgICAgIHZhZGRyOyAgICAgICAgICAvKiB2aXJ0dWFsIGFkZHJlc3MgKi8KKwlfX3UzMiAgICAgICAgICAgICAgICAgICBkYWRkcjsgICAgICAgICAgLyogZGVzdGluYXRpb24gYWRkcmVzcyAqLworCisJLyogRmxhZ3MgYW5kIHN0YXRlIHRyYW5zaXRpb24gKi8KKwlfX3UxNiAgICAgICAgICAgICAgICAgICBmbGFnczsgICAgICAgICAgLyogc3RhdHVzIGZsYWdzICovCisJX191MTYgICAgICAgICAgICAgICAgICAgc3RhdGU7ICAgICAgICAgIC8qIHN0YXRlIGluZm8gKi8KKworCS8qIFRoZSBzZXF1ZW5jZSBvcHRpb25zIHN0YXJ0IGhlcmUgKi8KK307CisKK3N0cnVjdCBpcF92c19zeW5jX2Nvbm5fb3B0aW9ucyB7CisJc3RydWN0IGlwX3ZzX3NlcSAgICAgICAgaW5fc2VxOyAgICAgICAgIC8qIGluY29taW5nIHNlcS4gc3RydWN0ICovCisJc3RydWN0IGlwX3ZzX3NlcSAgICAgICAgb3V0X3NlcTsgICAgICAgIC8qIG91dGdvaW5nIHNlcS4gc3RydWN0ICovCit9OworCisjZGVmaW5lIElQX1ZTX1NZTkNfQ09OTl9USU1FT1VUICgzKjYwKkhaKQorI2RlZmluZSBTSU1QTEVfQ09OTl9TSVpFICAoc2l6ZW9mKHN0cnVjdCBpcF92c19zeW5jX2Nvbm4pKQorI2RlZmluZSBGVUxMX0NPTk5fU0laRSAgXAorKHNpemVvZihzdHJ1Y3QgaXBfdnNfc3luY19jb25uKSArIHNpemVvZihzdHJ1Y3QgaXBfdnNfc3luY19jb25uX29wdGlvbnMpKQorCisKKy8qCisgIFRoZSBtYXN0ZXIgbXVsaXRjYXN0cyBtZXNzYWdlcyB0byB0aGUgYmFja3VwIGxvYWQgYmFsYW5jZXJzIGluIHRoZQorICBmb2xsb3dpbmcgZm9ybWF0LgorCisgICAgICAgMCAgICAgICAgICAgICAgICAgICAxICAgICAgICAgICAgICAgICAgIDIgICAgICAgICAgICAgICAgICAgMworICAgICAgIDAgMSAyIDMgNCA1IDYgNyA4IDkgMCAxIDIgMyA0IDUgNiA3IDggOSAwIDEgMiAzIDQgNSA2IDcgOCA5IDAgMQorICAgICAgKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSsKKyAgICAgIHwgIENvdW50IENvbm5zICB8ICAgIFN5bmNJRCAgICAgfCAgICAgICAgICAgIFNpemUgICAgICAgICAgICAgICB8CisgICAgICArLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKworICAgICAgfCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwKKyAgICAgIHwgICAgICAgICAgICAgICAgICAgIElQVlMgU3luYyBDb25uZWN0aW9uICgxKSAgICAgICAgICAgICAgICAgICB8CisgICAgICArLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKworICAgICAgfCAgICAgICAgICAgICAgICAgICAgICAgICAgICAuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwKKyAgICAgIHwgICAgICAgICAgICAgICAgICAgICAgICAgICAgLiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB8CisgICAgICB8ICAgICAgICAgICAgICAgICAgICAgICAgICAgIC4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfAorICAgICAgKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSsKKyAgICAgIHwgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB8CisgICAgICB8ICAgICAgICAgICAgICAgICAgICBJUFZTIFN5bmMgQ29ubmVjdGlvbiAobikgICAgICAgICAgICAgICAgICAgfAorICAgICAgKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSsKKyovCisKKyNkZWZpbmUgU1lOQ19NRVNHX0hFQURFUl9MRU4JNAorCitzdHJ1Y3QgaXBfdnNfc3luY19tZXNnIHsKKwlfX3U4ICAgICAgICAgICAgICAgICAgICBucl9jb25uczsKKwlfX3U4ICAgICAgICAgICAgICAgICAgICBzeW5jaWQ7CisJX191MTYgICAgICAgICAgICAgICAgICAgc2l6ZTsKKworCS8qIGlwX3ZzX3N5bmNfY29ubiBlbnRyaWVzIHN0YXJ0IGhlcmUgKi8KK307CisKKy8qIHRoZSBtYXhpbXVtIGxlbmd0aCBvZiBzeW5jIChzZW5kaW5nL3JlY2VpdmluZykgbWVzc2FnZSAqLworc3RhdGljIGludCBzeW5jX3NlbmRfbWVzZ19tYXhsZW47CitzdGF0aWMgaW50IHN5bmNfcmVjdl9tZXNnX21heGxlbjsKKworc3RydWN0IGlwX3ZzX3N5bmNfYnVmZiB7CisJc3RydWN0IGxpc3RfaGVhZCAgICAgICAgbGlzdDsKKwl1bnNpZ25lZCBsb25nICAgICAgICAgICBmaXJzdHVzZTsKKworCS8qIHBvaW50ZXJzIGZ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IDogICAgIGNoYW5nZWQgc29tZSBjb21lc3RpY3MgdGhpbmdzIGZvciBkZWJ1Z2dpbmcKKyAqICAgICBXZW5zb25nIFpoYW5nICAgICAgICAgICAgOiAgICAgY2hhbmdlZCBmb3IgdGhlIGQtbGlua2VkIGRlc3RpbmF0aW9uIGxpc3QKKyAqICAgICBXZW5zb25nIFpoYW5nICAgICAgICAgICAgOiAgICAgYWRkZWQgdGhlIGlwX3ZzX3dycl91cGRhdGVfc3ZjCisgKiAgICAgSnVsaWFuIEFuYXN0YXNvdiAgICAgICAgIDogICAgIGZpeGVkIHRoZSBidWcgb2YgcmV0dXJuaW5nIGRlc3RpbmF0aW9uCisgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdpdGggd2VpZ2h0IDAgd2hlbiBhbGwgd2VpZ2h0cyBhcmUgemVybworICoKKyAqLworCisjaW5jbHVkZSA8bGludXgvbW9kdWxlLmg+CisjaW5jbHVkZSA8bGludXgva2VybmVsLmg+CisKKyNpbmNsdWRlIDxuZXQvaXBfdnMuaD4KKworLyoKKyAqIGN1cnJlbnQgZGVzdGluYXRpb24gcG9pbnRlciBmb3Igd2VpZ2h0ZWQgcm91bmQtcm9iaW4gc2NoZWR1bGluZworICovCitzdHJ1Y3QgaXBfdnNfd3JyX21hcmsgeworCXN0cnVjdCBsaXN0X2hlYWQgKmNsOwkvKiBjdXJyZW50IGxpc3QgaGVhZCAqLworCWludCBjdzsJCQkvKiBjdXJyZW50IHdlaWdodCAqLworCWludCBtdzsJCQkvKiBtYXhpbXVtIHdlaWdodCAqLworCWludCBkaTsJCQkvKiBkZWNyZWFzaW5nIGludGVydmFsICovCit9OworCisKKy8qCisgKiAgICBHZXQgdGhlIGdjZCBvZiBzZXJ2ZXIgd2VpZ2h0cworICovCitzdGF0aWMgaW50IGdjZChpbnQgYSwgaW50IGIpCit7CisJaW50IGM7CisKKwl3aGlsZSAoKGMgPSBhICUgYikpIHsKKwkJYSA9IGI7CisJCWIgPSBj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YW1hbmRhLm8KK29iai0kKENPTkZJR19JUF9ORl9OQVRfVEZUUCkgKz0gaXBfbmF0X3RmdHAubworb2JqLSQoQ09ORklHX0lQX05GX05BVF9GVFApICs9IGlwX25hdF9mdHAubworb2JqLSQoQ09ORklHX0lQX05GX05BVF9JUkMpICs9IGlwX25hdF9pcmMubworCisjIGdlbmVyaWMgSVAgdGFibGVzIAorb2JqLSQoQ09ORklHX0lQX05GX0lQVEFCTEVTKSArPSBpcF90YWJsZXMubworCisjIHRoZSB0aHJlZSBpbnN0YW5jZXMgb2YgaXBfdGFibGVzCitvYmotJChDT05GSUdfSVBfTkZfRklMVEVSKSArPSBpcHRhYmxlX2ZpbHRlci5vCitvYmotJChDT05GSUdfSVBfTkZfTUFOR0xFKSArPSBpcHRhYmxlX21hbmdsZS5vCitvYmotJChDT05GSUdfSVBfTkZfTkFUKSArPSBpcHRhYmxlX25hdC5vCitvYmotJChDT05GSUdfSVBfTkZfUkFXKSArPSBpcHRhYmxlX3Jhdy5vCisKKyMgbWF0Y2hlcworb2JqLSQoQ09ORklHX0lQX05GX01BVENIX0hFTFBFUikgKz0gaXB0X2hlbHBlci5vCitvYmotJChDT05GSUdfSVBfTkZfTUFUQ0hfTElNSVQpICs9IGlwdF9saW1pdC5vCitvYmotJChDT05GSUdfSVBfTkZfTUFUQ0hfSEFTSExJTUlUKSArPSBpcHRfaGFzaGxpbWl0Lm8KK29iai0kKENPTkZJR19JUF9ORl9NQVRDSF9TQ1RQKSArPSBpcHRfc2N0cC5vCitvYmotJChDT05GSUdfSVBfTkZfTUFUQ0hfTUFSSykgKz0gaXB0X21hcmsubworb2JqLSQoQ09ORklHX0lQX05GX01BVENIX01BQykgKz0gaXB0X21hYy5vCitvYmotJChDT05GSUdfSVBfTkZfTUFUQ0hfSVBSQU5HRSkgKz0gaXB0X2lwcmFuZ2Uubworb2JqLSQoQ09ORklHX0lQX05GX01BVENIX1BLVFRZUEUpICs9IGlwdF9wa3R0eXBlLm8KK29iai0kKEN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ElTVF9IRUFEKGFycHRfdGFibGVzKTsKKyNkZWZpbmUgQUREX0NPVU5URVIoYyxiLHApIGRvIHsgKGMpLmJjbnQgKz0gKGIpOyAoYykucGNudCArPSAocCk7IH0gd2hpbGUoMCkKKworI2lmZGVmIENPTkZJR19TTVAKKyNkZWZpbmUgVEFCTEVfT0ZGU0VUKHQscCkgKFNNUF9BTElHTigodCktPnNpemUpKihwKSkKKyNlbHNlCisjZGVmaW5lIFRBQkxFX09GRlNFVCh0LHApIDAKKyNlbmRpZgorCitzdGF0aWMgaW5saW5lIGludCBhcnBfZGV2YWRkcl9jb21wYXJlKGNvbnN0IHN0cnVjdCBhcnB0X2RldmFkZHJfaW5mbyAqYXAsCisJCQkJICAgICAgY2hhciAqaGRyX2FkZHIsIGludCBsZW4pCit7CisJaW50IGksIHJldDsKKworCWlmIChsZW4gPiBBUlBUX0RFVl9BRERSX0xFTl9NQVgpCisJCWxlbiA9IEFSUFRfREVWX0FERFJfTEVOX01BWDsKKworCXJldCA9IDA7CisJZm9yIChpID0gMDsgaSA8IGxlbjsgaSsrKQorCQlyZXQgfD0gKGhkcl9hZGRyW2ldIF4gYXAtPmFkZHJbaV0pICYgYXAtPm1hc2tbaV07CisKKwlyZXR1cm4gKHJldCAhPSAwKTsKK30KKworLyogUmV0dXJucyB3aGV0aGVyIHBhY2tldCBtYXRjaGVzIHJ1bGUgb3Igbm90LiAqLworc3RhdGljIGlubGluZSBpbnQgYXJwX3BhY2tldF9tYXRjaChjb25zdCBzdHJ1Y3QgYXJwaGRyICphcnBoZHIsCisJCQkJICAgc3RydWN0IG5ldF9kZXZpY2UgKmRldiwKKwkJCQkgICBjb25zdCBjaGFyICppbmRldiwKKwkJCQkgICBjb25zdCBjaGFyICpvdXRkZXYsCisJCQkJICAgY29uc3Qgc3RydWN0IGFycHRfYXJwICphcnBpbmZvKQoreworCWNoYXIgKmFycHB0ciA9IChjaGFyICopKGFycGhkciArIDEpOworCWNoYXIgKnNyY19kZXZhZGRyLCAqdGd0X2RldmFkZHI7CisJdTMyIHNyY19pcGFkZHIsIHRndF9pcGFkZHI7CisJaW50IGksIHJldDsKKworI2RlZmluZSBGV0lOVihib29sLGludmZsZykgKChib29sKSBeICEhKGFycGluZm8tPmludmZsYWdzICYgaW52ZmxnKSkKKworCWlmIChGV0lOVigoYXJwaGRyLT5hcl9vcCAmIGFycGluZm8tPmFycG9wX21hc2spICE9IGFycGluZm8tPmFycG9wLAorCQkgIEFSUFRfSU5WX0FSUE9QKSkgeworCQlkcHJpbnRmKCJBUlAgb3BlcmF0aW9uIGZpZWxkIG1pc21hdGNoLlxuIik7CisJCWRwcmludGYoImFyX29wOiAlMDR4IGluZm8tPmFycG9wOiAlMDR4IGluZm8tPmFycG9wX21hc2s6ICUwNHhcbiIsCisJCQlhcnBoZHItPmFyX29wLCBhcnBpbmZvLT5hcnBvcCwgYXJwaW5mby0+YXJwb3BfbWFzayk7CisJCXJldHVybiAwOworCX0KKworCWlmIChGV0lOVigoYXJwaGRyLT5hcl9ocmQgJiBhcnBpbmZvLT5hcmhyZF9tYXNrKSAhPSBhcnBpbmZvLT5hcmhyZCwKKwkJICBBUlBUX0lOVl9BUlBIUkQpKSB7CisJCWRwcmludGYoIkFSUCBoYXJkd2FyZSBhZGRyZXNzIGZvcm1hdCBtaXNtYXRjaC5cbiIpOworCQlkcHJpbnRmKCJhcl9ocmQ6ICUwNHggaW5mby0+YXJocmQ6ICUwNHggaW5mby0+YXJocmRfbWFzazogJTA0eFxuIiwKKwkJCWFycGhkci0+YXJfaHJkLCBhcnBpbmZvLT5hcmhyZCwgYXJwaW5mby0+YXJocmRfbWFzayk7CisJCXJldHVybiAwOworCX0KKworCWlmIChGV0lOVigoYXJwaGRyLT5hcl9wcm8gJiBhcnBpbmZvLT5hcnByb19tYXNrKSAhPSBhcnBpbmZvLT5hcnBybywKKwkJICBBUlBUX0lOVl9BUlBQUk8pKSB7CisJCWRwcmludGYoIkFSUCBwcm90b2NvbCBhZGRyZXNzIGZvcm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BzaXplb2Yoc3RydWN0IGFycHRfZW50cnlfdGFyZ2V0KSkgeworCQlkdXByaW50ZigiY2hlY2tpbmc6IGVsZW1lbnQgJXAgc2l6ZSAldVxuIiwKKwkJCSBlLCBlLT5uZXh0X29mZnNldCk7CisJCXJldHVybiAtRUlOVkFMOworCX0KKworCS8qIENoZWNrIGhvb2tzICYgdW5kZXJmbG93cyAqLworCWZvciAoaCA9IDA7IGggPCBORl9BUlBfTlVNSE9PS1M7IGgrKykgeworCQlpZiAoKHVuc2lnbmVkIGNoYXIgKillIC0gYmFzZSA9PSBob29rX2VudHJpZXNbaF0pCisJCQluZXdpbmZvLT5ob29rX2VudHJ5W2hdID0gaG9va19lbnRyaWVzW2hdOworCQlpZiAoKHVuc2lnbmVkIGNoYXIgKillIC0gYmFzZSA9PSB1bmRlcmZsb3dzW2hdKQorCQkJbmV3aW5mby0+dW5kZXJmbG93W2hdID0gdW5kZXJmbG93c1toXTsKKwl9CisKKwkvKiBGSVhNRTogdW5kZXJmbG93cyBtdXN0IGJlIHVuY29uZGl0aW9uYWwsIHN0YW5kYXJkIHZlcmRpY3RzCisgICAgICAgICAgIDwgMCAobm90IEFSUFRfUkVUVVJOKS4gLS1SUiAqLworCisJLyogQ2xlYXIgY291bnRlcnMgYW5kIGNvbWVmcm9tICovCisJZS0+Y291bnRlcnMgPSAoKHN0cnVjdCBhcnB0X2NvdW50ZXJzKSB7IDAsIDAgfSk7CisJZS0+Y29tZWZyb20gPSAwOworCisJKCppKSsrOworCXJldHVybiAwOworfQorCitzdGF0aWMgaW5saW5lIGludCBjbGVhbnVwX2VudHJ5KHN0cnVjdCBhcnB0X2VudHJ5ICplLCB1bnNpZ25lZCBpbnQgKmkpCit7CisJc3RydWN0IGFycHRfZW50cnlfdGFyZ2V0ICp0OworCisJaWYgKGkgJiYgKCppKS0tID09IDApCisJCXJldHVybiAxOworCisJdCA9IGFycHRfZ2V0X3RhcmdldChlKTsKKwlpZiAodC0+dS5rZXJuZWwudGFyZ2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07CisKKwlpZiAoY29weV9mcm9tX3VzZXIobmV3aW5mby0+ZW50cmllcywgdXNlciArIHNpemVvZih0bXApLAorCQkJICAgdG1wLnNpemUpICE9IDApIHsKKwkJcmV0ID0gLUVGQVVMVDsKKwkJZ290byBmcmVlX25ld2luZm87CisJfQorCisJY291bnRlcnMgPSB2bWFsbG9jKHRtcC5udW1fY291bnRlcnMgKiBzaXplb2Yoc3RydWN0IGFycHRfY291bnRlcnMpKTsKKwlpZiAoIWNvdW50ZXJzKSB7CisJCXJldCA9IC1FTk9NRU07CisJCWdvdG8gZnJlZV9uZXdpbmZvOworCX0KKwltZW1zZXQoY291bnRlcnMsIDAsIHRtcC5udW1fY291bnRlcnMgKiBzaXplb2Yoc3RydWN0IGFycHRfY291bnRlcnMpKTsKKworCXJldCA9IHRyYW5zbGF0ZV90YWJsZSh0bXAubmFtZSwgdG1wLnZhbGlkX2hvb2tzLAorCQkJICAgICAgbmV3aW5mbywgdG1wLnNpemUsIHRtcC5udW1fZW50cmllcywKKwkJCSAgICAgIHRtcC5ob29rX2VudHJ5LCB0bXAudW5kZXJmbG93KTsKKwlpZiAocmV0ICE9IDApCisJCWdvdG8gZnJlZV9uZXdpbmZvX2NvdW50ZXJzOworCisJZHVwcmludGYoImFycF90YWJsZXM6IFRyYW5zbGF0ZWQgdGFibGVcbiIpOworCisJdCA9IGFycHRfZmluZF90YWJsZV9sb2NrKHRtcC5uYW1lLCAmcmV0LCAmYXJwdF9tdXRleCk7CisJaWYgKCF0KQorCQlnb3RvIGZyZWVfbmV3aW5mb19jb3VudGVyc191bnRyYW5zOworCisJLyogWW91IGxpZWQhICovCisJaWYgKHRtcC52YWxpZF9ob29rcyAhPSB0LT52YWxpZF9ob29rcykgeworCQlkdXByaW50ZigiVmFsaWQgaG9vayBjcmFwOiAlMDhYIHZzICUwOFhcbiIsCisJCQkgdG1wLnZhbGlkX2hvb2tzLCB0LT52YWxpZF9ob29rcyk7CisJCXJldCA9IC1FSU5WQUw7CisJCWd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vbm50cmFjay0+Y3RfZ2VuZXJhbC5kZXN0cm95ID0gZGVzdHJveV9jb25udHJhY2s7CisJY29ubnRyYWNrLT50dXBsZWhhc2hbSVBfQ1RfRElSX09SSUdJTkFMXS50dXBsZSA9ICp0dXBsZTsKKwljb25udHJhY2stPnR1cGxlaGFzaFtJUF9DVF9ESVJfUkVQTFldLnR1cGxlID0gcmVwbF90dXBsZTsKKwlpZiAoIXByb3RvY29sLT5uZXcoY29ubnRyYWNrLCBza2IpKSB7CisJCWttZW1fY2FjaGVfZnJlZShpcF9jb25udHJhY2tfY2FjaGVwLCBjb25udHJhY2spOworCQlyZXR1cm4gTlVMTDsKKwl9CisJLyogRG9uJ3Qgc2V0IHRpbWVyIHlldDogd2FpdCBmb3IgY29uZmlybWF0aW9uICovCisJaW5pdF90aW1lcigmY29ubnRyYWNrLT50aW1lb3V0KTsKKwljb25udHJhY2stPnRpbWVvdXQuZGF0YSA9ICh1bnNpZ25lZCBsb25nKWNvbm50cmFjazsKKwljb25udHJhY2stPnRpbWVvdXQuZnVuY3Rpb24gPSBkZWF0aF9ieV90aW1lb3V0OworCisJV1JJVEVfTE9DSygmaXBfY29ubnRyYWNrX2xvY2spOworCWV4cCA9IGZpbmRfZXhwZWN0YXRpb24odHVwbGUpOworCisJaWYgKGV4cCkgeworCQlERUJVR1AoImNvbm50cmFjazogZXhwZWN0YXRpb24gYXJyaXZlcyBjdD0lcCBleHA9JXBcbiIsCisJCQljb25udHJhY2ssIGV4cCk7CisJCS8qIFdlbGNvbWUsIE1yLiBCb25kLiAgV2UndmUgYmVlbiBleHBlY3RpbmcgeW91Li4uICovCisJCV9fc2V0X2JpdChJUFNfRVhQRUNURURfQklULCAmY29ubnRyYWNrLT5zdGF0dXMpOworCQljb25udHJhY2stPm1hc3RlciA9IGV4cC0+bWFzdGVyOworI2lmIENPTkZJR19JUF9ORl9DT05OVFJBQ0tfTUFSSworCQljb25udHJhY2stPm1hcmsgPSBleHAtPm1hc3Rlci0+bWFyazs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VCwgJmN0LT5zdGF0dXMpKSB7CisJCQlERUJVR1AoImlwX2Nvbm50cmFja19pbjogbm9ybWFsIHBhY2tldCBmb3IgJXBcbiIsCisJCQkgICAgICAgY3QpOworCQkgICAgICAgICpjdGluZm8gPSBJUF9DVF9FU1RBQkxJU0hFRDsKKwkJfSBlbHNlIGlmICh0ZXN0X2JpdChJUFNfRVhQRUNURURfQklULCAmY3QtPnN0YXR1cykpIHsKKwkJCURFQlVHUCgiaXBfY29ubnRyYWNrX2luOiByZWxhdGVkIHBhY2tldCBmb3IgJXBcbiIsCisJCQkgICAgICAgY3QpOworCQkJKmN0aW5mbyA9IElQX0NUX1JFTEFURUQ7CisJCX0gZWxzZSB7CisJCQlERUJVR1AoImlwX2Nvbm50cmFja19pbjogbmV3IHBhY2tldCBmb3IgJXBcbiIsCisJCQkgICAgICAgY3QpOworCQkJKmN0aW5mbyA9IElQX0NUX05FVzsKKwkJfQorCQkqc2V0X3JlcGx5ID0gMDsKKwl9CisJc2tiLT5uZmN0ID0gJmN0LT5jdF9nZW5lcmFsOworCXNrYi0+bmZjdGluZm8gPSAqY3RpbmZvOworCXJldHVybiBjdDsKK30KKworLyogTmV0ZmlsdGVyIGhvb2sgaXRzZWxmLiAqLwordW5zaWduZWQgaW50IGlwX2Nvbm50cmFja19pbih1bnNpZ25lZCBpbnQgaG9va251bSwKKwkJCSAgICAgc3RydWN0IHNrX2J1ZmYgKipwc2tiLAorCQkJICAgICBjb25zdCBzdHJ1Y3QgbmV0X2RldmljZSAqaW4sCisJCQkgICAgIGNvbnN0IHN0cnVjdCBuZXRfZGV2aWNlICpvdXQsCisJCQkgICAgIGludCAoKm9rZm4pKHN0cnVjdCBza19idWZmICopKQoreworCXN0cnVjdCBpcF9jb25udHJhY2sgKmN0OworCWVudW0gaXBfY29ubnRyYWNrX2luZm8gY3RpbmZvOworCXN0cnVjdCBpcF9jb25udHJhY2tfcHJvdG9jb2wgKnByb3RvOworCWludCBzZXRfcmVwbHk7CisJaW50I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5zZWVuWzBdOworCXN0cnVjdCBpcF9jdF90Y3Bfc3RhdGUgKnJlY2VpdmVyID0gJmNvbm50cmFjay0+cHJvdG8udGNwLnNlZW5bMV07CisjZW5kaWYKKworCXRoID0gc2tiX2hlYWRlcl9wb2ludGVyKHNrYiwgaXBoLT5paGwgKiA0LAorCQkJCXNpemVvZihfdGNwaCksICZfdGNwaCk7CisJQlVHX09OKHRoID09IE5VTEwpOworCQorCS8qIERvbid0IG5lZWQgbG9jayBoZXJlOiB0aGlzIGNvbm50cmFjayBub3QgaW4gY2lyY3VsYXRpb24geWV0ICovCisJbmV3X3N0YXRlCisJCT0gdGNwX2Nvbm50cmFja3NbMF1bZ2V0X2Nvbm50cmFja19pbmRleCh0aCldCisJCVtUQ1BfQ09OTlRSQUNLX05PTkVdOworCisJLyogSW52YWxpZDogZGVsZXRlIGNvbm50cmFjayAqLworCWlmIChuZXdfc3RhdGUgPj0gVENQX0NPTk5UUkFDS19NQVgpIHsKKwkJREVCVUdQKCJpcF9jdF90Y3A6IGludmFsaWQgbmV3IGRlbGV0aW5nLlxuIik7CisJCXJldHVybiAwOworCX0KKworCWlmIChuZXdfc3RhdGUgPT0gVENQX0NPTk5UUkFDS19TWU5fU0VOVCkgeworCQkvKiBTWU4gcGFja2V0ICovCisJCWNvbm50cmFjay0+cHJvdG8udGNwLnNlZW5bMF0udGRfZW5kID0KKwkJCXNlZ21lbnRfc2VxX3BsdXNfbGVuKG50b2hsKHRoLT5zZXEpLCBza2ItPmxlbiwKKwkJCQkJICAgICBpcGgsIHRoKTsKKwkJY29ubnRyYWNrLT5wcm90by50Y3Auc2VlblswXS50ZF9tYXh3aW4gPSBudG9ocyh0aC0+d2luZG93KTsKKwkJaWYgKGNvbm50cmFjay0+cHJvdG8udGNwLnNlZW5bMF0udGRfbWF4d2luID09IDApCisJCQljb25udHJhY2stPnByb3RvLnRjcC5zZWVuWzBdLnRkX21heHdpbiA9IDE7CisJCWNvbm50cmFjay0+cHJvdG8udGNwLnN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reworCWNvbnN0IHN0cnVjdCBpcF9jb25udHJhY2tfdHVwbGVfaGFzaCAqaGFzaCA9IHY7CisJY29uc3Qgc3RydWN0IGlwX2Nvbm50cmFjayAqY29ubnRyYWNrID0gdHVwbGVoYXNoX3RvX2N0cmFjayhoYXNoKTsKKwlzdHJ1Y3QgaXBfY29ubnRyYWNrX3Byb3RvY29sICpwcm90bzsKKworCU1VU1RfQkVfUkVBRF9MT0NLRUQoJmlwX2Nvbm50cmFja19sb2NrKTsKKwlJUF9ORl9BU1NFUlQoY29ubnRyYWNrKTsKKworCS8qIHdlIG9ubHkgd2FudCB0byBwcmludCBESVJfT1JJR0lOQUwgKi8KKwlpZiAoRElSRUNUSU9OKGhhc2gpKQorCQlyZXR1cm4gMDsKKworCXByb3RvID0gaXBfY3RfZmluZF9wcm90byhjb25udHJhY2stPnR1cGxlaGFzaFtJUF9DVF9ESVJfT1JJR0lOQUxdCisJCQkgICAgICAgLnR1cGxlLmRzdC5wcm90b251bSk7CisJSVBfTkZfQVNTRVJUKHByb3RvKTsKKworCWlmIChzZXFfcHJpbnRmKHMsICIlLThzICV1ICVsZCAiLAorCQkgICAgICBwcm90by0+bmFtZSwKKwkJICAgICAgY29ubnRyYWNrLT50dXBsZWhhc2hbSVBfQ1RfRElSX09SSUdJTkFMXS50dXBsZS5kc3QucHJvdG9udW0sCisJCSAgICAgIHRpbWVyX3BlbmRpbmcoJmNvbm50cmFjay0+dGltZW91dCkKKwkJICAgICAgPyAobG9uZykoY29ubnRyYWNrLT50aW1lb3V0LmV4cGlyZXMgLSBqaWZmaWVzKS9IWgorCQkgICAgICA6IDApICE9IDApCisJCXJldHVybiAtRU5PU1BDOworCisJaWYgKHByb3RvLT5wcmludF9jb25udHJhY2socywgY29ubnRyYWNrKSkKKwkJcmV0dXJuIC1FTk9TUEM7CisgIAorCWlmIChwcmludF90dXBsZShzLCAmY29ubnRyYWNrLT50dXBsZWhhc2hbSVBfQ1RfRElSX09SSUdJTkFMXS50dXBsZSw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Q09ORklHX1BST0NfRlMgKi8KKwlpcF9jb25udHJhY2tfY2xlYW51cCgpOworIGNsZWFudXBfbm90aGluZzoKKwlyZXR1cm4gcmV0OworfQorCisvKiBGSVhNRTogQWxsb3cgTlVMTCBmdW5jdGlvbnMgYW5kIHN1YiBpbiBwb2ludGVycyB0byBnZW5lcmljIGZvcgorICAgdGhlbS4gLS1SUiAqLworaW50IGlwX2Nvbm50cmFja19wcm90b2NvbF9yZWdpc3RlcihzdHJ1Y3QgaXBfY29ubnRyYWNrX3Byb3RvY29sICpwcm90bykKK3sKKwlpbnQgcmV0ID0gMDsKKworCVdSSVRFX0xPQ0soJmlwX2Nvbm50cmFja19sb2NrKTsKKwlpZiAoaXBfY3RfcHJvdG9zW3Byb3RvLT5wcm90b10gIT0gJmlwX2Nvbm50cmFja19nZW5lcmljX3Byb3RvY29sKSB7CisJCXJldCA9IC1FQlVTWTsKKwkJZ290byBvdXQ7CisJfQorCWlwX2N0X3Byb3Rvc1twcm90by0+cHJvdG9dID0gcHJvdG87Cisgb3V0OgorCVdSSVRFX1VOTE9DSygmaXBfY29ubnRyYWNrX2xvY2spOworCXJldHVybiByZXQ7Cit9CisKK3ZvaWQgaXBfY29ubnRyYWNrX3Byb3RvY29sX3VucmVnaXN0ZXIoc3RydWN0IGlwX2Nvbm50cmFja19wcm90b2NvbCAqcHJvdG8pCit7CisJV1JJVEVfTE9DSygmaXBfY29ubnRyYWNrX2xvY2spOworCWlwX2N0X3Byb3Rvc1twcm90by0+cHJvdG9dID0gJmlwX2Nvbm50cmFja19nZW5lcmljX3Byb3RvY29sOworCVdSSVRFX1VOTE9DSygmaXBfY29ubnRyYWNrX2xvY2spOworCQorCS8qIFNvbWVib2R5IGNvdWxkIGJlIHN0aWxsIGxvb2tpbmcgYXQgdGhlIHByb3RvIGluIGJoLiAqLworCXN5bmNocm9uaXplX25ldCgpOworCisJLyogUmVtb3ZlIGFsbCBjb250cmFjayBlbnRyaWVzIGZvciB0aGlzIHByb3RvY29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weDdGOworCX0gd2hpbGUgKChjaCAmIDB4ODApID09IDB4ODApOworCXJldHVybiAxOworfQorCitzdGF0aWMgdW5zaWduZWQgY2hhciBhc24xX2lkX2RlY29kZShzdHJ1Y3QgYXNuMV9jdHggKmN0eCwgCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1bnNpZ25lZCBpbnQgKmNscywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVuc2lnbmVkIGludCAqY29uLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdW5zaWduZWQgaW50ICp0YWcpCit7CisJdW5zaWduZWQgY2hhciBjaDsKKwkKKwlpZiAoIWFzbjFfb2N0ZXRfZGVjb2RlKGN0eCwgJmNoKSkKKwkJcmV0dXJuIDA7CisJCQorCSpjbHMgPSAoY2ggJiAweEMwKSA+PiA2OworCSpjb24gPSAoY2ggJiAweDIwKSA+PiA1OworCSp0YWcgPSAoY2ggJiAweDFGKTsKKwkKKwlpZiAoKnRhZyA9PSAweDFGKSB7CisJCWlmICghYXNuMV90YWdfZGVjb2RlKGN0eCwgdGFnKSkKKwkJCXJldHVybiAwOworCX0KKwlyZXR1cm4gMTsKK30KKworc3RhdGljIHVuc2lnbmVkIGNoYXIgYXNuMV9sZW5ndGhfZGVjb2RlKHN0cnVjdCBhc24xX2N0eCAqY3R4LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVuc2lnbmVkIGludCAqZGVmLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVuc2lnbmVkIGludCAqbGVuKQoreworCXVuc2lnbmVkIGNoYXIgY2gsIGNudDsKKwkKKwlpZiAoIWFzbjFfb2N0ZXRfZGVjb2RlKGN0eCwgJmNoKSkKKwkJcmV0dXJuIDA7CisJCQorCWlmIChjaCA9PSAweDgwKQorCQkqZGVmID0gMDsKKwllbHNlIHsKKwkJKmRlZiA9IDE7CisJCQorCQlpZiAoY2ggPCAweDgwKQorCQkJKmxlbiA9IGNoOworCQllbHNlIHsKKwkJCWNudCA9ICh1bnNpZ25lZCBjaGFyKSAoY2ggJiAweDdGKTsKKwkJCSpsZW4gPSAwOworCQkJCisJCQl3aGlsZSAoY250ID4gMCkgeworCQkJCWlmICghYXNuMV9vY3RldF9kZWNvZGUoY3R4LCAmY2gpKQorCQkJCQlyZXR1cm4gMDsKKwkJCQkqbGVuIDw8PSA4OworCQkJCSpsZW4gfD0gY2g7CisJCQkJY250LS07CisJCQl9CisJCX0KKwl9CisJcmV0dXJuIDE7Cit9CisKK3N0YXRpYyB1bnNpZ25lZCBjaGFyIGFzbjFfaGVhZGVyX2RlY29kZShzdHJ1Y3QgYXNuMV9jdHggKmN0eCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1bnNpZ25lZCBjaGFyICoqZW9jLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVuc2lnbmVkIGludCAqY2xzLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVuc2lnbmVkIGludCAqY29uLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVuc2lnbmVkIGludCAqdGFnKQoreworCXVuc2lnbmVkIGludCBkZWYsIGxlbjsKKwkKKwlpZiAoIWFzbjFfaWRfZGVjb2RlKGN0eCwgY2xzLCBjb24sIHRhZykpCisJCXJldHVybiAwOworCQkKKwlpZiAoIWFzbjFfbGVuZ3RoX2RlY29kZShjdHgsICZkZWYsICZsZW4pKQorCQlyZXR1cm4gMDsKKwkJCisJaWYgKGRlZikKKwkJKmVvYyA9IGN0eC0+cG9pbnRlciArIGxlbjsKKwllbHNlCisJCSplb2MgPSBOVUxMOworCXJldHVybiAxOworfQorCitzdGF0aWMgdW5zaWduZWQgY2hhciBhc24xX2VvY19kZWNvZGUoc3RydWN0IGFzbjFfY3R4ICpjdHgsIHVuc2lnbmVkIGNoYXIgKmVvYykKK3sKKwl1bnNpZ25lZCBjaGFyIGNoOworCQorCWlmIChlb2MgPT0gMCkgeworCQlpZiAoIWFzbjFfb2N0ZXRfZGVjb2RlKGN0eCwgJmNoKSkKKwkJCXJldHVybiAwOworCQkJCisJCWlmIChjaCAhPSAweDAwKSB7CisJCQljdHgtPmVycm9yID0gQVNOMV9FUlJfREVDX0VPQ19NSVNNQVRDSDsKKwkJCXJldHVybiAwOworCQl9CisJCQorCQlpZiAoIWFzbjFfb2N0ZXRfZGVjb2RlKGN0eCwgJmNoKSkKKwkJCXJldHVybiAwOworCQkJCisJCWlmIChjaCAhPSAweDAwKSB7CisJCQljdHgtPmVycm9yID0gQVNOMV9FUlJfREVDX0VPQ19NSVNNQVRDSDsKKwkJCXJldHVybiAwOworCQl9CisJCXJldHVybiAxOworCX0gZWxzZSB7CisJCWlmIChjdHgtPnBvaW50ZXIgIT0gZW9jKSB7CisJCQljdHgtPmVycm9yID0gQVNOMV9FUlJfREVDX0xFTkdUSF9NSVNNQVRDSDsKKwkJCXJldHVybiAwOworCQl9CisJCXJldHVybiAxOworCX0KK30KKworc3RhdGljIHVuc2lnbmVkIGNoYXIgYXNuMV9udWxsX2RlY29kZShzdHJ1Y3QgYXNuMV9jdHggKmN0eCwgdW5zaWduZWQgY2hhciAqZW9jKQoreworCWN0eC0+cG9pbnRlciA9IGVvYzsKKwlyZXR1cm4gMTsKK30KKworc3RhdGljIHVuc2lnbmVkIGNoYXIgYXNuMV9sb25nX2RlY29kZShzdHJ1Y3QgYXNuMV9jdHggKmN0eCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdW5zaWduZWQgY2hhciAqZW9jLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb25nICppbnRlZ2VyKQoreworCXVuc2lnbmVkIGNoYXIgY2g7CisJdW5zaWduZWQgaW50ICBsZW47CisJCisJaWYgKCFhc24xX29jdGV0X2RlY29kZShjdHgsICZjaCkpCisJCXJldHVybiAwOworCQkKKwkqaW50ZWdlciA9IChzaWduZWQgY2hhcikgY2g7CisJbGVuID0gMTsKKwkKKwl3aGlsZSAoY3R4LT5wb2ludGVyIDwgZW9jKSB7CisJCWlmICgrK2xlbiA+IHNpemVvZiAobG9uZykpIHsKKwkJCWN0eC0+ZXJyb3IgPSBBU04xX0VSUl9ERUNfQkFEVkFMVUU7CisJCQlyZXR1cm4gMDsKKwkJfQorCQkKKwkJaWYgKCFhc24xX29jdGV0X2RlY29kZShjdHgsICZjaCkpCisJCQlyZXR1cm4gMDsKKwkJCQorCQkqaW50ZWdlciA8PD0gODsKKwkJKmludGVnZXIgfD0gY2g7CisJfQorCXJldHVybiAxOworfQorCitzdGF0aWMgdW5zaWduZWQgY2hhciBhc24xX3VpbnRfZGVjb2RlKHN0cnVjdCBhc24xX2N0eCAqY3R4LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1bnNpZ25lZCBjaGFyICplb2MsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVuc2lnbmVkIGludCAqaW50ZWdlcikKK3sKKwl1bnNpZ25lZCBjaGFyIGNoOworCXVuc2lnbmVkIGludCAgbGVuOworCQorCWlmICghYXNuMV9vY3RldF9kZWNvZGUoY3R4LCAmY2gpKQorCQlyZXR1cm4gMDsKKwkJCisJKmludGVnZXIgPSBjaDsKKwlpZiAoY2ggPT0gMCkgbGVuID0gMDsKKwllbHNlIGxlbiA9IDE7CisJCisJd2hpbGUgKGN0eC0+cG9pbnRlciA8IGVvYykgeworCQlpZiAoKytsZW4gPiBzaXplb2YgKHVuc2lnbmVkIGludCkpIHsKKwkJCWN0eC0+ZXJyb3IgPSBBU04xX0VSUl9ERUNfQkFEVkFMVUU7CisJCQlyZXR1cm4gMDsKKwkJfQorCQkKKwkJaWYgKCFhc24xX29jdGV0X2RlY29kZShjdHgsICZjaCkpCisJCQlyZXR1cm4gMDsKKwkJCQorCQkqaW50ZWdlciA8PD0gODsKKwkJKmludGVnZXIgfD0gY2g7CisJfQorCXJldHVybiAxOworfQorCitzdGF0aWMgdW5zaWduZWQgY2hhciBhc24xX3Vsb25nX2RlY29kZShzdHJ1Y3QgYXNuMV9jdHggKmN0eCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVuc2lnbmVkIGNoYXIgKmVvYywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVuc2lnbmVkIGxvbmcgKmludGVnZXIpCit7CisJdW5zaWduZWQgY2hhciBjaDsKKwl1bnNpZ25lZCBpbnQgIGxlbjsKKwkKKwlpZiAoIWFzbjFfb2N0ZXRfZGVjb2RlKGN0eCwgJmNoKSkKKwkJcmV0dXJuIDA7CisJCQorCSppbnRlZ2VyID0gY2g7CisJaWYgKGNoID09IDApIGxlbiA9IDA7CisJZWxzZSBsZW4gPSAxOworCQorCXdoaWxlIChjdHgtPnBvaW50ZXIgPCBlb2MpIHsKKwkJaWYgKCsrbGVuID4gc2l6ZW9mICh1bnNpZ25lZCBsb25nKSkgeworCQkJY3R4LT5lcnJvciA9IEFTTjFfRVJSX0RFQ19CQURWQUxVRTsKKwkJCXJldHVybiAwOworCQl9CisJCQorCQlpZiAoIWFzbjFfb2N0ZXRfZGVjb2RlKGN0eCwgJmNoKSkKKwkJCXJldHVybiAwOworCQkJCisJCSppbnRlZ2VyIDw8PSA4OworCQkqaW50ZWdlciB8PSBjaDsKKwl9CisJcmV0dXJuIDE7Cit9CisKK3N0YXRpYyB1bnNpZ25lZCBjaGFyIGFzbjFfb2N0ZXRzX2RlY29kZShzdHJ1Y3QgYXNuMV9jdHggKmN0eCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1bnNpZ25lZCBjaGFyICplb2MsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdW5zaWduZWQgY2hhciAqKm9jdGV0cywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1b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gICAgICAgICAgICAgICB1bnNpZ25lZCBjaGFyICplb2MsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdW5zaWduZWQgbG9uZyAqKm9pZCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1bnNpZ25lZCBpbnQgKmxlbikKK3sKKwl1bnNpZ25lZCBsb25nIHN1YmlkOworCXVuc2lnbmVkIGludCAgc2l6ZTsKKwl1bnNpZ25lZCBsb25nICpvcHRyOworCQorCXNpemUgPSBlb2MgLSBjdHgtPnBvaW50ZXIgKyAxOworCSpvaWQgPSBrbWFsbG9jKHNpemUgKiBzaXplb2YodW5zaWduZWQgbG9uZyksIEdGUF9BVE9NSUMpOworCWlmICgqb2lkID09IE5VTEwpIHsKKwkJaWYgKG5ldF9yYXRlbGltaXQoKSkKKwkJCXByaW50aygiT09NIGluIGJzYWxnICglZClcbiIsIF9fTElORV9fKTsKKwkJcmV0dXJuIDA7CisJfQorCQorCW9wdHIgPSAqb2lkOworCQorCWlmICghYXNuMV9zdWJpZF9kZWNvZGUoY3R4LCAmc3ViaWQpKSB7CisJCWtmcmVlKCpvaWQpOworCQkqb2lkID0gTlVMTDsKKwkJcmV0dXJuIDA7CisJfQorCQorCWlmIChzdWJpZCA8IDQwKSB7CisJCW9wdHIgWzBdID0gMDsKKwkJb3B0ciBbMV0gPSBzdWJpZDsKKwl9IGVsc2UgaWYgKHN1YmlkIDwgODApIHsKKwkJb3B0ciBbMF0gPSAxOworCQlvcHRyIFsxXSA9IHN1YmlkIC0gNDA7CisJfSBlbHNlIHsKKwkJb3B0ciBbMF0gPSAyOworCQlvcHRyIFsxXSA9IHN1YmlkIC0gODA7CisJfQorCQorCSpsZW4gPSAyOworCW9wdHIgKz0gMjsKKwkKKwl3aGlsZSAoY3R4LT5wb2ludGVyIDwgZW9jKSB7CisJCWlmICgrKygqbGVuKSA+IHNpemUpIHsKKwkJCWN0eC0+ZXJyb3IgPSBBU04xX0VSUl9ERUNfQkFEVkFMVUU7CisJCQlrZnJlZSgqb2lkKTsKKwkJCSpvaWQgPSBOVUxMOworCQkJcmV0dXJuIDA7CisJCX0KKwkJCisJCWlmICghYXNuMV9zdWJpZF9kZWNvZGUoY3R4LCBvcHRyKyspKSB7CisJCQlrZnJlZSgqb2lkKTsKKwkJCSpvaWQgPSBOVUxMOworCQkJcmV0dXJuIDA7CisJCX0KKwl9CisJcmV0dXJuIDE7Cit9CisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorICoKKyAqIFNOTVAgZGVjb2Rpbmcgcm91dGluZXMgKGd4c25tcCBhdXRob3IgRGlyayBXaXNzZSkKKyAqCisgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisKKy8qIFNOTVAgVmVyc2lvbnMgKi8KKyNkZWZpbmUgU05NUF9WMQkJCQkwCisjZGVmaW5lIFNOTVBfVjJDCQkJMQorI2RlZmluZSBTTk1QX1YyCQkJCTIKKyNkZWZpbmUgU05NUF9WMwkJCQkzCisKKy8qIERlZmF1bHQgU2l6ZXMgKi8KKyNkZWZpbmUgU05NUF9TSVpFX0NPTU0JCQkyNTYKKyNkZWZpbmUgU05NUF9TSVpFX09CSkVDVElECQkxMjgKKyNkZWZpbmUgU05NUF9TSVpFX0JVRkNIUgkJMjU2CisjZGVmaW5lIFNOTVBfU0laRV9CVUZJTlQJCTEyOAorI2RlZmluZSBTTk1QX1NJWkVfU01BTExPQkpFQ1RJRAkJMTYKKworLyogUmVxdWVzdHMgKi8KKyNkZWZpbmUgU05NUF9QRFVfR0VUCQkJMAorI2RlZmluZSBTTk1QX1BEVV9ORVhUCQkJMQorI2RlZmluZSBTTk1QX1BEVV9SRVNQT05TRQkJMgorI2RlZmluZSBTTk1QX1BEVV9TRVQJCQkzCisjZGVmaW5lIFNOTVBfUERVX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RlZmluZSBTTk1QX1RSQVBfTElOS1VQCQkzCisjZGVmaW5lIFNOTVBfVFJBUF9BVVRGQUlMVVJFCQk0CisjZGVmaW5lIFNOTVBfVFJBUF9FUVBORUlHSEJPUkxPU1MJNQorI2RlZmluZSBTTk1QX1RSQVBfRU5UU1BFQ0lGSUMJCTYKKworLyogU05NUHYxIFR5cGVzICovCisjZGVmaW5lIFNOTVBfTlVMTCAgICAgICAgICAgICAgICAwCisjZGVmaW5lIFNOTVBfSU5URUdFUiAgICAgICAgICAgICAxICAgIC8qIGwgICovCisjZGVmaW5lIFNOTVBfT0NURVRTVFIgICAgICAgICAgICAyICAgIC8qIGMgICovCisjZGVmaW5lIFNOTVBfRElTUExBWVNUUiAgICAgICAgICAyICAgIC8qIGMgICovCisjZGVmaW5lIFNOTVBfT0JKRUNUSUQgICAgICAgICAgICAzICAgIC8qIHVsICovCisjZGVmaW5lIFNOTVBfSVBBRERSICAgICAgICAgICAgICA0ICAgIC8qIHVjICovCisjZGVmaW5lIFNOTVBfQ09VTlRFUiAgICAgICAgICAgICA1ICAgIC8qIHVsICovCisjZGVmaW5lIFNOTVBfR0FVR0UgICAgICAgICAgICAgICA2ICAgIC8qIHVsICovCisjZGVmaW5lIFNOTVBfVElNRVRJQ0tTICAgICAgICAgICA3ICAgIC8qIHVsICovCisjZGVmaW5lIFNOTVBfT1BBUVVFICAgICAgICAgICAgICA4ICAgIC8qIGMgICovCisKKy8qIEFkZGl0aW9uYWwgU05NUHYyIFR5cGVzICovCisjZGVmaW5lIFNOTVBfVUlOVEVHRVIgICAgICAgICAgICA1ICAgIC8qIHVsICovCisjZGVmaW5lIFNOTVBfQklUU1RSICAgICAgICAgICAgICA5ICAgIC8qIHVjICovCisjZGVmaW5lIFNOTVBfTlNBUCAgICAgICAgICAgICAgIDEwICAgIC8qIHVjICovCisjZGVmaW5lIFNOTVBfQ09VTlRFUjY0ICAgICAgICAgIDExICAgIC8qIHVsICovCisjZGVmaW5lIFNOTVBfTk9TVU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tBU04xX0FQTCwgU05NUF9USVQsIFNOTVBfVElNRVRJQ0tTfSwKKwl7QVNOMV9BUEwsIFNOTVBfT1BRLCBTTk1QX09QQVFVRX0sCisJCisJLyogU05NUHYyIGRhdGEgdHlwZXMgYW5kIGVycm9ycyAqLworCXtBU04xX1VOSSwgQVNOMV9CVFMsIFNOTVBfQklUU1RSfSwKKwl7QVNOMV9BUEwsIFNOTVBfQzY0LCBTTk1QX0NPVU5URVI2NH0sCisJe0FTTjFfQ1RYLCBTRVJSX05TTywgU05NUF9OT1NVQ0hPQkpFQ1R9LAorCXtBU04xX0NUWCwgU0VSUl9OU0ksIFNOTVBfTk9TVUNISU5TVEFOQ0V9LAorCXtBU04xX0NUWCwgU0VSUl9FT00sIFNOTVBfRU5ET0ZNSUJWSUVXfSwKKwl7MCwgICAgICAgMCwgICAgICAgLTF9Cit9OworCitzdGF0aWMgdW5zaWduZWQgY2hhciBzbm1wX3RhZ19jbHMyc3ludGF4KHVuc2lnbmVkIGludCB0YWcsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVuc2lnbmVkIGludCBjbHMsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVuc2lnbmVkIHNob3J0ICpzeW50YXgpCit7CisJc3RydWN0IHNubXBfY252ICpjbnY7CisJCisJY252ID0gc25tcF9jb252OworCQorCXdoaWxlIChjbnYtPnN5bnRheCAhPSAtMSkgeworCQlpZiAoY252LT50YWcgPT0gdGFnICYmIGNudi0+Y2xhc3MgPT0gY2xzKSB7CisJCQkqc3ludGF4ID0gY252LT5zeW50YXg7CisJCQlyZXR1cm4gMTsKKwkJfQorCQljbnYrKzsKKwl9CisJcmV0dXJuIDA7Cit9CisKK3N0YXRpYyB1bnNpZ25lZCBjaGFyIHNubXBfb2JqZWN0X2RlY29kZShzdHJ1Y3QgYXNuMV9jdHggKmN0eCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdH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isJCXgtLTsKKwkJeCAmPSAweEZGRkY7CisJfQorCQorCWlmIChvZGQpIG5ldyA9IG5wdHJbMF0gKiAyNTY7CisJZWxzZSBuZXcgPSBucHRyWzBdOworCQorCXggKz0gbmV3ICYgMHhGRkZGOworCWlmICh4ICYgMHgxMDAwMCkgeworCQl4Kys7CisJCXggJj0gMHhGRkZGOworCX0KKwkKKwl4ID1+IHggJiAweEZGRkY7CisJY3N1bVswXSA9IHggLyAyNTY7CisJY3N1bVsxXSA9IHggJiAweEZGOworfQorCisvKiAKKyAqIE1hbmdsZSBJUCBhZGRyZXNzLgorICogCS0gYmVnaW4gcG9pbnRzIHRvIHRoZSBzdGFydCBvZiB0aGUgc25tcCBtZXNzZ2FlCisgKiAgICAgIC0gYWRkciBwb2ludHMgdG8gdGhlIHN0YXJ0IG9mIHRoZSBhZGRyZXNzCisgKi8KK3N0YXRpYyBpbmxpbmUgdm9pZCBtYW5nbGVfYWRkcmVzcyh1bnNpZ25lZCBjaGFyICpiZWdpbiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1bnNpZ25lZCBjaGFyICphZGRyLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0cnVjdCBvY3QxX21hcCAqbWFwLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVfaW50MTZfdCAqY2hlY2spCit7CisJaWYgKG1hcC0+ZnJvbSA9PSBOT0NUMSgqYWRkcikpIHsKKwkJdV9pbnQzMl90IG9sZDsKKwkJCisJCWlmIChkZWJ1ZykKKwkJCW1lbWNweSgmb2xkLCAodW5zaWduZWQgY2hhciAqKWFkZHIsIHNpemVvZihvbGQpKTsKKwkJCQorCQkqYWRkciA9IG1hcC0+dG87CisJCQorCQkvKiBVcGRhdGUgVURQIGNoZWNrc3VtIGlmIGJlaW5nIHVzZWQgKi8KKwkJaWYgKCpjaGVjaykgeworCQkJdW5zaWduZWQgY2hhciBvZGQgPSAhKChhZGRyIC0gYmVnaW4pICUgMik7CisJCQkKKwkJCWZhc3RfY3N1bSgodW5zaWduZWQgY2hhciAqKWNoZWNrLAorCQkJICAgICAgICAgICZtYXAtPmZyb20sICZtYXAtPnRvLCBvZGQpOworCQkJICAgICAgICAgIAorCQl9CisJCQorCQlpZiAoZGVidWcpCisJCQlwcmludGsoS0VSTl9ERUJVRyAiYnNhbGc6IG1hcHBlZCAldS4ldS4ldS4ldSB0byAiCisJCQkgICAgICAgIiV1LiV1LiV1LiV1XG4iLCBOSVBRVUFEKG9sZCksIE5JUFFVQUQoKmFkZHIpKTsKKwl9Cit9CisKK3N0YXRpYyB1bnNpZ25lZCBjaGFyIHNubXBfdHJhcF9kZWNvZGUoc3RydWN0IGFzbjFfY3R4ICpjdHgsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cnVjdCBzbm1wX3YxX3RyYXAgKnRyYXAsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0cnVjdCBvY3QxX21hcCAqbWFwLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1X2ludDE2X3QgKmNoZWNrKQoreworCXVuc2lnbmVkIGludCBjbHMsIGNvbiwgdGFnLCBsZW47CisJdW5zaWduZWQgY2hhciAqZW5kOworCisJaWYgKCFhc24xX2hlYWRlcl9kZWNvZGUoY3R4LCAmZW5kLCAmY2xzLCAmY29uLCAmdGFnKSkKKwkJcmV0dXJuIDA7CisJCQorCWlmIChjbHMgIT0gQVNOMV9VTkkgfHwgY29uICE9IEFTTjFfUFJJIHx8IHRhZyAhPSBBU04xX09KSSkKKwkJcmV0dXJuIDA7CisJCisJaWYgKCFhc24xX29pZF9kZWNvZGUoY3R4LCBlbmQsICZ0cmFwLT5pZCwgJnRyYXAtPmlkX2xlbikpCisJCXJldHVybiAwOworCQkKKwlpZiAoIWFzbjFfaGVhZGVyX2RlY29kZShjdHgsICZlbmQsICZjbHMsICZjb24sICZ0YWcpKQ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OworCQkKKwlpZiAoIWFzbjFfdWludF9kZWNvZGUoY3R4LCBlbmQsICZ0cmFwLT5zcGVjaWZpYykpCisJCWdvdG8gZXJyX2FkZHJfZnJlZTsKKwkJCisJaWYgKCFhc24xX2hlYWRlcl9kZWNvZGUoY3R4LCAmZW5kLCAmY2xzLCAmY29uLCAmdGFnKSkKKwkJZ290byBlcnJfYWRkcl9mcmVlOworCQkKKwlpZiAoISgoY2xzID09IEFTTjFfQVBMICYmIGNvbiA9PSBBU04xX1BSSSAmJiB0YWcgPT0gU05NUF9USVQpIHx8CisJICAgICAgKGNscyA9PSBBU04xX1VOSSAmJiBjb24gPT0gQVNOMV9QUkkgJiYgdGFnID09IEFTTjFfSU5UKSkpCisJCWdvdG8gZXJyX2FkZHJfZnJlZTsKKwkJCisJaWYgKCFhc24xX3Vsb25nX2RlY29kZShjdHgsIGVuZCwgJnRyYXAtPnRpbWUpKQorCQlnb3RvIGVycl9hZGRyX2ZyZWU7CisJCQorCXJldHVybiAxOworCitlcnJfaWRfZnJlZToKKwlrZnJlZSh0cmFwLT5pZCk7CisKK2Vycl9hZGRyX2ZyZWU6CisJa2ZyZWUoKHVuc2lnbmVkIGxvbmcgKil0cmFwLT5pcF9hZGRyZXNzKTsKKwkKKwlyZXR1cm4gMDsKK30KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgKgorICogTWlzYy4gcm91dGluZXMKKyAqCisgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisKK3N0YXRpYyB2b2lkIGhleF9kdW1wKHVuc2lnbmVkIGNoYXIgKmJ1Ziwgc2l6ZV90IGxlbikKK3sKKwlzaXplX3QgaTsKKwkKKwlmb3IgKGkgPSAwOyBpIDwgbGVuOyBpKyspIHsKKwkJaWYgKGkgJiYgIShpICUgMTYpKQorCQkJcHJpbnRrKCJcbiIpOworCQlwcmludGsoIiUwMnggIiwgKihidWYgKyBpKSk7CisJfQorCXByaW50aygiXG4iKTsKK30KKworLyoKKyAqIFBhcnNlIGFuZCBtYW5nbGUgU05NUCBtZXNzYWdlIGFjY29yZGluZyB0byBtYXBwaW5nLgorICogKEFuZCB0aGlzIGlzIHRoZSBmdWNraW5nICdiYXNpYycgbWV0aG9kKS4KKyAqLworc3RhdGljIGludCBzbm1wX3BhcnNlX21hbmdsZSh1bnNpZ25lZCBjaGFyICptc2csCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVfaW50MTZfdCBsZW4sCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0cnVjdCBvY3QxX21hcCAqbWFwLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1X2ludDE2X3QgKmNoZWNrKQoreworCXVuc2lnbmVkIGNoYXIgKmVvYywgKmVuZDsKKwl1bnNpZ25lZCBpbnQgY2xzLCBjb24sIHRhZywgdmVycywgcGR1dHlwZTsKKwlzdHJ1Y3QgYXNuMV9jdHggY3R4OworCXN0cnVjdCBhc24xX29jdHN0ciBjb21tOworCXN0cnVjdCBzbm1wX29iamVjdCAqKm9iajsKKwkKKwlpZiAoZGVidWcgPiAxKQorCQloZXhfZHVtcChtc2csIGxlbik7CisKKwlhc24xX29wZW4oJmN0eCwgbXNnLCBsZW4pOworCQorCS8qIAorCSAqIFN0YXJ0IG9mIFNOTVAgbWVzc2FnZS4KKwkgKi8KKwlpZiAoIWFzbjFfaGVhZGVyX2RlY29kZSgmY3R4LCAmZW9jLCAmY2xzLCAmY29uLCAmdGFnKSkKKwkJcmV0dXJuIDA7CisJaWYgKGNscyAhPSBBU04xX1VOSSB8fCBjb24gIT0gQVNOMV9DT04gfHwgdGFnICE9IEFTTjFfU0VRKQorCQlyZXR1cm4gMDsKKwkKKwkvKiAKKwkgKiBWZXJzaW9uIDEgb3IgMiBoYW5kbGVkLgorCSAqLworCWlmICghY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4gMDsJCisJfQorCisJd2hpbGUgKCFhc24xX2VvY19kZWNvZGUoJmN0eCwgZW9jKSkgeworCQl1bnNpZ25lZCBpbnQgaTsKKwkJCisJCWlmICghc25tcF9vYmplY3RfZGVjb2RlKCZjdHgsIG9iaikpIHsKKwkJCWlmICgqb2JqKSB7CisJCQkJaWYgKCgqb2JqKS0+aWQpCisJCQkJCWtmcmVlKCgqb2JqKS0+aWQpOworCQkJCWtmcmVlKCpvYmopOworCQkJfQkKKwkJCWtmcmVlKG9iaik7CisJCQlyZXR1cm4gMDsKKwkJfQorCisJCWlmIChkZWJ1ZyA+IDEpIHsKKwkJCXByaW50ayhLRVJOX0RFQlVHICJic2FsZzogb2JqZWN0OiAiKTsKKwkJCWZvciAoaSA9IDA7IGkgPCAoKm9iaiktPmlkX2xlbjsgaSsrKSB7CisJCQkJaWYgKGkgPiAwKQorCQkJCQlwcmludGsoIi4iKTsKKwkJCQlwcmludGsoIiVsdSIsICgqb2JqKS0+aWRbaV0pOworCQkJfQorCQkJcHJpbnRrKCI6IHR5cGU9JXVcbiIsICgqb2JqKS0+dHlwZSk7CisJCQkKKwkJfQorCisJCWlmICgoKm9iaiktPnR5cGUgPT0gU05NUF9JUEFERFIpCisJCQltYW5nbGVfYWRkcmVzcyhjdHguYmVnaW4sIGN0eC5wb2ludGVyIC0gNCAsIG1hcCwgY2hlY2spOworCQkKKwkJa2ZyZWUoKCpvYmopLT5pZCk7CisJCWtmcmVlKCpvYmopOworCX0KKwlrZnJlZShvYmopOworCQorCWlmICghYXNuMV9lb2NfZGVjb2RlKCZjdHgsIGVvYykpCisJCXJldHVybiAwOworCQkKKwlyZXR1cm4gMTsKK30KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgKgorICogTkFUIHJvdXRpbmVzLgorICoKKyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqK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ID0geyAuc3JjID0geyAudSA9IHsgMHhGRkZGIH0gfSwKKwkJIC5kc3QgPSB7IC5wcm90b251bSA9IDB4RkYgfSwKKwl9LAorfTsKKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgKgorICogTW9kdWxlIHN0dWZmLgorICoKKyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKyAKK3N0YXRpYyBpbnQgX19pbml0IGluaXQodm9pZCkKK3sKKwlpbnQgcmV0ID0gMDsKKworCXJldCA9IGlwX2Nvbm50cmFja19oZWxwZXJfcmVnaXN0ZXIoJnNubXBfaGVscGVyKTsKKwlpZiAocmV0IDwgMCkKKwkJcmV0dXJuIHJldDsKKwlyZXQgPSBpcF9jb25udHJhY2tfaGVscGVyX3JlZ2lzdGVyKCZzbm1wX3RyYXBfaGVscGVyKTsKKwlpZiAocmV0IDwgMCkgeworCQlpcF9jb25udHJhY2tfaGVscGVyX3VucmVnaXN0ZXIoJnNubXBfaGVscGVyKTsKKwkJcmV0dXJuIHJldDsKKwl9CisJcmV0dXJuIHJldDsKK30KKworc3RhdGljIHZvaWQgX19leGl0IGZpbmkodm9pZCkKK3sKKwlpcF9jb25udHJhY2tfaGVscGVyX3VucmVnaXN0ZXIoJnNubXBfaGVscGVyKTsKKwlpcF9jb25udHJhY2tfaGVscGVyX3VucmVnaXN0ZXIoJnNubXBfdHJhcF9oZWxwZXIpOworfQorCittb2R1bGVfaW5pdChpbml0KTsKK21vZHVsZV9leGl0KGZpbmkpOworCittb2R1bGVfcGFyYW0oZGVidWcsIGJvb2wsIDA2MDApOwpkaWZmIC0tZ2l0IGEvbmV0L2lwdjQvbmV0ZmlsdGVyL2lwX25hdF9zdGFuZGFsb25lLmMgYi9uZXQvaXB2NC9uZXRmaWx0ZXIvaXBfbmF0X3N0YW5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i8KKwkJCWlmIChob29rbnVtID09IE5GX0lQX0xPQ0FMX0lOKQorCQkJCXJldCA9IGFsbG9jX251bGxfYmluZGluZyhjdCwgaW5mbywgaG9va251bSk7CisJCQllbHNlCisJCQkJcmV0ID0gaXBfbmF0X3J1bGVfZmluZChwc2tiLCBob29rbnVtLAorCQkJCQkJICAgICAgIGluLCBvdXQsIGN0LAorCQkJCQkJICAgICAgIGluZm8pOworCisJCQlpZiAocmV0ICE9IE5GX0FDQ0VQVCkgeworCQkJCXJldHVybiByZXQ7CisJCQl9CisJCX0gZWxzZQorCQkJREVCVUdQKCJBbHJlYWR5IHNldHVwIG1hbmlwICVzIGZvciBjdCAlcFxuIiwKKwkJCSAgICAgICBtYW5pcHR5cGUgPT0gSVBfTkFUX01BTklQX1NSQyA/ICJTUkMiIDogIkRTVCIsCisJCQkgICAgICAgY3QpOworCQlicmVhazsKKworCWRlZmF1bHQ6CisJCS8qIEVTVEFCTElTSEVEICovCisJCUlQX05GX0FTU0VSVChjdGluZm8gPT0gSVBfQ1RfRVNUQUJMSVNIRUQKKwkJCSAgICAgfHwgY3RpbmZvID09IChJUF9DVF9FU1RBQkxJU0hFRCtJUF9DVF9JU19SRVBMWSkpOworCQlpbmZvID0gJmN0LT5uYXQuaW5mbzsKKwl9CisKKwlJUF9ORl9BU1NFUlQoaW5mbyk7CisJcmV0dXJuIG5hdF9wYWNrZXQoY3QsIGN0aW5mbywgaG9va251bSwgcHNrYik7Cit9CisKK3N0YXRpYyB1bnNpZ25lZCBpbnQKK2lwX25hdF9pbih1bnNpZ25lZCBpbnQgaG9va251bSwKKyAgICAgICAgICBzdHJ1Y3Qgc2tfYnVmZiAqKnBza2IsCisgICAgICAgICAgY29uc3Qgc3RydWN0IG5ldF9kZXZpY2UgKmluLAorICAgICAgICAgIGNvbnN0IHN0cnVjdCBuZXRfZGV2aWNlICpvdXQsCisgICAgICAgICAgaW50ICgqb2tmbikoc3RydWN0IHNrX2J1ZmYgKikpCit7CisJdV9pbn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PnUudGFyZ2V0X3NpemUgLSBzaXplb2YoKnQpKTsKKwltb2R1bGVfcHV0KHQtPnUua2VybmVsLnRhcmdldC0+bWUpOworCXJldHVybiAwOworfQorCisvKiBDaGVja3MgYW5kIHRyYW5zbGF0ZXMgdGhlIHVzZXItc3VwcGxpZWQgdGFibGUgc2VnbWVudCAoaGVsZCBpbgorICAgbmV3aW5mbykgKi8KK3N0YXRpYyBpbnQKK3RyYW5zbGF0ZV90YWJsZShjb25zdCBjaGFyICpuYW1lLAorCQl1bnNpZ25lZCBpbnQgdmFsaWRfaG9va3MsCisJCXN0cnVjdCBpcHRfdGFibGVfaW5mbyAqbmV3aW5mbywKKwkJdW5zaWduZWQgaW50IHNpemUsCisJCXVuc2lnbmVkIGludCBudW1iZXIsCisJCWNvbnN0IHVuc2lnbmVkIGludCAqaG9va19lbnRyaWVzLAorCQljb25zdCB1bnNpZ25lZCBpbnQgKnVuZGVyZmxvd3MpCit7CisJdW5zaWduZWQgaW50IGk7CisJaW50IHJldDsKKworCW5ld2luZm8tPnNpemUgPSBzaXplOworCW5ld2luZm8tPm51bWJlciA9IG51bWJlcjsKKworCS8qIEluaXQgYWxsIGhvb2tzIHRvIGltcG9zc2libGUgdmFsdWUuICovCisJZm9yIChpID0gMDsgaSA8IE5GX0lQX05VTUhPT0tTOyBpKyspIHsKKwkJbmV3aW5mby0+aG9va19lbnRyeVtpXSA9IDB4RkZGRkZGRkY7CisJCW5ld2luZm8tPnVuZGVyZmxvd1tpXSA9IDB4RkZGRkZGRkY7CisJfQorCisJZHVwcmludGYoInRyYW5zbGF0ZV90YWJsZTogc2l6ZSAldVxuIiwgbmV3aW5mby0+c2l6ZSk7CisJaSA9IDA7CisJLyogV2FsayB0aHJvdWdoIGVudHJpZXMsIGNoZWNraW5nIG9mZnNldHMuICovCisJcmV0ID0gSVBUX0VOVFJZX0lURVJBVEUobmV3aW5mby0+ZW50cmllcywgbmV3aW5mby0+c2l6ZSwKKwkJCQljaGVja19lbnRyeV9z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XJldCA9IElQVF9FTlRSWV9JVEVSQVRFKG5ld2luZm8tPmVudHJpZXMsIG5ld2luZm8tPnNpemUsCisJCQkJY2hlY2tfZW50cnksIG5hbWUsIHNpemUsICZpKTsKKworCWlmIChyZXQgIT0gMCkgeworCQlJUFRfRU5UUllfSVRFUkFURShuZXdpbmZvLT5lbnRyaWVzLCBuZXdpbmZvLT5zaXplLAorCQkJCSAgY2xlYW51cF9lbnRyeSwgJmkpOworCQlyZXR1cm4gcmV0OworCX0KKworCS8qIEFuZCBvbmUgY29weSBmb3IgZXZlcnkgb3RoZXIgQ1BVICovCisJZm9yIChpID0gMTsgaSA8IG51bV9wb3NzaWJsZV9jcHVzKCk7IGkrKykgeworCQltZW1jcHkobmV3aW5mby0+ZW50cmllcyArIFNNUF9BTElHTihuZXdpbmZvLT5zaXplKSppLAorCQkgICAgICAgbmV3aW5mby0+ZW50cmllcywKKwkJICAgICAgIFNNUF9BTElHTihuZXdpbmZvLT5zaXplKSk7CisJfQorCisJcmV0dXJuIHJldDsKK30KKworc3RhdGljIHN0cnVjdCBpcHRfdGFibGVfaW5mbyAqCityZXBsYWNlX3RhYmxlKHN0cnVjdCBpcHRfdGFibGUgKnRhYmxlLAorCSAgICAgIHVuc2lnbmVkIGludCBudW1fY291bnRlcnMsCisJICAgICAgc3RydWN0IGlwdF90YWJsZV9pbmZvICpuZXdpbmZvLAorCSAgICAgIGludCAqZXJyb3IpCit7CisJc3RydWN0IGlwdF90YWJsZV9pbmZvICpvbGRpbmZvOworCisjaWZkZWYgQ09ORklHX05FVEZJTFRFUl9ERUJVRworCXsKKwkJc3RydWN0IGlwdF9lbnRyeSAqdGFibGVfYmFzZTsKKwkJdW5zaWduZWQgaW50IGk7CisKKwkJZm9yIChpID0gMDsgaSA8IG51bV9wb3NzaWJsZV9jcHVzKCk7IGkrKykgeworCQkJdGFibGVfYmFzZSA9CisJCQkJKHZvaWQgKiluZXdpbmZvLT5lbnRyaWVzCisJCQkJKyBUQUJMRV9PRkZ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FsX25vZGVzKSsxKTsKK30KKworc3RhdGljIGlubGluZSBpbnQKK2NsdXN0ZXJpcF9yZXNwb25zaWJsZShzdHJ1Y3QgY2x1c3RlcmlwX2NvbmZpZyAqY29uZmlnLCB1X2ludDMyX3QgaGFzaCkKK3sKKwlpbnQgaTsKKworCVJFQURfTE9DSygmY2x1c3RlcmlwX2xvY2spOworCisJaWYgKGNvbmZpZy0+bnVtX2xvY2FsX25vZGVzID09IDApIHsKKwkJUkVBRF9VTkxPQ0soJmNsdXN0ZXJpcF9sb2NrKTsKKwkJcmV0dXJuIDA7CisJfQorCisJZm9yIChpID0gMDsgaSA8IGNvbmZpZy0+bnVtX2xvY2FsX25vZGVzOyBpKyspIHsKKwkJaWYgKGNvbmZpZy0+bG9jYWxfbm9kZXNbaV0gPT0gaGFzaCkgeworCQkJUkVBRF9VTkxPQ0soJmNsdXN0ZXJpcF9sb2NrKTsKKwkJCXJldHVybiAxOworCQl9CisJfQorCisJUkVBRF9VTkxPQ0soJmNsdXN0ZXJpcF9sb2NrKTsKKworCXJldHVybiAwOworfQorCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiogCisgKiBJUFRBQkxFUyBUQVJHRVQgCisgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisKK3N0YXRpYyB1bnNpZ25lZCBpbnQKK3RhcmdldChzdHJ1Y3Qgc2tfYnVmZiAqKnBza2IsCisgICAgICAgY29uc3Qgc3RydWN0IG5ldF9kZXZpY2UgKmluLAorICAgICAgIGNvbnN0IHN0cnVjdCBuZXRfZGV2aWNlICpvdXQsCisgICAgICAgdW5zaWduZWQgaW50IGhvb2tudW0sCisgICAgICAgY29uc3Qgdm9pZCAqdGFyZ2luZm8sCisgICAgICAgdm9pZCAqdXNlcmluZm8pCit7CisJY29uc3Qgc3RydWN0IGlwdF9jbHV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SBwcm9jIGVudHJ5IGFuZCB0aGVuIGRyb3AgdGhlIHJlZmVyZW5jZQorCSAqIGNvdW50LiAgSW4gY2FzZSBhbnlvbmUgc3RpbGwgYWNjZXNzZXMgdGhlIGZpbGUsIHRoZSBvcGVuL2Nsb3NlCisJICogZnVuY3Rpb25zIGFyZSBhbHNvIGluY3JlbWVudGluZyB0aGUgcmVmY291bnQgb24gdGhlaXIgb3duICovCisjaWZkZWYgQ09ORklHX1BST0NfRlMKKwlyZW1vdmVfcHJvY19lbnRyeShjaXBpbmZvLT5jb25maWctPnBkZS0+bmFtZSwKKwkJCSAgY2lwaW5mby0+Y29uZmlnLT5wZGUtPnBhcmVudCk7CisjZW5kaWYKKwljbHVzdGVyaXBfY29uZmlnX3B1dChjaXBpbmZvLT5jb25maWcpOworfQorCitzdGF0aWMgc3RydWN0IGlwdF90YXJnZXQgY2x1c3RlcmlwX3RndCA9IHsgCisJLm5hbWUgPSAiQ0xVU1RFUklQIiwKKwkudGFyZ2V0ID0gJnRhcmdldCwgCisJLmNoZWNrZW50cnkgPSAmY2hlY2tlbnRyeSwgCisJLmRlc3Ryb3kgPSAmZGVzdHJveSwKKwkubWUgPSBUSElTX01PRFVMRQorfTsKKworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiogCisgKiBBUlAgTUFOR0xJTkcgQ09ERSAKKyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKworLyogaGFyZGNvZGVkIGZvciA0OGJpdCBldGhlcm5ldCBhbmQgMzJiaXQgaXB2NCBhZGRyZXNzZXMgKi8KK3N0cnVjdCBhcnBfcGF5bG9hZCB7CisJdV9pbnQ4X3Qgc3JjX2h3W0VUSF9BTEVOXTsKKwl1X2ludDMyX3Qgc3JjX2lwOworCXVfaW50OF90IGRzdF9od1tFVEhfQUxFTl07CisJdV9p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ChjLT5kZXYgIT0gb3V0KSB7CisJCURFQlVHUCgiQ0xVU1RFUklQOiBub3QgbWFuZ2xpbmcgYXJwIHJlcGx5IG9uIGRpZmZlcmVudCAiCisJCSAgICAgICAiaW50ZXJmYWNlOiBjaXAnJXMnLXNrYiclcydcbiIsIGMtPmRldi0+bmFtZSwgb3V0LT5uYW1lKTsKKwkJY2x1c3RlcmlwX2NvbmZpZ19wdXQoYyk7CisJCXJldHVybiBORl9BQ0NFUFQ7CisJfQorCisJLyogbWFuZ2xlIHJlcGx5IGhhcmR3YXJlIGFkZHJlc3MgKi8KKwltZW1jcHkocGF5bG9hZC0+c3JjX2h3LCBjLT5jbHVzdGVybWFjLCBhcnAtPmFyX2hsbik7CisKKyNpZmRlZiBDTFVTVEVSSVBfREVCVUcKKwlERUJVR1AoS0VSTl9ERUJVRyAiQ0xVU1RFUklQIG1hbmdsZWQgYXJwIHJlcGx5OiAiKTsKKwlhcnBfcHJpbnQocGF5bG9hZCk7CisjZW5kaWYKKworCWNsdXN0ZXJpcF9jb25maWdfcHV0KGMpOworCisJcmV0dXJuIE5GX0FDQ0VQVDsKK30KKworc3RhdGljIHN0cnVjdCBuZl9ob29rX29wcyBjaXBfYXJwX29wcyA9IHsKKwkuaG9vayA9IGFycF9tYW5nbGUsCisJLnBmID0gTkZfQVJQLAorCS5ob29rbnVtID0gTkZfQVJQX09VVCwKKwkucHJpb3JpdHkgPSAtMQorfTsKKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqIAorICogUFJPQyBESVIgSEFORExJTkcgCisgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisKKyNpZmRlZiBDT05GSUdfUFJPQ19GUworCitzdGF0aWMgdm9pZCAqY2x1c3RlcmlwX3NlcV9zdGFydChzdHJ1Y3Qgc2VxX2ZpbGUgKnMsIGxvZm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orCSAgdW5zaWduZWQgaW50IGhvb2tudW0sCisJICBjb25zdCB2b2lkICp0YXJnaW5mbywKKwkgIHZvaWQgKnVzZXJpbmZvKQoreworCWNvbnN0IHN0cnVjdCBpcHRfbWFya190YXJnZXRfaW5mb192MSAqbWFya2luZm8gPSB0YXJnaW5mbzsKKwlpbnQgbWFyayA9IDA7CisKKwlzd2l0Y2ggKG1hcmtpbmZvLT5tb2RlKSB7CisJY2FzZSBJUFRfTUFSS19TRVQ6CisJCW1hcmsgPSBtYXJraW5mby0+bWFyazsKKwkJYnJlYWs7CisJCQorCWNhc2UgSVBUX01BUktfQU5EOgorCQltYXJrID0gKCpwc2tiKS0+bmZtYXJrICYgbWFya2luZm8tPm1hcms7CisJCWJyZWFrOworCQkKKwljYXNlIElQVF9NQVJLX09SOgorCQltYXJrID0gKCpwc2tiKS0+bmZtYXJrIHwgbWFya2luZm8tPm1hcms7CisJCWJyZWFrOworCX0KKworCWlmKCgqcHNrYiktPm5mbWFyayAhPSBtYXJrKSB7CisJCSgqcHNrYiktPm5mbWFyayA9IG1hcms7CisJCSgqcHNrYiktPm5mY2FjaGUgfD0gTkZDX0FMVEVSRUQ7CisJfQorCXJldHVybiBJUFRfQ09OVElOVUU7Cit9CisKKworc3RhdGljIGludAorY2hlY2tlbnRyeV92MChjb25zdCBjaGFyICp0YWJsZW5hbWUsCisJICAgICAgY29uc3Qgc3RydWN0IGlwdF9lbnRyeSAqZSwKKwkgICAgICB2b2lkICp0YXJnaW5mbywKKwkgICAgICB1bnNpZ25lZCBpbnQgdGFyZ2luZm9zaXplLAorCSAgICAgIHVuc2lnbmVkIGludCBob29rX21hc2spCit7CisJaWYgKHRhcmdpbmZvc2l6ZSAhPSBJUFRfQUxJR04oc2l6ZW9mKHN0cnVjdCBpcHRfbWFya190YXJnZXRfaW5mbykpKSB7CisJCXByaW50ayhLRVJOX1dBUk5JTkcgIk1BUks6IHRhcmdpbmZvc2l6ZSAldSAhPSAlWnVcbiIsCisJCSAgICAg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sCisgICAgICAgICAgIHVuc2lnbmVkIGludCBob29rX21hc2spCit7CisgICAgICAgIGlmIChob29rX21hc2sKKyAgICAgICAgICAgICYgfigoMSA8PCBORl9JUF9MT0NBTF9PVVQpIHwgKDEgPDwgTkZfSVBfUE9TVF9ST1VUSU5HKSkpIHsKKyAgICAgICAgICAgICAgICBwcmludGsoImlwdF9vd25lcjogb25seSB2YWxpZCBmb3IgTE9DQUxfT1VUIG9yIFBPU1RfUk9VVElORy5cbiIpOworICAgICAgICAgICAgICAgIHJldHVybiAwOworICAgICAgICB9CisKKwlpZiAobWF0Y2hzaXplICE9IElQVF9BTElHTihzaXplb2Yoc3RydWN0IGlwdF9vd25lcl9pbmZvKSkpIHsKKwkJcHJpbnRrKCJNYXRjaHNpemUgJXUgIT0gJVp1XG4iLCBtYXRjaHNpemUsCisJCSAgICAgICBJUFRfQUxJR04oc2l6ZW9mKHN0cnVjdCBpcHRfb3duZXJfaW5mbykpKTsKKwkJcmV0dXJuIDA7CisJfQorI2lmZGVmIENPTkZJR19TTVAKKwkvKiBmaWxlcy0+ZmlsZV9sb2NrIGNhbiBub3QgYmUgdXNlZCBpbiBhIEJIICovCisJaWYgKCgoc3RydWN0IGlwdF9vd25lcl9pbmZvICopbWF0Y2hpbmZvKS0+bWF0Y2gKKwkgICAgJiAoSVBUX09XTkVSX1BJRHxJUFRfT1dORVJfU0lEfElQVF9PV05FUl9DT01NKSkgeworCQlwcmludGsoImlwdF9vd25lcjogcGlkLCBzaWQgYW5kIGNvbW1hbmQgbWF0Y2hpbmcgaXMgYnJva2VuICIKKwkJICAgICAgICJvbiBTTVAuXG4iKTsKKwkJcmV0dXJuIDA7CisJfQorI2VuZGlmCisJcmV0dXJuIDE7Cit9CisKK3N0YXRpYyBzdHJ1Y3QgaXB0X21hdGNoIG93bmVyX21hdGNoID0geworCS5uYW1lCQk9ICJvd25lciIsCisJLm1hdGNoCQk9ICZtYXRjaCwKKwkuY2hlY2tlbnRyeQk9ICZjaGVja2VudH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GNoKGNvbnN0IHN0cnVjdCBza19idWZmICpza2IsCisgICAgICBjb25zdCBzdHJ1Y3QgbmV0X2RldmljZSAqaW4sCisgICAgICBjb25zdCBzdHJ1Y3QgbmV0X2RldmljZSAqb3V0LAorICAgICAgY29uc3Qgdm9pZCAqbWF0Y2hpbmZvLAorICAgICAgaW50IG9mZnNldCwKKyAgICAgIGludCAqaG90ZHJvcCkKK3sKKwljb25zdCBzdHJ1Y3QgaXB0X3JlYWxtX2luZm8gKmluZm8gPSBtYXRjaGluZm87CisJc3RydWN0IGRzdF9lbnRyeSAqZHN0ID0gc2tiLT5kc3Q7CisgICAgCisJcmV0dXJuIChpbmZvLT5pZCA9PSAoZHN0LT50Y2xhc3NpZCAmIGluZm8tPm1hc2spKSBeIGluZm8tPmludmVydDsKK30KKworc3RhdGljIGludCBjaGVjayhjb25zdCBjaGFyICp0YWJsZW5hbWUsCisgICAgICAgICAgICAgICAgIGNvbnN0IHN0cnVjdCBpcHRfaXAgKmlwLAorICAgICAgICAgICAgICAgICB2b2lkICptYXRjaGluZm8sCisgICAgICAgICAgICAgICAgIHVuc2lnbmVkIGludCBtYXRjaHNpemUsCisgICAgICAgICAgICAgICAgIHVuc2lnbmVkIGludCBob29rX21hc2spCit7CisJaWYgKGhvb2tfbWFzaworCSAgICAmIH4oKDEgPDwgTkZfSVBfUE9TVF9ST1VUSU5HKSB8ICgxIDw8IE5GX0lQX0ZPUldBUkQpIHwKKwkgICAgICAgICgxIDw8IE5GX0lQX0xPQ0FMX09VVCkgfCAoMSA8PCBORl9JUF9MT0NBTF9JTikpKSB7CisJCXByaW50aygiaXB0X3JlYWxtOiBvbmx5IHZhbGlkIGZvciBQT1NUX1JPVVRJTkcsIExPQ0FMX09VVCwgIgorCQkgICAgICAgIkxPQ0FMX0lOIG9yIEZPUldBUkQuXG4iKTsKKwkJcmV0dXJuIDA7CisJfQorCWlmIChtYXRjaHNpemUgIT0gSVBUX0FMSUdOKHNpemVvZihzdHJ1Y3QgaXB0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YWcpICghKChmbGFnKSAmIChvcHRpb24pKSBcCisJCQkJCSAgICAgIHx8ICghISgoaW52ZmxhZykgJiAob3B0aW9uKSkgXiAoY29uZCkpKQorCitzdGF0aWMgaW50CittYXRjaF9mbGFncyhjb25zdCBzdHJ1Y3QgaXB0X3NjdHBfZmxhZ19pbmZvICpmbGFnX2luZm8sCisJICAgIGNvbnN0IGludCBmbGFnX2NvdW50LAorCSAgICB1X2ludDhfdCBjaHVua3R5cGUsCisJICAgIHVfaW50OF90IGNodW5rZmxhZ3MpCit7CisJaW50IGk7CisKKwlmb3IgKGkgPSAwOyBpIDwgZmxhZ19jb3VudDsgaSsrKSB7CisJCWlmIChmbGFnX2luZm9baV0uY2h1bmt0eXBlID09IGNodW5rdHlwZSkgeworCQkJcmV0dXJuIChjaHVua2ZsYWdzICYgZmxhZ19pbmZvW2ldLmZsYWdfbWFzaykgPT0gZmxhZ19pbmZvW2ldLmZsYWc7CisJCX0KKwl9CisKKwlyZXR1cm4gMTsKK30KKworc3RhdGljIGludAorbWF0Y2hfcGFja2V0KGNvbnN0IHN0cnVjdCBza19idWZmICpza2IsCisJICAgICBjb25zdCB1X2ludDMyX3QgKmNodW5rbWFwLAorCSAgICAgaW50IGNodW5rX21hdGNoX3R5cGUsCisJICAgICBjb25zdCBzdHJ1Y3QgaXB0X3NjdHBfZmxhZ19pbmZvICpmbGFnX2luZm8sCisJICAgICBjb25zdCBpbnQgZmxhZ19jb3VudCwKKwkgICAgIGludCAqaG90ZHJvcCkKK3sKKwlpbnQgb2Zmc2V0OworCXVfaW50MzJfdCBjaHVua21hcGNvcHlbMjU2IC8gc2l6ZW9mICh1X2ludDMyX3QpXTsKKwlzY3RwX2NodW5raGRyX3QgX3NjaCwgKnNjaDsKKworI2lmZGVmIERFQlVHX1NDVFAKKwlpbnQgaSA9IDA7CisjZW5kaWYKKworCWlmIChjaHVua19tYXRjaF90eXBlID09IFNDVFBfQ0hVTktfTUFUQ0hfQUxMKSB7CisJCVNDVFBfQ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QkNfTk9QOgorCQkJYnJlYWs7CisJCWNhc2UgVENQRElBR19CQ19KTVA6CisJCQl5ZXMgPSAwOworCQkJYnJlYWs7CisJCWNhc2UgVENQRElBR19CQ19TX0dFOgorCQkJeWVzID0gZW50cnktPnNwb3J0ID49IG9wWzFdLm5vOworCQkJYnJlYWs7CisJCWNhc2UgVENQRElBR19CQ19TX0xFOgorCQkJeWVzID0gZW50cnktPmRwb3J0IDw9IG9wWzFdLm5vOworCQkJYnJlYWs7CisJCWNhc2UgVENQRElBR19CQ19EX0dFOgorCQkJeWVzID0gZW50cnktPmRwb3J0ID49IG9wWzFdLm5vOworCQkJYnJlYWs7CisJCWNhc2UgVENQRElBR19CQ19EX0xFOgorCQkJeWVzID0gZW50cnktPmRwb3J0IDw9IG9wWzFdLm5vOworCQkJYnJlYWs7CisJCWNhc2UgVENQRElBR19CQ19BVVRPOgorCQkJeWVzID0gIShlbnRyeS0+dXNlcmxvY2tzICYgU09DS19CSU5EUE9SVF9MT0NLKTsKKwkJCWJyZWFrOworCQljYXNlIFRDUERJQUdfQkNfU19DT05EOgorCQljYXNlIFRDUERJQUdfQkNfRF9DT05EOgorCQl7CisJCQlzdHJ1Y3QgdGNwZGlhZ19ob3N0Y29uZCAqY29uZCA9IChzdHJ1Y3QgdGNwZGlhZ19ob3N0Y29uZCopKG9wKzEpOworCQkJdTMyICphZGRyOworCisJCQlpZiAoY29uZC0+cG9ydCAhPSAtMSAmJgorCQkJICAgIGNvbmQtPnBvcnQgIT0gKG9wLT5jb2RlID09IFRDUERJQUdfQkNfU19DT05EID8KKwkJCQkJICAgICBlbnRyeS0+c3BvcnQgOiBlbnRyeS0+ZHBvcnQpKSB7CisJCQkJeWVzID0gMDsKKwkJCQlicmVhazsKKwkJCX0KKwkJCQorCQkJaWYgKGNvbmQtPnByZWZpeF9sZW4gPT0gMCkKKwkJCQlicmVhazsKKworCQkJaWYgKG9wLT5jb2RlID09IFRDUERJQUdfQkNfU19DT05EKQorCQkJCWFkZHI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JZXJyID0gc2tiX2NvcHlfZGF0YWdyYW1faW92ZWMoc2tiLCBzaXplb2Yoc3RydWN0IHVkcGhkciksIG1zZy0+bXNnX2lvdiwKKwkJCQkJICAgICAgY29waWVkKTsKKwl9IGVsc2UgeworCQllcnIgPSBza2JfY29weV9hbmRfY3N1bV9kYXRhZ3JhbV9pb3ZlYyhza2IsIHNpemVvZihzdHJ1Y3QgdWRwaGRyKSwgbXNnLT5tc2dfaW92KTsKKworCQlpZiAoZXJyID09IC1FSU5WQUwpCisJCQlnb3RvIGNzdW1fY29weV9lcnI7CisJfQorCisJaWYgKGVycikKKwkJZ290byBvdXRfZnJlZTsKKworCXNvY2tfcmVjdl90aW1lc3RhbXAobXNnLCBzaywgc2tiKTsKKworCS8qIENvcHkgdGhlIGFkZHJlc3MuICovCisJaWYgKHNpbikKKwl7CisJCXNpbi0+c2luX2ZhbWlseSA9IEFGX0lORVQ7CisJCXNpbi0+c2luX3BvcnQgPSBza2ItPmgudWgtPnNvdXJjZTsKKwkJc2luLT5zaW5fYWRkci5zX2FkZHIgPSBza2ItPm5oLmlwaC0+c2FkZHI7CisJCW1lbXNldChzaW4tPnNpbl96ZXJvLCAwLCBzaXplb2Yoc2luLT5zaW5femVybykpOworICAJfQorCWlmIChpbmV0LT5jbXNnX2ZsYWdzKQorCQlpcF9jbXNnX3JlY3YobXNnLCBza2IpOworCisJZXJyID0gY29waWVkOworCWlmIChmbGFncyAmIE1TR19UUlVOQykKKwkJZXJyID0gc2tiLT5sZW4gLSBzaXplb2Yoc3RydWN0IHVkcGhkcik7CisgIAorb3V0X2ZyZWU6CisgIAlza2JfZnJlZV9kYXRhZ3JhbShzaywgc2tiKTsKK291dDoKKyAgCXJldHVybiBlcnI7CisKK2NzdW1fY29weV9lcnI6CisJVURQX0lOQ19TVEFUU19CSChVRFBfTUlCX0lORVJST1JTKTsKKworCS8qIENsZWFyIHF1ZXVlLiAqLworCWlmIChmbGFncyZNU0dfUEVFSykgeworCQlpbnQgY2xlY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