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b250cm9sIHNvY2tldCAiCisJCQkgICAgICAgIihlcnIgJWQpLlxuIiwKKwkJCSAgICAgICBlcnIpOworCQkJZ290byBmYWlsOworCQl9CisKKwkJc2sgPSBwZXJfY3B1KF9faWNtcHY2X3NvY2tldCwgaSktPnNrOworCQlzay0+c2tfYWxsb2NhdGlvbiA9IEdGUF9BVE9NSUM7CisKKwkJLyogRW5vdWdoIHNwYWNlIGZvciAyIDY0SyBJQ01QIHBhY2tldHMsIGluY2x1ZGluZworCQkgKiBza19idWZmIHN0cnVjdCBvdmVyaGVhZC4KKwkJICovCisJCXNrLT5za19zbmRidWYgPQorCQkJKDIgKiAoKDY0ICogMTAyNCkgKyBzaXplb2Yoc3RydWN0IHNrX2J1ZmYpKSk7CisKKwkJc2stPnNrX3Byb3QtPnVuaGFzaChzayk7CisJfQorCisKKwlpZiAoaW5ldDZfYWRkX3Byb3RvY29sKCZpY21wdjZfcHJvdG9jb2wsIElQUFJPVE9fSUNNUFY2KSA8IDApIHsKKwkJcHJpbnRrKEtFUk5fRVJSICJGYWlsZWQgdG8gcmVnaXN0ZXIgSUNNUDYgcHJvdG9jb2xcbiIpOworCQllcnIgPSAtRUFHQUlOOworCQlnb3RvIGZhaWw7CisJfQorCisJcmV0dXJuIDA7CisKKyBmYWlsOgorCWZvciAoaiA9IDA7IGogPCBpOyBqKyspIHsKKwkJaWYgKCFjcHVfcG9zc2libGUoaikpCisJCQljb250aW51ZTsKKwkJc29ja19yZWxlYXNlKHBlcl9jcHUoX19pY21wdjZfc29ja2V0LCBqKSk7CisJfQorCisJcmV0dXJuIGVycjsKK30KKwordm9pZCBpY21wdjZfY2xlYW51cCh2b2lkKQoreworCWludCBpOworCisJZm9yIChpID0gMDsgaSA8IE5SX0NQVVM7IGkrKykgeworCQlpZiAoIWNwdV9wb3NzaWJsZShpKSkKKwkJCWNvbnRpbnVlOworCQlzb2NrX3JlbGVhc2UocGVyX2NwdShfX2ljbXB2Nl9zb2NrZXQsIGkpKTsKKwl9Cis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kZWZpbmUgSEFTSF9TSVpFICAzMgorCisjZGVmaW5lIEhBU0goYWRkcikgKCgoYWRkciktPnM2X2FkZHIzMlswXSBeIChhZGRyKS0+czZfYWRkcjMyWzFdIF4gXAorCSAgICAgICAgICAgICAoYWRkciktPnM2X2FkZHIzMlsyXSBeIChhZGRyKS0+czZfYWRkcjMyWzNdKSAmIFwKKyAgICAgICAgICAgICAgICAgICAgKEhBU0hfU0laRSAtIDEpKQorCitzdGF0aWMgaW50IGlwNmlwNl9mYl90bmxfZGV2X2luaXQoc3RydWN0IG5ldF9kZXZpY2UgKmRldik7CitzdGF0aWMgaW50IGlwNmlwNl90bmxfZGV2X2luaXQoc3RydWN0IG5ldF9kZXZpY2UgKmRldik7CitzdGF0aWMgdm9pZCBpcDZpcDZfdG5sX2Rldl9zZXR1cChzdHJ1Y3QgbmV0X2RldmljZSAqZGV2KTsKKworLyogdGhlIElQdjYgdHVubmVsIGZhbGxiYWNrIGRldmljZSAqLworc3RhdGljIHN0cnVjdCBuZXRfZGV2aWNlICppcDZpcDZfZmJfdG5sX2RldjsKKworCisvKiBsaXN0cyBmb3Igc3RvcmluZyB0dW5uZWxzIGluIHVzZSAqLworc3RhdGljIHN0cnVjdCBpcDZfdG5sICp0bmxzX3JfbFtIQVNIX1NJWkVdOworc3RhdGljIHN0cnVjdCBpcDZfdG5sICp0bmxzX3djWzFdOworc3RhdGljIHN0cnVjdCBpcDZfdG5sICoqdG5sc1syXSA9IHsgdG5sc193YywgdG5sc19yX2wgfTsKKworLyogbG9jayBmb3IgdGhlIHR1bm5lbCBsaXN0cyAqLworc3RhdGljIERFRklORV9SV0xPQ0soaXA2aXA2X2xvY2spOworCitzdGF0aWMgaW5saW5lIHN0cnVjdCBkc3RfZW50cnkgKmlwNl90bmxfZHN0X2NoZWNrKHN0cnVjdCBpcDZfdG5sICp0KQoreworCXN0cnVjdCBkc3RfZW50cnkgKmRzdCA9IHQtPmRzdF9jYWNoZTsKKworCWlmIChkc3QgJiYgZHN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7CisJCS5jdGxfbmFtZQk9IENUTF9ORVQsCisJCS5wcm9jbmFtZQk9ICJuZXQiLAorCQkubW9kZQkJPSAwNTU1LAorCQkuY2hpbGQJCT0gaXBxX2Rpcl90YWJsZQorCX0sCisJeyAuY3RsX25hbWUgPSAwIH0KK307CisKK3N0YXRpYyBpbnQKK2lwcV9nZXRfaW5mbyhjaGFyICpidWZmZXIsIGNoYXIgKipzdGFydCwgb2ZmX3Qgb2Zmc2V0LCBpbnQgbGVuZ3RoKQoreworCWludCBsZW47CisKKwlyZWFkX2xvY2tfYmgoJnF1ZXVlX2xvY2spOworCQorCWxlbiA9IHNwcmludGYoYnVmZmVyLAorCSAgICAgICAgICAgICAgIlBlZXIgUElEICAgICAgICAgIDogJWRcbiIKKwkgICAgICAgICAgICAgICJDb3B5IG1vZGUgICAgICAgICA6ICVodVxuIgorCSAgICAgICAgICAgICAgIkNvcHkgcmFuZ2UgICAgICAgIDogJXVcbiIKKwkgICAgICAgICAgICAgICJRdWV1ZSBsZW5ndGggICAgICA6ICV1XG4iCisJICAgICAgICAgICAgICAiUXVldWUgbWF4LiBsZW5ndGggOiAldVxuIgorCQkgICAgICAiUXVldWUgZHJvcHBlZCAgICAgOiAldVxuIgorCQkgICAgICAiTmV0ZmlsdGVyIGRyb3BwZWQgOiAldVxuIiwKKwkgICAgICAgICAgICAgIHBlZXJfcGlkLAorCSAgICAgICAgICAgICAgY29weV9tb2RlLAorCSAgICAgICAgICAgICAgY29weV9yYW5nZSwKKwkgICAgICAgICAgICAgIHF1ZXVlX3RvdGFsLAorCSAgICAgICAgICAgICAgcXVldWVfbWF4bGVuLAorCQkgICAgICBxdWV1ZV9kcm9wcGVkLAorCQkgICAgICBxdWV1ZV91c2VyX2Ryb3BwZWQpOworCisJcmVhZF91bmxvY2tfYmgoJnF1ZXVlX2xvY2spOworCQorCSpzdGFydCA9IGJ1ZmZlciArIG9mZnNldDsKKwlsZW4gLT0gb2Zmc2V0OworCWlmIChsZW4gPiBsZW5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GludCBudW1iZXI7CisJLyogSW5pdGlhbCBudW1iZXIgb2YgZW50cmllcy4gTmVlZGVkIGZvciBtb2R1bGUgdXNhZ2UgY291bnQgKi8KKwl1bnNpZ25lZCBpbnQgaW5pdGlhbF9lbnRyaWVzOworCisJLyogRW50cnkgcG9pbnRzIGFuZCB1bmRlcmZsb3dzICovCisJdW5zaWduZWQgaW50IGhvb2tfZW50cnlbTkZfSVA2X05VTUhPT0tTXTsKKwl1bnNpZ25lZCBpbnQgdW5kZXJmbG93W05GX0lQNl9OVU1IT09LU107CisKKwkvKiBpcDZ0X2VudHJ5IHRhYmxlczogb25lIHBlciBDUFUgKi8KKwljaGFyIGVudHJpZXNbMF0gX19fX2NhY2hlbGluZV9hbGlnbmVkOworfTsKKworc3RhdGljIExJU1RfSEVBRChpcDZ0X3RhcmdldCk7CitzdGF0aWMgTElTVF9IRUFEKGlwNnRfbWF0Y2gpOworc3RhdGljIExJU1RfSEVBRChpcDZ0X3RhYmxlcyk7CisjZGVmaW5lIEFERF9DT1VOVEVSKGMsYixwKSBkbyB7IChjKS5iY250ICs9IChiKTsgKGMpLnBjbnQgKz0gKHApOyB9IHdoaWxlKDApCisKKyNpZmRlZiBDT05GSUdfU01QCisjZGVmaW5lIFRBQkxFX09GRlNFVCh0LHApIChTTVBfQUxJR04oKHQpLT5zaXplKSoocCkpCisjZWxzZQorI2RlZmluZSBUQUJMRV9PRkZTRVQodCxwKSAwCisjZW5kaWYKKworI2lmIDAKKyNkZWZpbmUgZG93bih4KSBkbyB7IHByaW50aygiRE9XTjoldToiICN4ICJcbiIsIF9fTElORV9fKTsgZG93bih4KTsgfSB3aGlsZSgwKQorI2RlZmluZSBkb3duX2ludGVycnVwdGlibGUoeCkgKHsgaW50IF9fcjsgcHJpbnRrKCJET1dOaToldToiICN4ICJcbiIsIF9fTElORV9fKTsgX19yID0gZG93bl9pbnRlcnJ1cHRpYmxlKHgpOyBpZiAoX19yICE9IDApIHByaW50aygiQUJPUlQtRE9XTmk6JXVcbiIsIF9fTElORV9fKTsgX19yOyB9KQorI2RlZmluZSB1cCh4KSBkbyB7IHByaW50aygiVVA6JXU6IiAjeCAiXG4iLCBfX0xJTkVfXyk7IHVwKHgpOyB9IHdoaWxlKDApCisjZW5kaWYKKworc3RhdGljIGludCBpcDZfbWFza2VkX2FkZHJjbXAoc3RydWN0IGluNl9hZGRyIGFkZHIxLCBzdHJ1Y3QgaW42X2FkZHIgbWFzaywKKwkJCSAgICAgIHN0cnVjdCBpbjZfYWRkciBhZGRyMikKK3sKKwlpbnQgaTsKKwlmb3IoIGkgPSAwOyBpIDwgMTY7IGkrKyl7CisJCWlmKChhZGRyMS5zNl9hZGRyW2ldICYgbWFzay5zNl9hZGRyW2ldKSAhPSAKKwkJICAgKGFkZHIyLnM2X2FkZHJbaV0gJiBtYXNrLnM2X2FkZHJbaV0pKQorCQkJcmV0dXJuIDE7CisJfQorCXJldHVybiAwOworfQorCisvKiBDaGVjayBmb3IgYW4gZXh0ZW5zaW9uICovCitpbnQgCitpcDZ0X2V4dF9oZHIodTggbmV4dGhkcikKK3sKKyAgICAgICAgcmV0dXJuICggKG5leHRoZHIgPT0gSVBQUk9UT19IT1BPUFRTKSAgIHx8CisgICAgICAgICAgICAgICAgIChuZXh0aGRyID09IElQUFJPVE9fUk9VVElORykgICB8fAorICAgICAgICAgICAgICAgICAobmV4dGhkciA9PSBJUFBST1RPX0ZSQUdNRU5UKSAgfHwKKyAgICAgICAgICAgICAgICAgKG5leHRoZHIgPT0gSVBQUk9UT19FU1ApICAgICAgIHx8CisgICAgICAgICAgICAgICAgIChuZXh0aGRyID09IElQUFJPVE9fQUgpICAgICAgICB8fAorICAgICAgICAgICAgICAgICAobmV4dGhkciA9PSBJUFBST1RPX05PTkUpICAgICAgfHwKKyAgICAgICAgICAgICAgICAgKG5leHRoZHIgPT0gSVBQUk9UT19EU1RPUFRTKSApOworfQorCisvKiBSZXR1cm5zIHdoZXRoZXIgbWF0Y2hlcyBydWxlIG9yIG5vd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IHRvIGNvdW50IHRoZXNlIHBhY2tldHMgaW4gJy1wIGFsbCcsCisJCQkgKiB3ZSB3aWxsIGNoYW5nZSB0aGUgcmV0dXJuIDAgdG8gMSovCisJCQlpZiAoKGN1cnJlbnRoZHIgPT0gSVBQUk9UT19OT05FKSB8fCAKKwkJCQkoY3VycmVudGhkciA9PSBJUFBST1RPX0VTUCkpCisJCQkJYnJlYWs7CisKKwkJCWhwID0gc2tiX2hlYWRlcl9wb2ludGVyKHNrYiwgcHRyLCBzaXplb2YoX2hkciksICZfaGRyKTsKKwkJCUJVR19PTihocCA9PSBOVUxMKTsKKworCQkJLyogU2l6ZSBjYWxjdWxhdGlvbiAqLworCSAgICAgICAgICAgICAgICBpZiAoY3VycmVudGhkciA9PSBJUFBST1RPX0ZSQUdNRU5UKSB7CisJCQkJZnAgPSBza2JfaGVhZGVyX3BvaW50ZXIoc2tiLAorCQkJCQkJICAgcHRyK29mZnNldG9mKHN0cnVjdCBmcmFnX2hkciwKKwkJCQkJCQkJZnJhZ19vZmYpLAorCQkJCQkJICAgc2l6ZW9mKF9mcmFnb2ZmKSwKKwkJCQkJCSAgICZfZnJhZ29mZik7CisJCQkJaWYgKGZwID09IE5VTEwpCisJCQkJCXJldHVybiAwOworCisJCQkJX2ZyYWdvZmYgPSBudG9ocygqZnApICYgfjB4NzsKKwkgICAgICAgICAgICAgICAgICAgICAgICBoZHJsZW4gPSA4OworCSAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGN1cnJlbnRoZHIgPT0gSVBQUk9UT19BSCkKKwkgICAgICAgICAgICAgICAgICAgICAgICBoZHJsZW4gPSAoaHAtPmhkcmxlbisyKTw8MjsKKwkgICAgICAgICAgICAgICAgZWxzZQorCSAgICAgICAgICAgICAgICAgICAgICAgIGhkcmxlbiA9IGlwdjZfb3B0bGVuKGhwKTsKKworCQkJY3VycmVudGhkciA9IGhwLT5uZXh0aGRyOworCSAgICAgICAgICAgICAgICBwdHIgKz0gaGRybGVuOworCQkJLyog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0dXJuIDA7Cit9CisKKy8qIENoZWNrcyBhbmQgdHJhbnNsYXRlcyB0aGUgdXNlci1zdXBwbGllZCB0YWJsZSBzZWdtZW50IChoZWxkIGluCisgICBuZXdpbmZvKSAqLworc3RhdGljIGludAordHJhbnNsYXRlX3RhYmxlKGNvbnN0IGNoYXIgKm5hbWUsCisJCXVuc2lnbmVkIGludCB2YWxpZF9ob29rcywKKwkJc3RydWN0IGlwNnRfdGFibGVfaW5mbyAqbmV3aW5mbywKKwkJdW5zaWduZWQgaW50IHNpemUsCisJCXVuc2lnbmVkIGludCBudW1iZXIsCisJCWNvbnN0IHVuc2lnbmVkIGludCAqaG9va19lbnRyaWVzLAorCQljb25zdCB1bnNpZ25lZCBpbnQgKnVuZGVyZmxvd3MpCit7CisJdW5zaWduZWQgaW50IGk7CisJaW50IHJldDsKKworCW5ld2luZm8tPnNpemUgPSBzaXplOworCW5ld2luZm8tPm51bWJlciA9IG51bWJlcjsKKworCS8qIEluaXQgYWxsIGhvb2tzIHRvIGltcG9zc2libGUgdmFsdWUuICovCisJZm9yIChpID0gMDsgaSA8IE5GX0lQNl9OVU1IT09LUzsgaSsrKSB7CisJCW5ld2luZm8tPmhvb2tfZW50cnlbaV0gPSAweEZGRkZGRkZGOworCQluZXdpbmZvLT51bmRlcmZsb3dbaV0gPSAweEZGRkZGRkZGOworCX0KKworCWR1cHJpbnRmKCJ0cmFuc2xhdGVfdGFibGU6IHNpemUgJXVcbiIsIG5ld2luZm8tPnNpemUpOworCWkgPSAwOworCS8qIFdhbGsgdGhyb3VnaCBlbnRyaWVzLCBjaGVja2luZyBvZmZzZXRzLiAqLworCXJldCA9IElQNlRfRU5UUllfSVRFUkFURShuZXdpbmZvLT5lbnRyaWVzLCBuZXdpbmZvLT5zaXplLAorCQkJCWNoZWNrX2VudHJ5X3NpemVfYW5kX2hvb2tzLAorCQkJCW5ld2luZm8sCisJCQkJbmV3aW5mby0+ZW50cmllcywKKwkJCQluZXdpbmZvLT5lbnRyaWV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nJvbSA9IDB4ZGVhZDU3YWM7CisJCX0KKwl9CisjZW5kaWYKKworCS8qIERvIHRoZSBzdWJzdGl0dXRpb24uICovCisJd3JpdGVfbG9ja19iaCgmdGFibGUtPmxvY2spOworCS8qIENoZWNrIGluc2lkZSBsb2NrOiBpcyB0aGUgb2xkIG51bWJlciBjb3JyZWN0PyAqLworCWlmIChudW1fY291bnRlcnMgIT0gdGFibGUtPnByaXZhdGUtPm51bWJlcikgeworCQlkdXByaW50ZigibnVtX2NvdW50ZXJzICE9IHRhYmxlLT5wcml2YXRlLT5udW1iZXIgKCV1LyV1KVxuIiwKKwkJCSBudW1fY291bnRlcnMsIHRhYmxlLT5wcml2YXRlLT5udW1iZXIpOworCQl3cml0ZV91bmxvY2tfYmgoJnRhYmxlLT5sb2NrKTsKKwkJKmVycm9yID0gLUVBR0FJTjsKKwkJcmV0dXJuIE5VTEw7CisJfQorCW9sZGluZm8gPSB0YWJsZS0+cHJpdmF0ZTsKKwl0YWJsZS0+cHJpdmF0ZSA9IG5ld2luZm87CisJbmV3aW5mby0+aW5pdGlhbF9lbnRyaWVzID0gb2xkaW5mby0+aW5pdGlhbF9lbnRyaWVzOworCXdyaXRlX3VubG9ja19iaCgmdGFibGUtPmxvY2spOworCisJcmV0dXJuIG9sZGluZm87Cit9CisKKy8qIEdldHMgY291bnRlcnMuICovCitzdGF0aWMgaW5saW5lIGludAorYWRkX2VudHJ5X3RvX2NvdW50ZXIoY29uc3Qgc3RydWN0IGlwNnRfZW50cnkgKmUsCisJCSAgICAgc3RydWN0IGlwNnRfY291bnRlcnMgdG90YWxbXSwKKwkJICAgICB1bnNpZ25lZCBpbnQgKmkpCit7CisJQUREX0NPVU5URVIodG90YWxbKmldLCBlLT5jb3VudGVycy5iY250LCBlLT5jb3VudGVycy5wY250KTsKKworCSgqaSkrKzsKKwlyZXR1cm4gMDsKK30KKworc3RhdGljIHZvaWQKK2dldF9jb3VudGVycyhjb25zdCBzdHJ1Y3QgaXA2dF90YWJsZV9pbmZvICp0LAorCSAgICAgc3RydWN0IGlwNnRfY291bnRlcnMgY291bnRlcnNbXSkKK3sKKwl1bnNpZ25lZCBpbnQgY3B1OworCXVuc2lnbmVkIGludCBpOworCisJZm9yIChjcHUgPSAwOyBjcHUgPCBudW1fcG9zc2libGVfY3B1cygpOyBjcHUrKykgeworCQlpID0gMDsKKwkJSVA2VF9FTlRSWV9JVEVSQVRFKHQtPmVudHJpZXMgKyBUQUJMRV9PRkZTRVQodCwgY3B1KSwKKwkJCQkgIHQtPnNpemUsCisJCQkJICBhZGRfZW50cnlfdG9fY291bnRlciwKKwkJCQkgIGNvdW50ZXJzLAorCQkJCSAgJmkpOworCX0KK30KKworc3RhdGljIGludAorY29weV9lbnRyaWVzX3RvX3VzZXIodW5zaWduZWQgaW50IHRvdGFsX3NpemUsCisJCSAgICAgc3RydWN0IGlwNnRfdGFibGUgKnRhYmxlLAorCQkgICAgIHZvaWQgX191c2VyICp1c2VycHRyKQoreworCXVuc2lnbmVkIGludCBvZmYsIG51bSwgY291bnRlcnNpemU7CisJc3RydWN0IGlwNnRfZW50cnkgKmU7CisJc3RydWN0IGlwNnRfY291bnRlcnMgKmNvdW50ZXJzOworCWludCByZXQgPSAwOworCisJLyogV2UgbmVlZCBhdG9taWMgc25hcHNob3Qgb2YgY291bnRlcnM6IHJlc3QgZG9lc24ndCBjaGFuZ2UKKwkgICAob3RoZXIgdGhhbiBjb21lZnJvbSwgd2hpY2ggdXNlcnNwYWNlIGRvZXNuJ3QgY2FyZQorCSAgIGFib3V0KS4gKi8KKwljb3VudGVyc2l6ZSA9IHNpemVvZihzdHJ1Y3QgaXA2dF9jb3VudGVycykgKiB0YWJsZS0+cHJpdmF0ZS0+bnVtYmVyOworCWNvdW50ZXJzID0gdm1hbGxvYyhjb3VudGVyc2l6ZSk7CisKKwlpZiAoY291bnRlcnMgPT0gTlVMTCkKKwkJcmV0dXJuIC1FTk9NRU07CisKKwkvKiBGaXJzdCwgc3VtIGNvdW50ZXJz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S8qIEVTUCAtPiBldmFsdWF0ZSAqLworCQlpZiAobmV4dGhkciA9PSBORVhUSERSX0VTUCkKKwkJCWJyZWFrOworCisJCWhwID0gc2tiX2hlYWRlcl9wb2ludGVyKHNrYiwgcHRyLCBzaXplb2YoX2hkciksICZfaGRyKTsKKwkJQlVHX09OKGhwID09IE5VTEwpOworCisJCS8qIENhbGN1bGF0ZSB0aGUgaGVhZGVyIGxlbmd0aCAqLworCQlpZiAobmV4dGhkciA9PSBORVhUSERSX0ZSQUdNRU5UKQorCQkJaGRybGVuID0gODsKKwkJZWxzZSBpZiAobmV4dGhkciA9PSBORVhUSERSX0FVVEgpCisJCQloZHJsZW4gPSAoaHAtPmhkcmxlbisyKTw8MjsKKwkJZWxzZQorCQkJaGRybGVuID0gaXB2Nl9vcHRsZW4oaHApOworCisJCS8qIEFIIC0+IGV2YWx1YXRlICovCisJCWlmIChuZXh0aGRyID09IE5FWFRIRFJfQVVUSCkgeworCQkJdGVtcCB8PSBNQVNLX0FIOworCQkJYnJlYWs7CisJCX0KKworCQkKKwkJLyogc2V0IHRoZSBmbGFnICovCisJCXN3aXRjaCAobmV4dGhkcikgeworCQljYXNlIE5FWFRIRFJfSE9QOgorCQljYXNlIE5FWFRIRFJfUk9VVElORzoKKwkJY2FzZSBORVhUSERSX0ZSQUdNRU5UOgorCQljYXNlIE5FWFRIRFJfQVVUSDoKKwkJY2FzZSBORVhUSERSX0RFU1Q6CisJCQlicmVhazsKKwkJZGVmYXVsdDoKKwkJCURFQlVHUCgiaXB2Nl9haCBtYXRjaDogdW5rbm93biBuZXh0aGVhZGVyICV1XG4iLG5leHRoZHIpOworCQkJcmV0dXJuIDA7CisJCX0KKworCQluZXh0aGRyID0gaHAtPm5leHRoZHI7CisJCWxlbiAtPSBoZHJsZW47CisJCXB0ciArPSBoZHJsZW47CisJCWlmIChwdHIgPiBza2ItPmxlbikgeworCQkJREVCVUdQKCJpcHY2X2FoOiBuZXcgcG9pbnRlciB0b28gbGFyZ2UhIFxuIik7CisJCQlicmVhazsKKwkJfQorCX0KKworCS8qIEFIIGhlYWRlciBub3QgZm91bmQgKi8KKwlpZiAodGVtcCAhPSBNQVNLX0FIKQorCQlyZXR1cm4gMDsKKworCWlmIChsZW4gPCBzaXplb2Yoc3RydWN0IGlwX2F1dGhfaGRyKSl7CisJCSpob3Rkcm9wID0gMTsKKwkJcmV0dXJuIDA7CisJfQorCisJYWggPSBza2JfaGVhZGVyX3BvaW50ZXIoc2tiLCBwdHIsIHNpemVvZihfYWgpLCAmX2FoKTsKKwlCVUdfT04oYWggPT0gTlVMTCk7CisKKwlERUJVR1AoIklQdjYgQUggTEVOICV1ICV1ICIsIGhkcmxlbiwgYWgtPmhkcmxlbik7CisJREVCVUdQKCJSRVMgJTA0WCAiLCBhaC0+cmVzZXJ2ZWQpOworCURFQlVHUCgiU1BJICV1ICUwOFhcbiIsIG50b2hsKGFoLT5zcGkpLCBudG9obChhaC0+c3BpKSk7CisKKwlERUJVR1AoIklQdjYgQUggc3BpICUwMlggIiwKKwkgICAgICAgKHNwaV9tYXRjaChhaGluZm8tPnNwaXNbMF0sIGFoaW5mby0+c3Bpc1sxXSwKKwkgICAgICAgICAgICAgICAgICBudG9obChhaC0+c3BpKSwKKwkgICAgICAgICAgICAgICAgICAhIShhaGluZm8tPmludmZsYWdzICYgSVA2VF9BSF9JTlZfU1BJKSkpKTsKKwlERUJVR1AoImxlbiAlMDJYICUwNFggJTAyWCAiLAorCSAgICAgICBhaGluZm8tPmhkcmxlbiwgaGRybGVuLAorCSAgICAgICAoIWFoaW5mby0+aGRybGVuIHx8CisJICAgICAgICAoYWhpbmZvLT5oZHJsZW4gPT0gaGRybGVuKSBeCisJICAgICAgICAhIShhaGluZm8tPmludmZsYWdzICYgSVA2VF9BSF9JTlZfTEVOKSkpOworCURFQlVHUCgicmVzICUwMlggJTA0WCAlMDJYXG4iLAorCSAgICAgICBhaGluZm8tPmhkcnJlcywgYWgtPnJlc2VydmVkLAorCSAgICAgICAhKGFoaW5mby0+aGRycmVzICYmIGFoLT5yZXNlcnZlZCkpOworCisJcmV0dXJuIChhaCAhPSBOVUxMKQorCSAgICAgICAmJgorCSAgICAgICAoc3BpX21hdGNoKGFoaW5mby0+c3Bpc1swXSwgYWhpbmZvLT5zcGlzWzFdLAorCSAgICAgICAgICAgICAgICAgIG50b2hsKGFoLT5zcGkpLAorCSAgICAgICAgICAgICAgICAgICEhKGFoaW5mby0+aW52ZmxhZ3MgJiBJUDZUX0FIX0lOVl9TUEkpKSkKKwkgICAgICAgJiYKKwkgICAgICAgKCFhaGluZm8tPmhkcmxlbiB8fAorCSAgICAgICAgKGFoaW5mby0+aGRybGVuID09IGhkcmxlbikgXgorCSAgICAgICAgISEoYWhpbmZvLT5pbnZmbGFncyAmIElQNlRfQUhfSU5WX0xFTikpCisJICAgICAgICYmCisJICAgICAgICEoYWhpbmZvLT5oZHJyZXMgJiYgYWgtPnJlc2VydmVkKTsKK30KKworLyogQ2FsbGVkIHdoZW4gdXNlciB0cmllcyB0byBpbnNlcnQgYW4gZW50cnkgb2YgdGhpcyB0eXBlLiAqLworc3RhdGljIGludAorY2hlY2tlbnRyeShjb25zdCBjaGFyICp0YWJsZW5hbWUsCisgICAgICAgICAgY29uc3Qgc3RydWN0IGlwNnRfaXA2ICppcCwKKyAgICAgICAgICB2b2lkICptYXRjaGluZm8sCisgICAgICAgICAgdW5zaWduZWQgaW50IG1hdGNoaW5mb3NpemUsCisgICAgICAgICAgdW5zaWduZWQgaW50IGhvb2tfbWFzaykKK3sKKwljb25zdCBzdHJ1Y3QgaXA2dF9haCAqYWhpbmZvID0gbWF0Y2hpbmZvOworCisJaWYgKG1hdGNoaW5mb3NpemUgIT0gSVA2VF9BTElHTihzaXplb2Yoc3RydWN0IGlwNnRfYWgpKSkgeworCQlERUJVR1AoImlwNnRfYWg6IG1hdGNoc2l6ZSAldSAhPSAldVxuIiwKKwkJICAgICAgIG1hdGNoaW5mb3NpemUsIElQNlRfQUxJR04oc2l6ZW9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mV4dGhkcjsKKyAgICAgICB1bnNpZ25lZCBpbnQgcHRyOworICAgICAgIHVuc2lnbmVkIGludCBoZHJsZW4gPSAwOworICAgICAgIHVuc2lnbmVkIGludCByZXQgPSAwOworICAgICAgIHU4IF9vcHR0eXBlLCAqdHAgPSBOVUxMOworICAgICAgIHU4IF9vcHRsZW4sICpscCA9IE5VTEw7CisgICAgICAgdW5zaWduZWQgaW50IG9wdGxlbjsKKyAgICAgICAKKyAgICAgICAvKiB0eXBlIG9mIHRoZSAxc3QgZXh0aGRyICovCisgICAgICAgbmV4dGhkciA9IHNrYi0+bmguaXB2NmgtPm5leHRoZHI7CisgICAgICAgLyogcG9pbnRlciB0byB0aGUgMXN0IGV4dGhkciAqLworICAgICAgIHB0ciA9IHNpemVvZihzdHJ1Y3QgaXB2Nmhkcik7CisgICAgICAgLyogYXZhaWxhYmxlIGxlbmd0aCAqLworICAgICAgIGxlbiA9IHNrYi0+bGVuIC0gcHRyOworICAgICAgIHRlbXAgPSAwOworCisgICAgICAgIHdoaWxlIChpcDZ0X2V4dF9oZHIobmV4dGhkcikpIHsKKyAgICAgICAgICAgICAgIHN0cnVjdCBpcHY2X29wdF9oZHIgX2hkciwgKmhwOworCisgICAgICAgICAgICAgIERFQlVHUCgiaXB2Nl9vcHRzIGhlYWRlciBpdGVyYXRpb24gXG4iKTsKKworICAgICAgICAgICAgICAvKiBJcyB0aGVyZSBlbm91Z2ggc3BhY2UgZm9yIHRoZSBuZXh0IGV4dCBoZWFkZXI/ICovCisgICAgICAgICAgICAgICAgaWYgKGxlbiA8IChpbnQpc2l6ZW9mKHN0cnVjdCBpcHY2X29wdF9oZHIpKQorICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIDA7CisgICAgICAgICAgICAgIC8qIE5vIG1vcmUgZXh0aGRyIC0+IGV2YWx1YXRlICovCisgICAgICAgICAgICAgICAgaWYgKG5leHRoZHIgPT0gTkVYVEhEUl9OT05FKSB7CisgICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAvKiBFU1AgLT4gZXZhbHVhdGUgKi8KKyAgICAgICAgICAgICAgICBpZiAobmV4dGhkciA9PSBORVhUSERSX0VTUCkgeworICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgIH0KKworCSAgICAgIGhwID0gc2tiX2hlYWRlcl9wb2ludGVyKHNrYiwgcHRyLCBzaXplb2YoX2hkciksICZfaGRyKTsKKwkgICAgICBCVUdfT04oaHAgPT0gTlVMTCk7CisKKyAgICAgICAgICAgICAgLyogQ2FsY3VsYXRlIHRoZSBoZWFkZXIgbGVuZ3RoICovCisgICAgICAgICAgICAgICAgaWYgKG5leHRoZHIgPT0gTkVYVEhEUl9GUkFHTUVOVCkgeworICAgICAgICAgICAgICAgICAgICAgICAgaGRybGVuID0gODsKKyAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKG5leHRoZHIgPT0gTkVYVEhEUl9BVVRIKQorICAgICAgICAgICAgICAgICAgICAgICAgaGRybGVuID0gKGhwLT5oZHJsZW4rMik8PDI7CisgICAgICAgICAgICAgICAgZWxzZQorICAgICAgICAgICAgICAgICAgICAgICAgaGRybGVuID0gaXB2Nl9vcHRsZW4oaHApOworCisgICAgICAgICAgICAgIC8qIE9QVFMgLT4gZXZhbHVhdGUgKi8KKyNpZiBIT1BCWUhPUAorICAgICAgICAgICAgICAgIGlmIChuZXh0aGRyID09IE5FWFRIRFJfSE9QKSB7CisgICAgICAgICAgICAgICAgICAgICB0ZW1wIHw9IE1BU0tfSE9QT1BUUzsKKyNlbHNlCisgICAgICAgICAgICAgICAgaWYgKG5leHRoZHIgPT0gTkVYVEhEUl9ERVNUKSB7CisgICAgICAgICAgICAgICAgICAgICB0ZW1wIHw9IE1BU0tfRFNUT1BUUzsKKyNlbmRpZgorICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgIH0KKworCisgICAgICAgICAgICAgIC8qIHNldCB0aGUgZmxhZyAqLworICAgICAgICAgICAgICBzd2l0Y2ggKG5leHRoZHIpeworICAgICAgICAgICAgICAgICAgICAgY2FzZSBORVhUSERSX0hPUDoKKyAgICAgICAgICAgICAgICAgICAgIGNhc2UgTkVYVEhEUl9ST1VUSU5HOgorICAgICAgICAgICAgICAgICAgICAgY2FzZSBORVhUSERSX0ZSQUdNRU5UOgorICAgICAgICAgICAgICAgICAgICAgY2FzZSBORVhUSERSX0FVVEg6CisgICAgICAgICAgICAgICAgICAgICBjYXNlIE5FWFRIRFJfREVTVDoKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgREVCVUdQKCJpcHY2X29wdHMgbWF0Y2g6IHVua25vd24gbmV4dGhlYWRlciAldVxuIixuZXh0aGRyKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gMDsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgfQorCisgICAgICAgICAgICAgICAgbmV4dGhkciA9IGhwLT5uZXh0aGRyOworICAgICAgICAgICAgICAgIGxlbiAtPSBoZHJsZW47CisgICAgICAgICAgICAgICAgcHRyICs9IGhkcmxlbjsKKwkJaWYgKCBwdHIgPiBza2ItPmxlbiApIHsKKwkJCURFQlVHUCgiaXB2Nl9vcHRzOiBuZXcgcG9pbnRlciBpcyB0b28gbGFyZ2UhIFxuIik7CisJCQlicmVhazsKKwkJfQorICAgICAgICB9CisKKyAgICAgICAvKiBPUFRJT05TIGhlYWRlciBub3QgZm91bmQgKi8KKyNpZiBIT1BCWUhPUAorICAgICAgIGlmICggdGVtcCAhPSBNQVNLX0hPUE9QVFMgKSByZXR1cm4gMDsKKyNlbHNlCisgICAgICAgaWYgKCB0ZW1wICE9IE1BU0tfRFNUT1BUUyApIHJldHVybiAwOworI2VuZGlmCisKKyAgICAgICBpZiAobGVuIDwgKGludClzaXplb2Yoc3RydWN0IGlwdjZfb3B0X2hkcikpeworCSAgICAgICAqaG90ZHJvcCA9IDE7CisgICAgICAgCQlyZXR1cm4gMDsKKyAgICAgICB9CisKKyAgICAgICBpZiAobGVuIDwgaGRybGVuKXsKKwkgICAgICAgLyogUGFja2V0IHNtYWxsZXIgdGhhbiBpdCdzIGxlbmd0aCBmaWVsZCAqLworICAgICAgIAkJcmV0dXJuIDA7CisgICAgICAgfQorCisgICAgICAgb2ggPSBza2JfaGVhZGVyX3BvaW50ZXIoc2tiLCBwdHIsIHNpemVvZihfb3B0c2gpLCAmX29wdHNoKTsKKyAgICAgICBCVUdfT04ob2ggPT0gTlVMTCk7CisKKyAgICAgICBERUJVR1AoIklQdjYgT1BUUyBMRU4gJXUgJXUgIiwgaGRybGVuLCBvaC0+aGRybGVuKTsKKworICAgICAgIERFQlVHUCgibGVuICUwMlggJTA0WCAlMDJYICIsCisgICAgICAgCQlvcHRpbmZvLT5oZHJsZW4sIGhkcmxlbiwKKyAgICAgICAJCSghKG9wdGluZm8tPmZsYWdzICYgSVA2VF9PUFRTX0xFTikgfHwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICgob3B0aW5mby0+aGRybGVuID09IGhkcmxlbikgXgorICAgICAgICAgICAgICAgICAgICAgICAgICAgISEob3B0aW5mby0+aW52ZmxhZ3MgJiBJUDZUX09QVFNfSU5WX0xFTikpKSk7CisKKyAgICAgICByZXQgPSAob2ggIT0gTlVMTCkKKyAgICAgICAJCSYmCisJICAgICAgCSghKG9wdGluZm8tPmZsYWdzICYgSVA2VF9PUFRTX0xFTikgfHwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICgob3B0aW5mby0+aGRybGVuID09IGhkcmxlbikgXgorICAgICAgICAgICAgICAgICAgICAgICAgICAgISEob3B0aW5mby0+aW52ZmxhZ3MgJiBJUDZUX09QVFNfSU5WX0xFTikpKTsKKworICAgICAgIHB0ciArPSAyOworICAgICAgIGhkcmxlbiAtP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uc3QgY2hhciAqdGFibGVuYW1lLAorICAgICAgICAgIGNvbnN0IHN0cnVjdCBpcDZ0X2lwNiAqaXAsCisgICAgICAgICAgdm9pZCAqbWF0Y2hpbmZvLAorICAgICAgICAgIHVuc2lnbmVkIGludCBtYXRjaGluZm9zaXplLAorICAgICAgICAgIHVuc2lnbmVkIGludCBob29rX21hc2spCit7CisgICAgICAgY29uc3Qgc3RydWN0IGlwNnRfb3B0cyAqb3B0c2luZm8gPSBtYXRjaGluZm87CisKKyAgICAgICBpZiAobWF0Y2hpbmZvc2l6ZSAhPSBJUDZUX0FMSUdOKHNpemVvZihzdHJ1Y3QgaXA2dF9vcHRzKSkpIHsKKyAgICAgICAgICAgICAgREVCVUdQKCJpcDZ0X29wdHM6IG1hdGNoc2l6ZSAldSAhPSAldVxuIiwKKyAgICAgICAgICAgICAgICAgICAgICBtYXRjaGluZm9zaXplLCBJUDZUX0FMSUdOKHNpemVvZihzdHJ1Y3QgaXA2dF9vcHRzKSkpOworICAgICAgICAgICAgICByZXR1cm4gMDsKKyAgICAgICB9CisgICAgICAgaWYgKG9wdHNpbmZvLT5pbnZmbGFncyAmIH5JUDZUX09QVFNfSU5WX01BU0spIHsKKyAgICAgICAgICAgICAgREVCVUdQKCJpcDZ0X29wdHM6IHVua25vd24gZmxhZ3MgJVhcbiIsCisgICAgICAgICAgICAgICAgICAgICAgb3B0c2luZm8tPmludmZsYWdzKTsKKyAgICAgICAgICAgICAgcmV0dXJuIDA7CisgICAgICAgfQorCisgICAgICAgcmV0dXJuIDE7Cit9CisKK3N0YXRpYyBzdHJ1Y3QgaXA2dF9tYXRjaCBvcHRzX21hdGNoID0geworI2lmIEhPUEJZSE9QCisJLm5hbWUJCT0gImhiaCIsCisjZWxzZQorCS5uYW1lCQk9ICJkc3QiLAorI2VuZGlmCisJLm1hdGNoCQk9ICZtYXRjaCwKKwkuY2hlY2tlbnRyeQk9ICZjaGVja2VudHJ5LAorCS5tZQkJPSBUSElTX01PRFVMRSwKK307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IGV1aTY0WzhdOworICAgIGludCBpPTA7CisKKyAgICAgaWYgKCAhKHNrYi0+bWFjLnJhdyA+PSBza2ItPmhlYWQKKyAgICAgICAgICAgICAgICAmJiAoc2tiLT5tYWMucmF3ICsgRVRIX0hMRU4pIDw9IHNrYi0+ZGF0YSkKKyAgICAgICAgICAgICAgICAmJiBvZmZzZXQgIT0gMCkgeworICAgICAgICAgICAgICAgICAgICAgICAgKmhvdGRyb3AgPSAxOworICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIDA7CisgICAgICAgICAgICAgICAgfQorICAgIAorICAgIG1lbXNldChldWk2NCwgMCwgc2l6ZW9mKGV1aTY0KSk7CisKKyAgICBpZiAoZXRoX2hkcihza2IpLT5oX3Byb3RvID09IG50b2hzKEVUSF9QX0lQVjYpKSB7CisgICAgICBpZiAoc2tiLT5uaC5pcHY2aC0+dmVyc2lvbiA9PSAweDYpIHsgCisgICAgICAgICBtZW1jcHkoZXVpNjQsIGV0aF9oZHIoc2tiKS0+aF9zb3VyY2UsIDMpOworICAgICAgICAgbWVtY3B5KGV1aTY0ICsgNSwgZXRoX2hkcihza2IpLT5oX3NvdXJjZSArIDMsIDMpOworCSBldWk2NFszXT0weGZmOworCSBldWk2NFs0XT0weGZlOworCSBldWk2NFswXSB8PSAweDAyOworCisJIGk9MDsKKwkgd2hpbGUgKChza2ItPm5oLmlwdjZoLT5zYWRkci5zNl9hZGRyWzgraV0gPT0KKwkJCSBldWk2NFtpXSkgJiYgKGk8OCkpIGkrKzsKKworCSBpZiAoIGkgPT0gOCApCisJIAlyZXR1cm4gMTsKKyAgICAgIH0KKyAgICB9CisKKyAgICByZXR1cm4gMDsKK30KKworc3RhdGljIGludAoraXA2dF9ldWk2NF9jaGVja2VudHJ5KGNvbnN0IGNoYXIgKnRhYmxlbmFtZSwKKwkJICAgY29uc3Qgc3RydWN0IGlwNnRfaXA2ICppcCwKKwkJICAgdm9pZCAqbWF0Y2hpbmZvLAorCQkgICB1bnNpZ25lZ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WYKKworLyogUmV0dXJucyAxIGlmIHRoZSBpZCBpcyBtYXRjaGVkIGJ5IHRoZSByYW5nZSwgMCBvdGhlcndpc2UgKi8KK3N0YXRpYyBpbmxpbmUgaW50CitpZF9tYXRjaCh1X2ludDMyX3QgbWluLCB1X2ludDMyX3QgbWF4LCB1X2ludDMyX3QgaWQsIGludCBpbnZlcnQpCit7CisgICAgICAgaW50IHI9MDsKKyAgICAgICBERUJVR1AoImZyYWcgaWRfbWF0Y2g6JWMgMHgleCA8PSAweCV4IDw9IDB4JXgiLGludmVydD8gJyEnOicgJywKKyAgICAgICAgICAgICAgbWluLGlkLG1heCk7CisgICAgICAgcj0oaWQgPj0gbWluICYmIGlkIDw9IG1heCkgXiBpbnZlcnQ7CisgICAgICAgREVCVUdQKCIgcmVzdWx0ICVzXG4iLHI/ICJQQVNTIiA6ICJGQUlMRUQiKTsKKyAgICAgICByZXR1cm4gcjsKK30KKworc3RhdGljIGludAorbWF0Y2goY29uc3Qgc3RydWN0IHNrX2J1ZmYgKnNrYiwKKyAgICAgIGNvbnN0IHN0cnVjdCBuZXRfZGV2aWNlICppbiwKKyAgICAgIGNvbnN0IHN0cnVjdCBuZXRfZGV2aWNlICpvdXQsCisgICAgICBjb25zdCB2b2lkICptYXRjaGluZm8sCisgICAgICBpbnQgb2Zmc2V0LAorICAgICAgdW5zaWduZWQgaW50IHByb3RvZmYsCisgICAgICBpbnQgKmhvdGRyb3ApCit7CisgICAgICAgc3RydWN0IGZyYWdfaGRyIF9mcmFnLCAqZmggPSBOVUxMOworICAgICAgIGNvbnN0IHN0cnVjdCBpcDZ0X2ZyYWcgKmZyYWdpbmZvID0gbWF0Y2hpbmZvOworICAgICAgIHVuc2lnbmVkIGludCB0ZW1wOworICAgICAgIGludCBsZW47CisgICAgICAgdTggbmV4dGhkcjsKKyAgICAgICB1bnNpZ25lZCBpbnQgcHRyOworICAgICAgIHVuc2lnbmVkIGludCBoZHJsZW4gPSAwOworCisgICAgICAgLyogdHlwZSBvZiB0aGUgMXN0IGV4dGhkciAqLworICAgICAgIG5leHRoZHIgPSBza2ItPm5oLmlwdjZoLT5uZXh0aGRyOworICAgICAgIC8qIHBvaW50ZXIgdG8gdGhlIDFzdCBleHRoZHIgKi8KKyAgICAgICBwdHIgPSBzaXplb2Yoc3RydWN0IGlwdjZoZHIpOworICAgICAgIC8qIGF2YWlsYWJsZSBsZW5ndGggKi8KKyAgICAgICBsZW4gPSBza2ItPmxlbiAtIHB0cjsKKyAgICAgICB0ZW1wID0gMDsKKworICAgICAgICB3aGlsZSAoaXA2dF9leHRfaGRyKG5leHRoZHIpKSB7CisgICAgICAgICAgICAgICBzdHJ1Y3QgaXB2Nl9vcHRfaGRyIF9oZHIsICpocDsKKworICAgICAgICAgICAgICBERUJVR1AoImlwdjZfZnJhZyBoZWFkZXIgaXRlcmF0aW9uIFxuIik7CisKKyAgICAgICAgICAgICAgLyogSXMgdGhlcmUgZW5vdWdoIHNwYWNlIGZvciB0aGUgbmV4dCBleHQgaGVhZGVyPyAqLworICAgICAgICAgICAgICAgIGlmIChsZW4gPCAoaW50KXNpemVvZihzdHJ1Y3QgaXB2Nl9vcHRfaGRyKSkKKyAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAwOworICAgICAgICAgICAgICAvKiBObyBtb3JlIGV4dGhkciAtPiBldmFsdWF0ZSAqLworICAgICAgICAgICAgICAgIGlmIChuZXh0aGRyID09IE5FWFRIRFJfTk9ORSkgeworICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgLyogRVNQIC0+IGV2YWx1YXRlICovCisgICAgICAgICAgICAgICAgaWYgKG5leHRoZHIgPT0gTkVYVEhEUl9FU1ApIHsKKyAgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICB9CisKKwkgICAgICBocCA9IHNrYl9oZWFkZXJfcG9pbnRlcihza2IsIHB0ciwgc2l6ZW9mKF9oZHIpLCAmX2hkcik7CisJICAgICAgQlVHX09OKGhwID09IE5VTEwpOworCisgICAgICAgICAgICAgIC8qIENhbGN1bGF0ZSB0aGUgaGVhZGVyIGxlbmd0aCAqLworICAgICAgICAgICAgICAgIGlmIChuZXh0aGRyID09IE5FWFRIRFJfRlJBR01FTlQpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIGhkcmxlbiA9IDg7CisgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChuZXh0aGRyID09IE5FWFRIRFJfQVVUSCkKKyAgICAgICAgICAgICAgICAgICAgICAgIGhkcmxlbiA9IChocC0+aGRybGVuKzIpPDwyOworICAgICAgICAgICAgICAgIGVsc2UKKyAgICAgICAgICAgICAgICAgICAgICAgIGhkcmxlbiA9IGlwdjZfb3B0bGVuKGhwKTsKKworICAgICAgICAgICAgICAvKiBGUkFHIC0+IGV2YWx1YXRlICovCisgICAgICAgICAgICAgICAgaWYgKG5leHRoZHIgPT0gTkVYVEhEUl9GUkFHTUVOVCkgeworICAgICAgICAgICAgICAgICAgICAgdGVtcCB8PSBNQVNLX0ZSQUdNRU5UOworICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgIH0KKworCisgICAgICAgICAgICAgIC8qIHNldCB0aGUgZmxhZyAqLworICAgICAgICAgICAgICBzd2l0Y2ggKG5leHRoZHIpeworICAgICAgICAgICAgICAgICAgICAgY2FzZSBORVhUSERSX0hPUDoKKyAgICAgICAgICAgICAgICAgICAgIGNhc2UgTkVYVEhEUl9ST1VUSU5HOgorICAgICAgICAgICAgICAgICAgICAgY2FzZSBORVhUSERSX0ZSQUdNRU5UOgorICAgICAgICAgICAgICAgICAgICAgY2FzZSBORVhUSERSX0FVVEg6CisgICAgICAgICAgICAgICAgICAgICBjYXNlIE5FWFRIRFJfREVTVDoKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgREVCVUdQKCJpcHY2X2ZyYWcgbWF0Y2g6IHVua25vd24gbmV4dGhlYWRlciAldVxuIixuZXh0aGRyKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gMDsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgfQorCisgICAgICAgICAgICAgICAgbmV4dGhkciA9IGhwLT5uZXh0aGRyOworICAgICAgICAgICAgICAgIGxlbiAtPSBoZHJsZW47CisgICAgICAgICAgICAgICAgcHRyICs9IGhkcmxlbjsKKwkJaWYgKCBwdHIgPiBza2ItPmxlbiApIHsKKwkJCURFQlVHUCgiaXB2Nl9mcmFnOiBuZXcgcG9pbnRlciB0b28gbGFyZ2UhIFxuIik7CisJCQlicmVhazsKKwkJfQorICAgICAgICB9CisKKyAgICAgICAvKiBGUkFHIGhlYWRlciBub3QgZm91bmQgKi8KKyAgICAgICBpZiAoIHRlbXAgIT0gTUFTS19GUkFHTUVOVCApIHJldHVybiAwOworCisgICAgICAgaWYgKGxlbiA8IHNpemVvZihzdHJ1Y3QgZnJhZ19oZHIpKXsKKwkgICAgICAgKmhvdGRyb3AgPSAxOworICAgICAgIAkJcmV0dXJuIDA7CisgICAgICAgfQorCisgICAgICAgZmggPSBza2JfaGVhZGVyX3BvaW50ZXIoc2tiLCBwdHIsIHNpemVvZihfZnJhZyksICZfZnJhZyk7CisgICAgICAgQlVHX09OKGZoID09IE5VTEwpOworCisgICAgICAgREVCVUdQKCJJTkZPICUwNFggIiwgZmgtPmZyYWdfb2ZmKTsKKyAgICAgICBERUJVR1AoIk9GRlNFVCAlMDRYICIsIG50b2hzKGZoLT5mcmFnX29mZikgJiB+MHg3KTsKKyAgICAgICBERUJVR1AoIlJFUyAlMDJYICUwNFgiLCBmaC0+cmVzZXJ2ZWQsIG50b2hzKGZoLT5mcmFnX29mZikgJiAweDYpOworICAgICAgIERFQlVHUCgiTUYgJTA0WCAiLCBmaC0+ZnJhZ19vZmYgJiB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yAmIElQNlRfRlJBR19OTUYpCisJCQkmJiAobnRvaHMoZmgtPmZyYWdfb2ZmKSAmIElQNl9NRikpOworfQorCisvKiBDYWxsZWQgd2hlbiB1c2VyIHRyaWVzIHRvIGluc2VydCBhbiBlbnRyeSBvZiB0aGlzIHR5cGUuICovCitzdGF0aWMgaW50CitjaGVja2VudHJ5KGNvbnN0IGNoYXIgKnRhYmxlbmFtZSwKKyAgICAgICAgICBjb25zdCBzdHJ1Y3QgaXA2dF9pcDYgKmlwLAorICAgICAgICAgIHZvaWQgKm1hdGNoaW5mbywKKyAgICAgICAgICB1bnNpZ25lZCBpbnQgbWF0Y2hpbmZvc2l6ZSwKKyAgICAgICAgICB1bnNpZ25lZCBpbnQgaG9va19tYXNrKQoreworICAgICAgIGNvbnN0IHN0cnVjdCBpcDZ0X2ZyYWcgKmZyYWdpbmZvID0gbWF0Y2hpbmZvOworCisgICAgICAgaWYgKG1hdGNoaW5mb3NpemUgIT0gSVA2VF9BTElHTihzaXplb2Yoc3RydWN0IGlwNnRfZnJhZykpKSB7CisgICAgICAgICAgICAgIERFQlVHUCgiaXA2dF9mcmFnOiBtYXRjaHNpemUgJXUgIT0gJXVcbiIsCisgICAgICAgICAgICAgICAgICAgICAgbWF0Y2hpbmZvc2l6ZSwgSVA2VF9BTElHTihzaXplb2Yoc3RydWN0IGlwNnRfZnJhZykpKTsKKyAgICAgICAgICAgICAgcmV0dXJuIDA7CisgICAgICAgfQorICAgICAgIGlmIChmcmFnaW5mby0+aW52ZmxhZ3MgJiB+SVA2VF9GUkFHX0lOVl9NQVNLKSB7CisgICAgICAgICAgICAgIERFQlVHUCgiaXA2dF9mcmFnOiB1bmtub3duIGZsYWdzICVYXG4iLAorICAgICAgICAgICAgICAgICAgICAgIGZyYWdpbmZvLT5pbnZmbGFncyk7CisgICAgICAgICAgICAgIHJldHVybiAwOworICAgICAgIH0KKworICAgICAgIHJldHVybiAxOworfQorCitzdGF0aWMgc3RydWN0IGlwNnRfbWF0Y2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oVHlwZSAmIDB4MjApID4+IDUKKyAqICAJMAktPiBpbnZhcmlhbnQKKyAqICAJMQktPiBjYW4gY2hhbmdlIHRoZSByb3V0aW5nCisgKiAgKFR5cGUgJiAweDFGKSBUeXBlCisgKiAgICAgIDAJLT4gUGFkMSAob25seSAxIGJ5dGUhKQorICogICAgICAxCS0+IFBhZE4gTEVOR1RIIGluZm8gKHRvdGFsIGxlbmd0aCA9IGxlbmd0aCArIDIpCisgKiAgICAgIEMwIHwgMgktPiBKVU1CTyA0IHggeCB4IHggKCB4eHh4ID4gNjRrICkKKyAqICAgICAgNQktPiBSVEFMRVJUIDIgeCB4CisgKi8KKworc3RhdGljIGludAorbWF0Y2goY29uc3Qgc3RydWN0IHNrX2J1ZmYgKnNrYiwKKyAgICAgIGNvbnN0IHN0cnVjdCBuZXRfZGV2aWNlICppbiwKKyAgICAgIGNvbnN0IHN0cnVjdCBuZXRfZGV2aWNlICpvdXQsCisgICAgICBjb25zdCB2b2lkICptYXRjaGluZm8sCisgICAgICBpbnQgb2Zmc2V0LAorICAgICAgdW5zaWduZWQgaW50IHByb3RvZmYsCisgICAgICBpbnQgKmhvdGRyb3ApCit7CisgICAgICAgc3RydWN0IGlwdjZfb3B0X2hkciBfb3B0c2gsICpvaDsKKyAgICAgICBjb25zdCBzdHJ1Y3QgaXA2dF9vcHRzICpvcHRpbmZvID0gbWF0Y2hpbmZvOworICAgICAgIHVuc2lnbmVkIGludCB0ZW1wOworICAgICAgIHVuc2lnbmVkIGludCBsZW47CisgICAgICAgdTggbmV4dGhkcjsKKyAgICAgICB1bnNpZ25lZCBpbnQgcHRyOworICAgICAgIHVuc2lnbmVkIGludCBoZHJsZW4gPSAwOworICAgICAgIHVuc2lnbmVkIGludCByZXQgPSAwOworICAgICAgIHU4IF9vcHR0eXBlLCAqdHAgPSBOVUxMOworICAgICAgIHU4IF9vcHRsZW4sICpscCA9IE5VTEw7CisgICAgICAgdW5zaWduZWQgaW50IG9wdGxlbjsKKyAgICAgICAKKyAgICAgICAvKiB0eXBlIG9mIHRoZSAxc3QgZXh0aGRyICovCisgICAgICAgbmV4dGhkciA9IHNrYi0+bmguaXB2NmgtPm5leHRoZHI7CisgICAgICAgLyogcG9pbnRlciB0byB0aGUgMXN0IGV4dGhkciAqLworICAgICAgIHB0ciA9IHNpemVvZihzdHJ1Y3QgaXB2Nmhkcik7CisgICAgICAgLyogYXZhaWxhYmxlIGxlbmd0aCAqLworICAgICAgIGxlbiA9IHNrYi0+bGVuIC0gcHRyOworICAgICAgIHRlbXAgPSAwOworCisgICAgICAgIHdoaWxlIChpcDZ0X2V4dF9oZHIobmV4dGhkcikpIHsKKyAgICAgICAgICAgICAgIHN0cnVjdCBpcHY2X29wdF9oZHIgX2hkciwgKmhwOworCisgICAgICAgICAgICAgIERFQlVHUCgiaXB2Nl9vcHRzIGhlYWRlciBpdGVyYXRpb24gXG4iKTsKKworICAgICAgICAgICAgICAvKiBJcyB0aGVyZSBlbm91Z2ggc3BhY2UgZm9yIHRoZSBuZXh0IGV4dCBoZWFkZXI/ICovCisgICAgICAgICAgICAgICAgaWYgKGxlbiA8IChpbnQpc2l6ZW9mKHN0cnVjdCBpcHY2X29wdF9oZHIpKQorICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIDA7CisgICAgICAgICAgICAgIC8qIE5vIG1vcmUgZXh0aGRyIC0+IGV2YWx1YXRlICovCisgICAgICAgICAgICAgICAgaWYgKG5leHRoZHIgPT0gTkVYVEhEUl9OT05FKSB7CisgICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAvKiBFU1AgLT4gZXZhbHVhdGUgKi8KKyAgICAgICAgICAgICAgICBpZiAobmV4dGhkciA9PSBORVhUSERSX0VTUCkgeworICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgIH0KKworCSAgICAgIGhwID0gc2tiX2hlYWRlcl9wb2ludGVyKHNrYiwgcHRyLCBzaXplb2YoX2hkciksICZfaGRyKTsKKwkgICAgICBCVUdfT04oaHAgPT0gTlVMTCk7CisKKyAgICAgICAgICAgICAgLyogQ2FsY3VsYXRlIHRoZSBoZWFkZXIgbGVuZ3RoICovCisgICAgICAgICAgICAgICAgaWYgKG5leHRoZHIgPT0gTkVYVEhEUl9GUkFHTUVOVCkgeworICAgICAgICAgICAgICAgICAgICAgICAgaGRybGVuID0gODsKKyAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKG5leHRoZHIgPT0gTkVYVEhEUl9BVVRIKQorICAgICAgICAgICAgICAgICAgICAgICAgaGRybGVuID0gKGhwLT5oZHJsZW4rMik8PDI7CisgICAgICAgICAgICAgICAgZWxzZQorICAgICAgICAgICAgICAgICAgICAgICAgaGRybGVuID0gaXB2Nl9vcHRsZW4oaHApOworCisgICAgICAgICAgICAgIC8qIE9QVFMgLT4gZXZhbHVhdGUgKi8KKyNpZiBIT1BCWUhPUAorICAgICAgICAgICAgICAgIGlmIChuZXh0aGRyID09IE5FWFRIRFJfSE9QKSB7CisgICAgICAgICAgICAgICAgICAgICB0ZW1wIHw9IE1BU0tfSE9QT1BUUzsKKyNlbHNlCisgICAgICAgICAgICAgICAgaWYgKG5leHRoZHIgPT0gTkVYVEhEUl9ERVNUKSB7CisgICAgICAgICAgICAgICAgICAgICB0ZW1wIHw9IE1BU0tfRFNUT1BUUzsKKyNlbmRpZgorICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgIH0KKworCisgICAgICAgICAgICAgIC8qIHNldCB0aGUgZmxhZyAqLworICAgICAgICAgICAgICBzd2l0Y2ggKG5leHRoZHIpeworICAgICAgICAgICAgICAgICAgICAgY2FzZSBORVhUSERSX0hPUDoKKyAgICAgICAgICAgICAgICAgICAgIGNhc2UgTkVYVEhEUl9ST1VUSU5HOgorICAgICAgICAgICAgICAgICAgICAgY2FzZSBORVhUSERSX0ZSQUdNRU5UOgorICAgICAgICAgICAgICAgICAgICAgY2FzZSBORVhUSERSX0FVVEg6CisgICAgICAgICAgICAgICAgICAgICBjYXNlIE5FWFRIRFJfREVTVDoKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgREVCVUdQKCJpcHY2X29wdHMgbWF0Y2g6IHVua25vd24gbmV4dGhlYWRlciAldVxuIixuZXh0aGRyKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gMDsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgfQorCisgICAgICAgICAgICAgICAgbmV4dGhkciA9IGhwLT5uZXh0aGRyOworICAgICAgICAgICAgICAgIGxlbiAtPSBoZHJsZW47CisgICAgICAgICAgICAgICAgcHRyICs9IGhkcmxlbjsKKwkJaWYgKCBwdHIgPiBza2ItPmxlbiApIHsKKwkJCURFQlVHUCgiaXB2Nl9vcHRzOiBuZXcgcG9pbnRlciBpcyB0b28gbGFyZ2UhIFxuIik7CisJCQlicmVhazsKKwkJfQorICAgICAgICB9CisKKyAgICAgICAvKiBPUFRJT05TIGhlYWRlciBub3QgZm91bmQgKi8KKyNpZiBIT1BCWUhPUAorICAgICAgIGlmICggdGVtcCAhPSBNQVNLX0hPUE9QVFMgKSByZXR1cm4gMDsKKyNlbHNlCisgICAgICAgaWYgKCB0ZW1wICE9IE1BU0tfRFNUT1BUUyApIHJldHVybiAwOworI2VuZGlmCisKKyAgICAgICBpZiAobGVuIDwgKGludClzaXplb2Yoc3RydWN0IGlwdjZfb3B0X2hkcikpeworCSAgICAgICAqaG90ZHJvcCA9IDE7CisgICAgICAgCQlyZXR1cm4gMDsKKyAgICAgICB9CisKKyAgICAgICBpZiAobGVuIDwgaGRybGVuKXsKKwkgICAgICAgLyogUGFja2V0IHNtYWxsZXIgdGhhbiBpdCdzIGxlbmd0aCBmaWVsZCAqLworICAgICAgIAkJcmV0dXJuIDA7CisgICAgICAgfQorCisgICAgICAgb2ggPSBza2JfaGVhZGVyX3BvaW50ZXIoc2tiLCBwdHIsIHNpemVvZihfb3B0c2gpLCAmX29wdHNoKTsKKyAgICAgICBCVUdfT04ob2ggPT0gTlVMTCk7CisKKyAgICAgICBERUJVR1AoIklQdjYgT1BUUyBMRU4gJXUgJXUgIiwgaGRybGVuLCBvaC0+aGRybGVuKTsKKworICAgICAgIERFQlVHUCgibGVuICUwMlggJTA0WCAlMDJYICIsCisgICAgICAgCQlvcHRpbmZvLT5oZHJsZW4sIGhkcmxlbiwKKyAgICAgICAJCSghKG9wdGluZm8tPmZsYWdzICYgSVA2VF9PUFRTX0xFTikgfHwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICgob3B0aW5mby0+aGRybGVuID09IGhkcmxlbikgXgorICAgICAgICAgICAgICAgICAgICAgICAgICAgISEob3B0aW5mby0+aW52ZmxhZ3MgJiBJUDZUX09QVFNfSU5WX0xFTikpKSk7CisKKyAgICAgICByZXQgPSAob2ggIT0gTlVMTCkKKyAgICAgICAJCSYmCisJICAgICAgCSghKG9wdGluZm8tPmZsYWdzICYgSVA2VF9PUFRTX0xFTikgfHwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICgob3B0aW5mby0+aGRybGVuID09IGhkcmxlbikgXgorICAgICAgICAgICAgICAgICAgICAgICAgICAgISEob3B0aW5mby0+aW52ZmxhZ3MgJiBJUDZUX09QVFNfSU5WX0xFTikpKTsKKworICAgICAgIHB0ciArPSAyOworICAgICAgIGhkcmxlbiAtPSAyOworICAgICAgIGlmICggIShvcHRpbmZvLT5mbGFncyAmIElQNlRfT1BUU19PUFRTKSApeworCSAgICAgICByZXR1cm4gcmV0OworCX0gZWxzZSBpZiAob3B0aW5mby0+ZmxhZ3MgJiBJUDZUX09QVFNfTlNUUklDVCkgeworCQlERUJVR1AoIk5vdCBzdHJpY3QgLSBub3QgaW1wbGVtZW50ZWQiKTsKKwl9IGVsc2UgeworCQlERUJVR1AoIlN0cm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ZXh0aGRyID09IE5FWFRIRFJfTk9ORSkgeworCQkJdGVtcCB8PSBNQVNLX05PTkU7CisJCQlicmVhazsKKwkJfQorCQkvKiBFU1AgLT4gZXZhbHVhdGUgKi8KKyAgICAgICAgICAgICAgICBpZiAobmV4dGhkciA9PSBORVhUSERSX0VTUCkgeworCQkJdGVtcCB8PSBNQVNLX0VTUDsKKwkJCWJyZWFrOworCQl9CisKKwkJaHAgPSBza2JfaGVhZGVyX3BvaW50ZXIoc2tiLCBwdHIsIHNpemVvZihfaGRyKSwgJl9oZHIpOworCQlCVUdfT04oaHAgPT0gTlVMTCk7CisKKwkJLyogQ2FsY3VsYXRlIHRoZSBoZWFkZXIgbGVuZ3RoICovCisgICAgICAgICAgICAgICAgaWYgKG5leHRoZHIgPT0gTkVYVEhEUl9GUkFHTUVOVCkgeworICAgICAgICAgICAgICAgICAgICAgICAgaGRybGVuID0gODsKKyAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKG5leHRoZHIgPT0gTkVYVEhEUl9BVVRIKQorICAgICAgICAgICAgICAgICAgICAgICAgaGRybGVuID0gKGhwLT5oZHJsZW4rMik8PDI7CisgICAgICAgICAgICAgICAgZWxzZQorICAgICAgICAgICAgICAgICAgICAgICAgaGRybGVuID0gaXB2Nl9vcHRsZW4oaHApOworCisJCS8qIHNldCB0aGUgZmxhZyAqLworCQlzd2l0Y2ggKG5leHRoZHIpeworCQkJY2FzZSBORVhUSERSX0hPUDoKKwkJCQl0ZW1wIHw9IE1BU0tfSE9QT1BUUzsKKwkJCQlicmVhazsKKwkJCWNhc2UgTkVYVEhEUl9ST1VUSU5HOgorCQkJCXRlbXAgfD0gTUFTS19ST1VUSU5HOworCQkJCWJyZWFrOworCQkJY2FzZSBORVhUSERSX0ZSQUdNRU5UOgorCQkJCXRlbXAgfD0gTUFTS19GUkFHTUVOVDsKKwkJCQlicmVhazsKKwkJCWNhc2UgTkVYVEhEUl9BVVRIOgorCQkJCXRlbXAgfD0gTUFTS19BSDsKKw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WlmKChza2ItPnNrLT5za19zb2NrZXQtPmZpbGUtPmZfdWlkICE9IGluZm8tPnVpZCkgXgorCQkgICAgISEoaW5mby0+aW52ZXJ0ICYgSVA2VF9PV05FUl9VSUQpKQorCQkJcmV0dXJuIDA7CisJfQorCisJaWYoaW5mby0+bWF0Y2ggJiBJUDZUX09XTkVSX0dJRCkgeworCQlpZigoc2tiLT5zay0+c2tfc29ja2V0LT5maWxlLT5mX2dpZCAhPSBpbmZvLT5naWQpIF4KKwkJICAgICEhKGluZm8tPmludmVydCAmIElQNlRfT1dORVJfR0lEKSkKKwkJCXJldHVybiAwOworCX0KKworCWlmKGluZm8tPm1hdGNoICYgSVA2VF9PV05FUl9QSUQpIHsKKwkJaWYgKCFtYXRjaF9waWQoc2tiLCBpbmZvLT5waWQpIF4KKwkJICAgICEhKGluZm8tPmludmVydCAmIElQNlRfT1dORVJfUElEKSkKKwkJCXJldHVybiAwOworCX0KKworCWlmKGluZm8tPm1hdGNoICYgSVA2VF9PV05FUl9TSUQpIHsKKwkJaWYgKCFtYXRjaF9zaWQoc2tiLCBpbmZvLT5zaWQpIF4KKwkJICAgICEhKGluZm8tPmludmVydCAmIElQNlRfT1dORVJfU0lEKSkKKwkJCXJldHVybiAwOworCX0KKworCXJldHVybiAxOworfQorCitzdGF0aWMgaW50CitjaGVja2VudHJ5KGNvbnN0IGNoYXIgKnRhYmxlbmFtZSwKKyAgICAgICAgICAgY29uc3Qgc3RydWN0IGlwNnRfaXA2ICppcCwKKyAgICAgICAgICAgdm9pZCAqbWF0Y2hpbmZvLAorICAgICAgICAgICB1bnNpZ25lZCBpbnQgbWF0Y2hzaXplLAorICAgICAgICAgICB1bnNpZ25lZCBpbnQgaG9va19tYXNrKQoreworICAgICAgICBpZiAoaG9va19tYXNrCisgICAgICAgICAgICAmIH4oKDEgPDwgTkZfSVA2X0xPQ0FMX09VVCkgfCAoMSA8PCBORl9JUDZfUE9TVF9ST1VUSU5HKSkpIHsKKyAgICAgICAgICAgICAg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bnN0IHN0cnVjdCBza19idWZmICpza2IsCisgICAgICBjb25zdCBzdHJ1Y3QgbmV0X2RldmljZSAqaW4sCisgICAgICBjb25zdCBzdHJ1Y3QgbmV0X2RldmljZSAqb3V0LAorICAgICAgY29uc3Qgdm9pZCAqbWF0Y2hpbmZvLAorICAgICAgaW50IG9mZnNldCwKKyAgICAgIHVuc2lnbmVkIGludCBwcm90b2ZmLAorICAgICAgaW50ICpob3Rkcm9wKQoreworICAgICAgIHN0cnVjdCBpcHY2X3J0X2hkciBfcm91dGUsICpyaCA9IE5VTEw7CisgICAgICAgY29uc3Qgc3RydWN0IGlwNnRfcnQgKnJ0aW5mbyA9IG1hdGNoaW5mbzsKKyAgICAgICB1bnNpZ25lZCBpbnQgdGVtcDsKKyAgICAgICB1bnNpZ25lZCBpbnQgbGVuOworICAgICAgIHU4IG5leHRoZHI7CisgICAgICAgdW5zaWduZWQgaW50IHB0cjsKKyAgICAgICB1bnNpZ25lZCBpbnQgaGRybGVuID0gMDsKKyAgICAgICB1bnNpZ25lZCBpbnQgcmV0ID0gMDsKKyAgICAgICBzdHJ1Y3QgaW42X2FkZHIgKmFwLCBfYWRkcjsKKworICAgICAgIC8qIHR5cGUgb2YgdGhlIDFzdCBleHRoZHIgKi8KKyAgICAgICBuZXh0aGRyID0gc2tiLT5uaC5pcHY2aC0+bmV4dGhkcjsKKyAgICAgICAvKiBwb2ludGVyIHRvIHRoZSAxc3QgZXh0aGRyICovCisgICAgICAgcHRyID0gc2l6ZW9mKHN0cnVjdCBpcHY2aGRyKTsKKyAgICAgICAvKiBhdmFpbGFibGUgbGVuZ3RoICovCisgICAgICAgbGVuID0gc2tiLT5sZW4gLSBwdHI7CisgICAgICAgdGVtcCA9IDA7CisKKyAgICAgICAgd2hpbGUgKGlwNnRfZXh0X2hkcihuZXh0aGRyKSkgeworICAgICAgICAgICAgICAgc3RydWN0IGlwdjZfb3B0X2hkciBfaGRyLCAqaHA7CisKKyAgICAgICAgICAgICAgREVCVUdQKCJpcHY2X3J0IGhlYWRlciBpdGVyYXRpb24gXG4iKTsKKworICAgICAgICAgICAgICAvKiBJcyB0aGVyZSBlbm91Z2ggc3BhY2UgZm9yIHRoZSBuZXh0IGV4dCBoZWFkZXI/ICovCisgICAgICAgICAgICAgICAgaWYgKGxlbiA8IChpbnQpc2l6ZW9mKHN0cnVjdCBpcHY2X29wdF9oZHIpKQorICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIDA7CisgICAgICAgICAgICAgIC8qIE5vIG1vcmUgZXh0aGRyIC0+IGV2YWx1YXRlICovCisgICAgICAgICAgICAgICAgaWYgKG5leHRoZHIgPT0gTkVYVEhEUl9OT05FKSB7CisgICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAvKiBFU1AgLT4gZXZhbHVhdGUgKi8KKyAgICAgICAgICAgICAgICBpZiAobmV4dGhkciA9PSBORVhUSERSX0VTUCkgeworICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgIH0KKworCSAgICAgIGhwID0gc2tiX2hlYWRlcl9wb2ludGVyKHNrYiwgcHRyLCBzaXplb2YoX2hkciksICZfaGRyKTsKKwkgICAgICBCVUdfT04oaHAgPT0gTlVMTCk7CisKKyAgICAgICAgICAgICAgLyogQ2FsY3VsYXRlIHRoZSBoZWFkZXIgbGVuZ3RoICovCisgICAgICAgICAgICAgICAgaWYgKG5leHRoZHIgPT0gTkVYVEhEUl9GUkFHTUVOVCkgeworICAgICAgICAgICAgICAgICAgICAgICAgaGRybGVuID0gODsKKyAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKG5leHRoZHIgPT0gTkVYVEhEUl9BVVRIKQorICAgICAgICAgICAgICAgICAgICAgICAgaGRybGVuID0gKGhwLT5oZHJsZW4rMik8PDI7CisgICAgICAgICAgICAgICAgZWxzZQorICAgICAgICAgICAgICAgICAgICAgICAgaGRybGVuID0gaXB2Nl9vcHRsZW4oaHApOworCisgICAgICAgICAgICAgIC8qIFJPVVRJTkcgLT4gZXZhbHVhdGUgKi8KKyAgICAgICAgICAgICAgICBpZiAobmV4dGhkciA9PSBORVhUSERSX1JPVVRJTkcpIHsKKyAgICAgICAgICAgICAgICAgICAgIHRlbXAgfD0gTUFTS19ST1VUSU5HOworICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgIH0KKworCisgICAgICAgICAgICAgIC8qIHNldCB0aGUgZmxhZyAqLworICAgICAgICAgICAgICBzd2l0Y2ggKG5leHRoZHIpeworICAgICAgICAgICAgICAgICAgICAgY2FzZSBORVhUSERSX0hPUDoKKyAgICAgICAgICAgICAgICAgICAgIGNhc2UgTkVYVEhEUl9ST1VUSU5HOgorICAgICAgICAgICAgICAgICAgICAgY2FzZSBORVhUSERSX0ZSQUdNRU5UOgorICAgICAgICAgICAgICAgICAgICAgY2FzZSBORVhUSERSX0FVVEg6CisgICAgICAgICAgICAgICAgICAgICBjYXNlIE5FWFRIRFJfREVTVDoKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgREVCVUdQKCJpcHY2X3J0IG1hdGNoOiB1bmtub3duIG5leHRoZWFkZXIgJXVcbiIsbmV4dGhkcik7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIDA7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgIH0KKworICAgICAgICAgICAgICAgIG5leHRoZHIgPSBocC0+bmV4dGhkcjsKKyAgICAgICAgICAgICAgICBsZW4gLT0gaGRybGVuOworICAgICAgICAgICAgICAgIHB0ciArPSBoZHJsZW47CisJCWlmICggcHRyID4gc2tiLT5sZW4gKSB7CisJCQlERUJVR1AoImlwdjZfcnQ6IG5ldyBwb2ludGVyIGlzIHRvbyBsYXJnZSEgXG4iKTsKKwkJCWJyZWFrOworCQl9CisgICAgICAgIH0KKworICAgICAgIC8qIFJPVVRJTkcgaGVhZGVyIG5vdCBmb3VuZCAqLworICAgICAgIGlmICggdGVtcCAhPSBNQVNLX1JPVVRJTkcgKSByZXR1cm4gMDsKKworICAgICAgIGlmIChsZW4gPCAoaW50KXNpemVvZihzdHJ1Y3QgaXB2Nl9ydF9oZHIpKXsKKwkgICAgICAgKmhvdGRyb3AgPSAxOworICAgICAgIAkJcmV0dXJuIDA7CisgICAgICAgfQorCisgICAgICAgaWYgKGxlbiA8IGhkcmxlbil7CisJICAgICAgIC8qIFBja2V0IHNtYWxsZXIgdGhhbiBpdHMgbGVuZ3RoIGZpZWxkICovCisgICAgICAgCQlyZXR1cm4gMDsKKyAgICAgICB9CisKKyAgICAgICByaCA9IHNrYl9oZWFkZXJfcG9pbnRlcihza2IsIHB0ciwgc2l6ZW9mKF9yb3V0ZSksICZfcm91dGUpOworICAgICAgIEJVR19PTihyaCA9PSBOVUxMKTsKKworICAgICAgIERFQlVHUCgiSVB2NiBSVCBMRU4gJXUgJXUgIiwgaGRybGVuLCByaC0+aGRybGVuKTsKKyAgICAgICBERUJVR1AoIlRZUEUgJTA0WCAiLCByaC0+dHlwZSk7CisgICAgICAgREVCVUdQKCJTR1NfTEVGVCAldSAlMDJYXG4iLCByaC0+c2VnbWVudHNfbGVmdCwgcmgtPnNlZ21lbnRzX2xlZnQpOworCisgICAgICAgREVCVUdQKCJJUHY2IFJUIHNlZ3NsZWZ0ICUwMlggIiwKKyAgICAgICAJCShzZWdzbGVmdF9tYXRjaChydGluZm8tPnNlZ3NsZWZ0WzBdLCBydGluZm8tPnNlZ3NsZWZ0WzFdLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgcmgtPnNlZ21lbnRzX2xlZnQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAhIShydGluZm8tPmludmZsYWdzICYgSVA2VF9SVF9JTlZfU0dTKSkpKTsKKyAgICAgICBERUJVR1AoInR5cGUgJTAyWCAlMDJYICUwMlggIiwKKyAgICAgICAJCXJ0aW5mby0+cnRfdHlwZSwgcmgtPnR5cGUsIAorICAgICAgIAkJKCEocnRpbmZvLT5mbGFncyAmIElQNlRfUlRfVFlQKSB8fAorICAgICAgICAgICAgICAgICAgICAgICAgICAgKChydGluZm8tPnJ0X3R5cGUgPT0gcmgtPnR5cGUpIF4KKyAgICAgICAgICAgICAgICAgICAgICAgICAgICEhKHJ0aW5mby0+aW52ZmxhZ3MgJiBJUDZUX1JUX0lOVl9UWVApKSkpOworICAgICAgIERFQlVHUCgibGVuICUwMlggJTA0WCAlMDJYICIsCisgICAgICAgCQlydGluZm8tPmhkcmxlbiwgaGRybGVuLAorICAgICAgIAkJKCEocnRpbmZvLT5mbGFncyAmIElQNlRfUlRfTEVOKSB8fAorICAgICAgICAgICAgICAgICAgICAgICAgICAgKChydGluZm8tPmhkcmxlbiA9PSBoZHJsZW4pIF4KKyAgICAgICAgICAgICAgICAgICAgICAgICAgICEhKHJ0aW5mby0+aW52ZmxhZ3MgJiBJUDZUX1JUX0lOVl9MRU4pKSkpOworICAgICAgIERFQlVHUCgicmVzICUwMlggJTAyWCAlMDJYICIsIAorICAgICAgIAkJKHJ0aW5mby0+ZmxhZ3MgJiBJUDZUX1JUX1JFUyksICgoc3RydWN0IHJ0MF9oZHIgKilyaCktPmJpdG1hcCwKKyAgICAgICAJCSEoKHJ0aW5mby0+ZmxhZ3MgJiBJUDZUX1JUX1JFUykgJiYgKCgoc3RydWN0IHJ0MF9oZHIgKilyaCktPmJpdG1hcCkpKTsKKworICAgICAgIHJldCA9IChyaCAhPSBOVUxMKQorICAgICAgIAkJJiYKKyAgICAgICAJCShzZWdzbGVmdF9tYXRjaChydGluZm8tPnNlZ3NsZWZ0WzBdLCBydGluZm8tPnNlZ3NsZWZ0WzFdLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgcmgtPnNlZ21lbnRzX2xlZnQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAhIShydGluZm8tPmludmZsYW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VjdCBpcDZ0X3J0KSkpIHsKKyAgICAgICAgICAgICAgREVCVUdQKCJpcDZ0X3J0OiBtYXRjaHNpemUgJXUgIT0gJXVcbiIsCisgICAgICAgICAgICAgICAgICAgICAgbWF0Y2hpbmZvc2l6ZSwgSVA2VF9BTElHTihzaXplb2Yoc3RydWN0IGlwNnRfcnQpKSk7CisgICAgICAgICAgICAgIHJldHVybiAwOworICAgICAgIH0KKyAgICAgICBpZiAocnRpbmZvLT5pbnZmbGFncyAmIH5JUDZUX1JUX0lOVl9NQVNLKSB7CisgICAgICAgICAgICAgIERFQlVHUCgiaXA2dF9ydDogdW5rbm93biBmbGFncyAlWFxuIiwKKyAgICAgICAgICAgICAgICAgICAgICBydGluZm8tPmludmZsYWdzKTsKKyAgICAgICAgICAgICAgcmV0dXJuIDA7CisgICAgICAgfQorICAgICAgIGlmICggKHJ0aW5mby0+ZmxhZ3MgJiAoSVA2VF9SVF9SRVN8SVA2VF9SVF9GU1RfTUFTSykpICYmIAorCQkgICAgICAgKCEocnRpbmZvLT5mbGFncyAmIElQNlRfUlRfVFlQKSB8fCAKKwkJICAgICAgIChydGluZm8tPnJ0X3R5cGUgIT0gMCkgfHwgCisJCSAgICAgICAocnRpbmZvLT5pbnZmbGFncyAmIElQNlRfUlRfSU5WX1RZUCkpICkgeworCSAgICAgIERFQlVHUCgiYC0tcnQtdHlwZSAwJyByZXF1aXJlZCBiZWZvcmUgYC0tcnQtMC0qJyIpOworICAgICAgICAgICAgICByZXR1cm4gMDsKKyAgICAgICB9CisKKyAgICAgICByZXR1cm4gMTsKK30KKworc3RhdGljIHN0cnVjdCBpcDZ0X21hdGNoIHJ0X21hdGNoID0geworCS5uYW1lCQk9ICJydCIsCisJLm1hdGNoCQk9ICZtYXRjaCwKKwkuY2hlY2tlbnRyeQk9ICZjaGVja2VudHJ5LAorCS5tZQkJPSBUSElTX01PRFVMRSwKK307CisKK3N0YXRpYyBpbnQgX19pbml0IGluaXQodm9pZCkKK3sKKyAgICAgIC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KwkJZWxzZQorCQkJdmFsID0gcnAtPm9mZnNldDsKKwkJYnJlYWs7CisKKwlkZWZhdWx0OgorCQlyZXR1cm4gLUVOT1BST1RPT1BUOworCX0KKworCWxlbiA9IG1pbl90KHVuc2lnbmVkIGludCwgc2l6ZW9mKGludCksIGxlbik7CisKKwlpZiAocHV0X3VzZXIobGVuLCBvcHRsZW4pKQorCQlyZXR1cm4gLUVGQVVMVDsKKwlpZiAoY29weV90b191c2VyKG9wdHZhbCwmdmFsLGxlbikpCisJCXJldHVybiAtRUZBVUxUOworCXJldHVybiAwOworfQorCitzdGF0aWMgaW50IHJhd3Y2X2lvY3RsKHN0cnVjdCBzb2NrICpzaywgaW50IGNtZCwgdW5zaWduZWQgbG9uZyBhcmcpCit7CisJc3dpdGNoKGNtZCkgeworCQljYXNlIFNJT0NPVVRROgorCQl7CisJCQlpbnQgYW1vdW50ID0gYXRvbWljX3JlYWQoJnNrLT5za193bWVtX2FsbG9jKTsKKwkJCXJldHVybiBwdXRfdXNlcihhbW91bnQsIChpbnQgX191c2VyICopYXJnKTsKKwkJfQorCQljYXNlIFNJT0NJTlE6CisJCXsKKwkJCXN0cnVjdCBza19idWZmICpza2I7CisJCQlpbnQgYW1vdW50ID0gMDsKKworCQkJc3Bpbl9sb2NrX2lycSgmc2stPnNrX3JlY2VpdmVfcXVldWUubG9jayk7CisJCQlza2IgPSBza2JfcGVlaygmc2stPnNrX3JlY2VpdmVfcXVldWUpOworCQkJaWYgKHNrYiAhPSBOVUxMKQorCQkJCWFtb3VudCA9IHNrYi0+dGFpbCAtIHNrYi0+aC5yYXc7CisJCQlzcGluX3VubG9ja19pcnEoJnNrLT5za19yZWNlaXZlX3F1ZXVlLmxvY2spOworCQkJcmV0dXJuIHB1dF91c2VyKGFtb3VudCwgKGludCBfX3VzZXIgKilhcmcpOworCQl9CisKKwkJZGVmYXVsdDoKKwkJCXJldHVybiAtRU5PSU9DVExDTUQ7CisJfQorfQorCitzdGF0aWMgdm9pZCByYXd2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