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MDY0NAppbmRleCAwMDAwMDAwLi4wNjgwNGQzCi0tLSAvZGV2L251bGwKKysrIGIvZHJpdmVycy9zMzkwL25ldC9jbGF3LmMKQEAgLTAsMCArMSw0NDQ3IEBACisvKgorICogIGRyaXZlcnMvczM5MC9uZXQvY2xhdy5jCisgKiAgICBFU0NPTiBDTEFXIG5ldHdvcmsgZHJpdmVyCisgKgorICogICAgJFJldmlzaW9uOiAxLjM1ICQgJERhdGU6IDIwMDUvMDMvMjQgMTI6MjU6MzggJAorICoKKyAqICBMaW51eCBmbyB6U2VyaWVzIHZlcnNpb24KKyAqICAgIENvcHlyaWdodCAoQykgMjAwMiwyMDA1IElCTSBDb3Jwb3JhdGlvbgorICogIEF1dGhvcihzKSBPcmlnaW5hbCBjb2RlIHdyaXR0ZW4gYnk6CisgKiAgICAgICAgICAgICAgS2F6dW8gSWltdXJhIChpaW11cmFAanAuaWJtLmNvbSkKKyAqICAgCSAgICAgIFJld3JpdHRlbiBieQorICogICAgICAgICAgICAgIEFuZHkgUmljaHRlciAocmljaHRlcmFAdXMuaWJtLmNvbSkKKyAqICAgICAgICAgICAgICBNYXJjIFByaWNlIChtd3ByaWNlQHVzLmlibS5jb20pCisgKgorICogICAgc3lzZnMgcGFybXM6CisgKiAgIGdyb3VwIHgueC5ycnJyLHgueC53d3d3CisgKiAgIHJlYWRfYnVmZmVyIG5ubm5ubm4KKyAqICAgd3JpdGVfYnVmZmVyIG5ubm5ubgorICogICBob3N0X25hbWUgIGFhYWFhYWFhCisgKiAgIGFkYXB0ZXJfbmFtZSBhYWFhYWFhYQorICogICBhcGlfdHlwZSAgICBhYWFhYWFhYQorICoKKyAqICBlZy4KKyAqICAgZ3JvdXAgIDAuMC4wMjAwIDAuMC4wMjAxCisgKiAgIHJlYWRfYnVmZmVyIDI1CisgKiAgIHdyaXRlX2J1ZmZlciAyMAorICogICBob3N0X25hbWUgTElOVVgzOTAKKyAqICAgYWRhcHRlcl9uYW1lIFJTNksKKyAqICAgYXBpX3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JpdCgwLCAmKCgoc3RydWN0IGNsYXdfcHJpdmJrICopIGRldi0+cHJpdiktPnRidXN5KSk7CisJbmV0aWZfd2FrZV9xdWV1ZShkZXYpOworCWVpZWlvKCk7Cit9CisKK3N0YXRpYyBpbmxpbmUgaW50CitjbGF3X2NoZWNrX2J1c3koc3RydWN0IG5ldF9kZXZpY2UgKmRldikKK3sKKwllaWVpbygpOworCXJldHVybiAoKHN0cnVjdCBjbGF3X3ByaXZiayAqKSBkZXYtPnByaXYpLT50YnVzeTsKK30KKworc3RhdGljIGlubGluZSB2b2lkCitjbGF3X3NldGJpdF9idXN5KGludCBucixzdHJ1Y3QgbmV0X2RldmljZSAqZGV2KQoreworCW5ldGlmX3N0b3BfcXVldWUoZGV2KTsKKyAJc2V0X2JpdChuciwgKHZvaWQgKikmKCgoc3RydWN0IGNsYXdfcHJpdmJrICopZGV2LT5wcml2KS0+dGJ1c3kpKTsKK30KKworc3RhdGljIGlubGluZSB2b2lkCitjbGF3X2NsZWFyYml0X2J1c3koaW50IG5yLHN0cnVjdCBuZXRfZGV2aWNlICpkZXYpCit7CisgCWNsZWFyX2JpdChuciwodm9pZCAqKSYoKChzdHJ1Y3QgY2xhd19wcml2YmsgKilkZXYtPnByaXYpLT50YnVzeSkpOworCW5ldGlmX3dha2VfcXVldWUoZGV2KTsKK30KKworc3RhdGljIGlubGluZSBpbnQKK2NsYXdfdGVzdF9hbmRfc2V0Yml0X2J1c3koaW50IG5yLHN0cnVjdCBuZXRfZGV2aWNlICpkZXYpCit7CisJbmV0aWZfc3RvcF9xdWV1ZShkZXYpOworCXJldHVybiB0ZXN0X2FuZF9zZXRfYml0KG5yLAorIAkJKHZvaWQgKikmKCgoc3RydWN0IGNsYXdfcHJpdmJrICopIGRldi0+cHJpdiktPnRidXN5KSk7Cit9CisKKworLyogRnVuY3Rpb25zIGZvciB0aGUgREVWIG1ldGhvZHMgKi8KKworc3RhdGljIGludCBjbGF3X3Byb2JlKHN0cnVjdCBjY3dncm91cF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IG5ldF9kZXZpY2UgKmRldiApOworCisvKiBGdW5jdGlvbnMgZm9yIHVucGFjayByZWFkcyAgICovCitzdGF0aWMgdm9pZCB1bnBhY2tfcmVhZCAoc3RydWN0IG5ldF9kZXZpY2UgKmRldiApOworCisvKiBjY3dncm91cCB0YWJsZSAgKi8KKworc3RhdGljIHN0cnVjdCBjY3dncm91cF9kcml2ZXIgY2xhd19ncm91cF9kcml2ZXIgPSB7CisgICAgICAgIC5vd25lciAgICAgICA9IFRISVNfTU9EVUxFLAorICAgICAgICAubmFtZSAgICAgICAgPSAiY2xhdyIsCisgICAgICAgIC5tYXhfc2xhdmVzICA9IDIsCisgICAgICAgIC5kcml2ZXJfaWQgICA9IDB4QzNEM0MxRTYsCisgICAgICAgIC5wcm9iZSAgICAgICA9IGNsYXdfcHJvYmUsCisgICAgICAgIC5yZW1vdmUgICAgICA9IGNsYXdfcmVtb3ZlX2RldmljZSwKKyAgICAgICAgLnNldF9vbmxpbmUgID0gY2xhd19uZXdfZGV2aWNlLAorICAgICAgICAuc2V0X29mZmxpbmUgPSBjbGF3X3NodXRkb3duX2RldmljZSwKK307CisKKy8qCisqCisqICAgICAgIEtleSBmdW5jdGlvbnMKKyovCisKKy8qLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSoKKyAqICAgY2xhd19wcm9iZSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICoKKyAqICAgICAgdGhpcyBmdW5jdGlvbiBpcyBjYWxsZWQgZm9yIGVhY2ggQ0xBVyBkZXZpY2UuICAgICAgICAgICAgICoKKyAqLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSovCitzdGF0aWMgaW50CitjbGF3X3Byb2JlKHN0cnVjdCBjY3dncm91cF9kZXZpY2U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mhlbGRfc2tiLT51c2Vycyk7CisJCQkJc2tiX3F1ZXVlX2hlYWQoJnBfY2gtPmNvbGxlY3RfcXVldWUsaGVsZF9za2IpOworCQkJfQorCQl9CisjaWZkZWYgSU9UUkFDRQorCQlwcmludGsoS0VSTl9JTkZPICIlczogJXMoKSBQYWNrZWQgJWQgbGVuICVkXG4iLAorCQkJcF9lbnYtPm5kZXYtPm5hbWUsCisJCQlfX0ZVTkNUSU9OX18scGt0X2NudCxuZXdfc2tiLT5sZW4pOworI2VuZGlmCisJfQorCUNMQVdfREJGX1RFWFQoNCx0cmFjZSwiUGFja1NLQngiKTsKKwlyZXR1cm4gbmV3X3NrYjsKK30KKworLyotLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKgorICogICBjbGF3X2NoYW5nZV9tdHUgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKgorICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKgorICotLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKi8KKworc3RhdGljIGludAorY2xhd19jaGFuZ2VfbXR1KHN0cnVjdCBuZXRfZGV2aWNlICpkZXYsIGludCBuZXdfbXR1KQoreworCXN0cnVjdCBjbGF3X3ByaXZiayAgKnByaXZwdHI9ZGV2LT5wcml2OworCWludCBidWZmX3NpemU7CisjaWZkZWYgRlVOQ1RSQUNFCisgICAgICAgIHByaW50ayhLRVJOX0lORk8gIiVzOiVzIEVudGVyICBcbiIsZGV2LT5uYW1lLF9fRlVOQ1RJT05fXyk7CisjZW5kaWYKKyNpZmRlZiBERUJVR01TRworICAgICAgICBwcmludGsoS0VSTl9JTkZPICJ2YXJpYWJsZSBkZXYgPVxuIik7CisgICAgICAgIGR1bXBpdCgoY2hhciAqKSBkZXYsIHNpemVvZihzdHJ1Y3QgbmV0X2RldmljZSkpOworICAgICAgICBwcmludGsoS0VSTl9JTkZPICJ2YXJpYWJsZSBuZXdfbXR1ID0gJWRcbiIsIG5ld19tdHUpOworI2VuZGlmCisJQ0xBV19EQkZfVEVYVCg0LHRyYWNlLCJzZXRtdHUiKTsKKwlidWZmX3NpemUgPSBwcml2cHRyLT5wX2Vudi0+d3JpdGVfc2l6ZTsKKyAgICAgICAgaWYgKChuZXdfbXR1IDwgNjApIHx8IChuZXdfbXR1ID4gYnVmZl9zaXplKSkgeworI2lmZGVmIEZVTkNUUkFDRQorICAgICAgICAgICAgICAgIHByaW50ayhLRVJOX0lORk8gIiVzOiVzIEV4aXQgb24gbGluZSAlZCwgcmM9RUlOVkFMXG4iLAorCQlkZXYtPm5hbWUsCisJCV9fRlVOQ1RJT05fXywgX19MSU5FX18pOworI2VuZGlmCisgICAgICAgICAgICAgICAgcmV0dXJuIC1FSU5WQUw7CisgICAgICAgIH0KKyAgICAgICAgZGV2LT5tdHUgPSBuZXdfbXR1OworI2lmZGVmIEZVTkNUUkFDRQorICAgICAgICBwcmludGsoS0VSTl9JTkZPICIlczolcyBFeGl0IG9uIGxpbmUgJWRcbiIsZGV2LT5uYW1lLAorCV9fRlVOQ1RJT05fXywgX19MSU5FX18pOworI2VuZGlmCisgICAgICAgIHJldHVybiAwOworfSAgLyogICBlbmQgb2YgY2xhd19jaGFuZ2VfbXR1ICovCisKKworLyotLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKgorICogICBjbGF3X29wZW4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKgorICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg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DTEFXX0RCRl9URVhUXygyLHRyYWNlLCJvcG5fY2glZCIsaSk7CisgICAgICAgICAgICAgICAgaW5pdF93YWl0cXVldWVfaGVhZCgmcHJpdnB0ci0+Y2hhbm5lbFtpXS53YWl0KTsKKwkJLyogc2tiX3F1ZXVlX2hlYWRfaW5pdCgmcF9jaC0+aW9fcXVldWUpOyAqLworCQlpZiAoaSA9PSBXUklURSkKKwkJCXNrYl9xdWV1ZV9oZWFkX2luaXQoCisJCQkJJnByaXZwdHItPmNoYW5uZWxbV1JJVEVdLmNvbGxlY3RfcXVldWUpOworICAgICAgICAgICAgICAgIHByaXZwdHItPmNoYW5uZWxbaV0uZmxhZ19hID0gMDsKKyAgICAgICAgICAgICAgICBwcml2cHRyLT5jaGFubmVsW2ldLklPX2FjdGl2ZSA9IDA7CisgICAgICAgICAgICAgICAgcHJpdnB0ci0+Y2hhbm5lbFtpXS5mbGFnICAmPSB+Q0xBV19USU1FUjsKKyAgICAgICAgICAgICAgICBpbml0X3RpbWVyKCZ0aW1lcik7CisgICAgICAgICAgICAgICAgdGltZXIuZnVuY3Rpb24gPSAodm9pZCAqKWNsYXdfdGltZXI7CisgICAgICAgICAgICAgICAgdGltZXIuZGF0YSA9ICh1bnNpZ25lZCBsb25nKSgmcHJpdnB0ci0+Y2hhbm5lbFtpXSk7CisgICAgICAgICAgICAgICAgdGltZXIuZXhwaXJlcyA9IGppZmZpZXMgKyAxNSpIWjsKKyAgICAgICAgICAgICAgICBhZGRfdGltZXIoJnRpbWVyKTsKKyAgICAgICAgICAgICAgICBzcGluX2xvY2tfaXJxc2F2ZShnZXRfY2N3ZGV2X2xvY2soCisJCQlwcml2cHRyLT5jaGFubmVsW2ldLmNkZXYpLCBzYXZlZmxhZ3MpOworICAgICAgICAgICAgICAgIHBhcm0gPSAodW5zaWduZWQgbG9uZykgJnByaXZwdHItPmNoYW5uZWxbaV07CisgICAgICAgICAgICAgICAgcHJpdnB0ci0+Y2hhbm5lbFtpXS5jbGF3X3N0YXRlID0gQ0xBV19TVEFSVF9IQUxUX0lPOworCQlyYyA9IDA7CisJCWFkZF93YWl0X3F1ZXVlKCZwcml2cHRyLT5jaGFubmVsW2ldLndhaXQsICZ3YWl0KTsKKyAgICAgICAgICAgICAgICByYyA9IGNjd19kZXZpY2VfaGFsdCgKKwkJCShzdHJ1Y3QgY2N3X2RldmljZSAqKXByaXZwdHItPmNoYW5uZWxbaV0uY2RldixwYXJtKTsKKyAgICAgICAgICAgICAgICBzZXRfY3VycmVudF9zdGF0ZShUQVNLX0lOVEVSUlVQVElCTEUpOworICAgICAgICAgICAgICAgIHNwaW5fdW5sb2NrX2lycXJlc3RvcmUoCisJCQlnZXRfY2N3ZGV2X2xvY2socHJpdnB0ci0+Y2hhbm5lbFtpXS5jZGV2KSwgc2F2ZWZsYWdzKTsKKyAgICAgICAgICAgICAgICBzY2hlZHVsZSgpOworCQlzZXRfY3VycmVudF9zdGF0ZShUQVNLX1JVTk5JTkcpOworICAgICAgICAgICAgICAgIHJlbW92ZV93YWl0X3F1ZXVlKCZwcml2cHRyLT5jaGFubmVsW2ldLndhaXQsICZ3YWl0KTsKKyAgICAgICAgICAgICAgICBpZihyYyAhPSAwKQorICAgICAgICAgICAgICAgICAgICAgICAgY2N3X2NoZWNrX3JldHVybl9jb2RlKHByaXZwdHItPmNoYW5uZWxbaV0uY2RldiwgcmMpOworICAgICAgICAgICAgICAgIGlmKChwcml2cHRyLT5jaGFubmVsW2ldLmZsYWcgJiBDTEFXX1RJTUVSKSA9PSAweDAwKQorICAgICAgICAgICAgICAgICAgICAgICAgZGVsX3RpbWVyKCZ0aW1lcik7CisgICAgICAgIH0KKyAgICAgICAgaWYgKCgoKHByaXZwdHItPmNoYW5uZWxbUkVBRF0ubGFzdF9kc3RhdCB8CisJCXByaXZwdHItPmNoYW5uZWxbV1JJVEVdLmxhc3RfZHN0YXQpICYKKyAgICAgICAgICAgfihERVZfU1RBVF9DSE5fRU5EIHwgREVWX1NUQVRfREVWX0VORCkpICE9IDB4MDApIHx8CisgICAgICAgICAgICgoKHByaXZwdHItPmNoYW5uZWxbUkVBRF0uZmxhZyB8CisJICAgCXByaXZwdHItPmNoYW5uZWxbV1JJVEVdLmZsYWcpICYgQ0xBV19USU1FUikgIT0gMHgwMCkpIHsKKyNpZmRlZiBERUJVR01TRworICAgICAgICAgICAgICAgIHByaW50ayhLRVJOX0lORk8gIiVzOiBjaGFubmVsIHByb2JsZW1zIGR1cmluZyBvcGVuIC0gcmVhZDoiCisJCQkiICUwMnggLSAgd3JpdGU6ICUwMnhcbiIsCisgICAgICAgICAgICAgICAgICAgICAgICBkZXYtPm5hbWUsCisJCQlwcml2cHRyLT5jaGFubmVsW1JFQURdLmxhc3RfZHN0YXQsCisJCQlwcml2cHRyLT5jaGFubmVsW1dSSVRFXS5sYXN0X2RzdGF0KTsKKyNlbmRpZgorICAgICAgICAgICAgICAgIHByaW50ayhLRVJOX0lORk8gIiVzOiByZW1vdGUgc2lkZSBpcyBub3QgcmVhZHlcbiIsIGRldi0+bmFtZSk7CisJCUNMQVdfREJGX1RFWFQoMix0cmFjZSwibm90cmR5Iik7CisKKyAgICAgICAgICAgICAgICBmb3IgKCBpID0gMDsgaSA8IDI7ICBpKyspIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIHNwaW5fbG9ja19pcnFzYXZlKAorCQkJCWdldF9jY3dkZXZfbG9jayhwcml2cHRyLT5jaGFubmVsW2ldLmNkZXYpLAorCQkJCXNhdmVmbGFncyk7CisgICAgICAgICAgICAgICAgICAgICAgICBwYXJtID0gKHVuc2lnbmVkIGxvbmcpICZwcml2cHRyLT5jaGFubmVsW2ldOworICAgICAgICAgICAgICAgICAgICAgICAgcHJpdnB0ci0+Y2hhbm5lbFtpXS5jbGF3X3N0YXRlID0gQ0xBV19TVE9QOworICAgICAgICAgICAgICAgICAgICAgICAgcmMgPSBjY3dfZGV2aWNlX2hhbHQoCisJCQkJKHN0cnVjdCBjY3dfZGV2aWNlICopJnByaXZwdHItPmNoYW5uZWxbaV0uY2RldiwKKwkJCQlwYXJtKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHNwaW5fdW5sb2NrX2lycXJlc3RvcmUoCisJCQkJZ2V0X2Njd2Rldl9sb2NrKHByaXZwdHItPmNoYW5uZWxbaV0uY2RldiksCisJCQkJc2F2ZWZsYWdzKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGlmIChyYyAhPSAwKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNjd19jaGVja19yZXR1cm5fY29kZSgKKwkJCQkJcHJpdnB0ci0+Y2hhbm5lbFtpXS5jZGV2LCByYyk7CisgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIGZyZWVfcGFnZXMoKHVuc2lnbmVkIGxvbmcpcHJpdnB0ci0+cF9idWZmX2NjdywKKwkJCShpbnQpcGFnZXNfdG9fb3JkZXJfb2ZfbWFnKHByaXZwdHItPnBfYnVmZl9jY3dfbnVtKSk7CisgICAgICAgICAgICAgICAgaWYgKHByaXZwdHItPnBfZW52LT5yZWFkX3NpemUgPCBQQUdFX1NJWkUpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIGZyZWVfcGFnZXMoKHVuc2lnbmVkIGxvbmcpcHJpdnB0ci0+cF9idWZmX3JlYWQsCisJCQkgICAgICAgKGludClwYWdlc190b19vcmRlcl9vZl9tYWcoCisJCQkgICAgICAgCQlwcml2cHRyLT5wX2J1ZmZfcmVhZF9udW0pKTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgZWxzZSB7CisgICAgICAgICAgICAgICAgICAgICAgICBwX2J1Zj1wcml2cHRyLT5wX3JlYWRfYWN0aXZlX2ZpcnN0OworICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKHBfYnVmIT1OVUxMKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZyZWVfcGFnZXMoKHVuc2lnbmVkIGxvbmcpcF9idWYtPnBfYnVmZmVyLAorCQkJCSAgICAgIChpbnQpcGFnZXNfdG9fb3JkZXJfb2ZfbWFnKAorCQkJCSAgICAgIAlwcml2cHRyLT5wX2J1ZmZfcGFnZXNfcGVycmVhZCApKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcF9idWY9cF9idWYtPm5leHQ7CisgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIGlmIChwcml2cHRyLT5wX2Vudi0+d3JpdGVfc2l6ZSA8IFBBR0VfU0laRSApIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIGZyZWVfcGFnZXMoKHVuc2lnbmVkIGxvbmcpcHJpdnB0ci0+cF9idWZmX3dyaXRlLAorCQkJICAgICAoaW50KXBhZ2VzX3RvX29yZGVyX29mX21hZygKKwkJCSAgICAgCXByaXZwdHItPnBfYnVmZl93cml0ZV9udW0pKTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgZWxzZSB7CisgICAgICAgICAgICAgICAgICAgICAgICBwX2J1Zj1wcml2cHRyLT5wX3dyaXRlX2FjdGl2ZV9maXJzdDsKKyAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlIChwX2J1ZiE9TlVMTCkgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmcmVlX3BhZ2VzKCh1bnNpZ25lZCBsb25nKXBfYnVmLT5wX2J1ZmZlciwKKwkJCQkgICAgIChpbnQpcGFnZXNfdG9fb3JkZXJfb2ZfbWFnKAorCQkJCSAgICAgCXByaXZwdHItPnBfYnVmZl9wYWdlc19wZXJ3cml0ZSApKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcF9idWY9cF9idWYtPm5leHQ7CisgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgfQorCQlwcml2cHRyLT5idWZmc19hbGxvYyA9IDA7CisJCXByaXZwdHItPmNoYW5uZWxbUkVBRF0uZmxhZz0gMHgwMDsKKwkJcHJpdnB0ci0+Y2hhbm5lbFtXUklURV0uZmxhZyA9IDB4MDA7CisgICAgICAgICAgICAgICAgcHJpdnB0ci0+cF9idWZmX2Njdz1OVUxMOworICAgICAgICAgICAgICAgIHByaXZwdHItPnBfYnVmZl9yZWFkPU5VTEw7CisgICAgICAgICAgICAgICAgcHJpdnB0ci0+cF9idWZmX3dyaXRlPU5VTEw7CisgICAgICAgICAgICAgICAgY2xhd19jbGVhcl9idXN5KGRldik7CisjaWZkZWYgRlVOQ1RSQUNFCisgICAgICAgICAgICAgICAgcHJpbnRrKEtFUk5fSU5GTyAiJXM6JXMgRXhpdCBvbiBsaW5lICVkLCByYz1FSU9cbiIsCisJCWRldi0+bmFtZSxfX0ZVTkNUSU9OX18sX19MSU5FX18pOworI2VuZGlmCisJCUNMQVdfREJGX1RFWFQoMix0cmFjZSwib3BlbiBFSU8iKTsKKyAgICAgICAgICAgICAgICByZXR1cm4gLUVJTzsKKyAgICAgICAgfQorCisgICAgICAgIC8qICAgU2VuZCBTeXN0ZW1WYWxpZGF0ZSBjb21tYW5kICovCisKKyAgICAgICAgY2xhd19jbGVhcl9idXN5KGRldik7CisKKyNpZmRlZiBGVU5DVFJBQ0UKKyAgICAgICAgcHJpbnRrKEtFUk5fSU5GTyAiJXM6JXMgRXhpdCBvbiBsaW5lICVkLCByYz0wXG4iLAorCQlkZXYtPm5hbWUsX19GVU5DVElPTl9fLF9fTElORV9fKTsKKyNlbmRpZgorCUNMQVdfREJGX1RFWFQoNCx0cmFjZSwib3Blbm9rIik7CisgICAgICAgIHJldHVybiAwOworfSAgICAvKiAgICAgZW5kIG9mIGNsYXdfb3BlbiAgICAqLworCisvKi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0qCisqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqCisqICAgICAgIGNsYXdfaXJxX2hhbmRsZXIgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqCisqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqCisqLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0qLworc3RhdGljIHZvaWQKK2NsYXdfaXJxX2hhbmRsZXIoc3RydWN0IGNjd19kZXZpY2UgKmNkZXYsCisJdW5zaWduZWQgbG9uZyBpbnRwYXJtLCBzdHJ1Y3QgaXJiICppcmIpCit7CisgICAgICAgIHN0cnVjdCBjaGJrICpwX2NoID0gTlVMTDsKKyAgICAgICAgc3RydWN0IGNsYXdfcHJpdmJrICpwcml2cHRyID0gTlVMTDsKKyAgICAgICAgc3RydWN0IG5ldF9kZXZpY2UgKmRldiA9IE5VTEw7CisgICAgICAgIHN0cnVjdCBjbGF3X2VudiAgKnBfZW52OworICAgICAgICBzdHJ1Y3QgY2hiayAqcF9jaF9yPU5VTEw7CisKKworI2lmZGVmIEZVTkNUUkFDRQorICAgICAgICBwcmludGsoS0VSTl9JTkZPICIlcyBlbnRlciAgXG4iLF9fRlVOQ1RJT05fXyk7CisjZW5kaWYKKwlDTEFXX0RCRl9URVhUKDQsdHJhY2UsImNsYXdpcnEiKTsKKyAgICAgICAgLyogQnlwYXNzIGFsbCAndW5zb2xpY2l0ZWQgaW50ZXJydXB0cycgKi8KKwlpZiAoIWNkZXYtPmRldi5kcml2ZXJfZGF0YSkgeworICAgICAgICAgICAgICAgIHByaW50ayhLRVJOX1dBUk5JTkcgImNsYXc6IHVuc29saWNpdGVkIGludGVycnVwdCBmb3IgZGV2aWNlOiIKKwkJIAkiJXMgcmVjZWl2ZWQgYy0lMDJ4IGQtJTAyeFxuIiwKKyAgICAgIC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aWYKKyNpZmRlZiBGVU5DVFJBQ0UKKwkJcHJpbnRrKEtFUk5fSU5GTyAiJXM6JXMgRXhpdCBvbiBsaW5lICVkXG4iLAorCQlkZXYtPm5hbWUsX19GVU5DVElPTl9fLF9fTElORV9fKTsKKyNlbmRpZgorCQlDTEFXX0RCRl9URVhUKDIsdHJhY2UsImNoYW5jaGsiKTsKKyAgICAgICAgICAgICAgICAvKiByZXR1cm47ICovCisgICAgICAgIH0KKworICAgICAgICAvKiBDaGVjayB0aGUgcmVhc29uLWNvZGUgb2YgYSB1bml0IGNoZWNrICovCisgICAgICAgIGlmIChpcmItPnNjc3cuZHN0YXQgJiBERVZfU1RBVF9VTklUX0NIRUNLKSB7CisgICAgICAgICAgICAgICAgY2N3X2NoZWNrX3VuaXRfY2hlY2socF9jaCwgaXJiLT5lY3dbMF0pOworICAgICAgICB9CisKKyAgICAgICAgLyogU3RhdGUgbWFjaGluZSB0byBicmluZyB0aGUgY29ubmVjdGlvbiB1cCwgZG93biBhbmQgdG8gcmVzdGFydCAqLworICAgICAgICBwX2NoLT5sYXN0X2RzdGF0ID0gaXJiLT5zY3N3LmRzdGF0OworCisgICAgICAgIHN3aXRjaCAocF9jaC0+Y2xhd19zdGF0ZSkgeworICAgICAgICAgICAgICAgIGNhc2UgQ0xBV19TVE9QOi8qIEhBTFRfSU8gYnkgY2xhd19yZWxlYXNlIChoYWx0IHNlcXVlbmNlKSAqLworI2lmZGVmIERFQlVHTVNHCisgICAgICAgICAgICAgICAgICAgICAgICBwcmludGsoS0VSTl9JTkZPICIlczogQ0xBV19TVE9QIGVudGVyXG4iLCBkZXYtPm5hbWUpOworI2VuZGlmCisgICAgICAgICAgICAgICAgICAgICAgICBpZiAoISgocF9jaC0+aXJiLT5zY3N3LnN0Y3RsICYgU0NTV19TVENUTF9TRUNfU1RBVFVTKSB8fAorCSAgICAJCShwX2NoLT5pcmItPnNjc3cuc3RjdGwgPT0gU0NTV19TVENUTF9TVEFUVVNfUEVORCkgfHwKKwkgICAgCQkocF9jaC0+aXJiLT5zY3N3LnN0Y3RsID09CisJICAgICAJCShTQ1NXX1NUQ1RMX0FMRVJUX1NUQVRVUyB8IFNDU1dfU1RDVExfU1RBVFVTX1BFTkQpKSkpIHsKKyNpZmRlZiBGVU5DVFJBQ0UKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnRrKEtFUk5fSU5GTyAiJXM6JXMgRXhpdCBvbiBsaW5lICVkXG4iLAorCQkJCQlkZXYtPm5hbWUsX19GVU5DVElPTl9fLF9fTElORV9fKTsKKyNlbmRpZgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CisgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgICAgICB3YWtlX3VwKCZwX2NoLT53YWl0KTsgICAvKiB3YWtlIHVwIGNsYXdfcmVsZWFzZSAqLworCisjaWZkZWYgREVCVUdNU0cKKyAgICAgICAgICAgICAgICAgICAgICAgIHByaW50ayhLRVJOX0lORk8gIiVzOiBDTEFXX1NUT1AgZXhpdFxuIiwgZGV2LT5uYW1lKTsKKyNlbmRpZgorI2lmZGVmIEZVTkNUUkFDRQorICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnRrKEtFUk5fSU5GTyAiJXM6JXMgRXhpdCBvbiBsaW5lICVkXG4iLAorCQkJCWRldi0+bmFtZSxfX0ZVTkNUSU9OX18sX19MSU5FX18pOworI2VuZGlmCisJCQlDTEFXX0RCRl9URVhUKDQsdHJhY2UsInN0b3AiKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKKworICAgICAgICAgICAgICAgIGNhc2UgQ0xBV19TVEFSVF9IQUxUX0lPOiAvKiBIQUxUX0lPIGlzc3VlZCBieSBjbGF3X29wZW4gICovCisjaWZkZWYgREVCVUdNU0cKKyAgICAgICAgICAgICAgICAgICAgICAgIHByaW50ayhLRVJOX0lORk8gIiVzOiBwcm9jZXNzIENMQVdfU1RBVF9IQUxUX0lPXG4iLAorCQkJCWRldi0+bmFtZSk7CisjZW5kaWYKKyAgICAgICAgICAgICAgICAgICAgICAgIGlmICghKChwX2NoLT5pcmItPnNjc3cuc3RjdGwgJiBTQ1NXX1NUQ1RMX1NFQ19TVEFUVVMpIHx8CisJICAgIAkJKHBfY2gtPmlyYi0+c2Nzdy5zdGN0bCA9PSBTQ1NXX1NUQ1RMX1NUQVRVU19QRU5EKSB8fAorCSAgICAJCShwX2NoLT5pcmItPnNjc3cuc3RjdGwgPT0KKwkgICAgIAkJKFNDU1dfU1RDVExfQUxFUlRfU1RBVFVTIHwgU0NTV19TVENUTF9TVEFUVVNfUEVORCkpKSkgeworI2lmZGVmIEZVTkNUUkFDRQorCQkJCXByaW50ayhLRVJOX0lORk8gIiVzOiVzIEV4aXQgb24gbGluZSAlZFxuIiwKKwkJCQkJZGV2LT5uYW1lLF9fRlVOQ1RJT05fXyxfX0xJTkVfXyk7CisjZW5kaWYKKwkJCQlDTEFXX0RCRl9URVhUKDQsdHJhY2UsImhhbHRpbyIpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CisgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgICAgICBpZiAocF9jaC0+ZmxhZyA9PSBDTEFXX1JFQUQpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcF9jaC0+Y2xhd19zdGF0ZSA9IENMQVdfU1RBUlRfUkVBRDsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2FrZV91cCgmcF9jaC0+d2FpdCk7IC8qIHdha2UgY2xhd19vcGVuIChSRUFEKSovCisgICAgICAgICAgICAgICAgICAgICAgICB9CisJCQllbHNlCisJCQkgICBpZiAocF9jaC0+ZmxhZyA9PSBDTEFXX1dSSVRFKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBfY2gtPmNsYXdfc3RhdGUgPSBDTEFXX1NUQVJUX1dSSVRFOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvKiAgICAgIHNlbmQgU1lTVEVNX1ZBTElEQVRFICAgICAgICAgICAgICAgICAgICAqLworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGF3X3N0cnRfcmVhZChkZXYsIExPQ0tfTk8pOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAljbGF3X3NlbmRfY29udHJvbChkZXYsCisJCQkJCVNZU1RFTV9WQUxJREFURV9SRVFVRVNULAorCQkJCQkwLCAwLCAwLAorCQkJCQlwX2Vudi0+aG9zdF9uYW1lLAorCQkJCQlwX2Vudi0+YWRhcHRlcl9uYW1lICk7CisgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgeworCQkJCXByaW50ayhLRVJOX1dBUk5JTkcgImNsYXc6IHVuc29saWNpdGVkICIKKwkJCQkJImludGVycnVwdCBmb3IgZGV2aWNlOiIKKwkJCQkgCSIlcyByZWNlaXZlZCBjLSUwMnggZC0lMDJ4XG4iLAorICAgICAgICAgICAgICAgIAkJICAgICAgICBjZGV2LT5kZXYuYnVzX2lkLAorCQkJCQlpcmItPnNjc3cuY3N0YXQsCisJCQkJCWlyYi0+c2Nzdy5kc3RhdCk7CisJCQkJcmV0dXJuOworCQkJCX0KKyNpZmRlZiBERUJVR01TRworICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnRrKEtFUk5fSU5GTyAiJXM6IHByb2Nlc3MgQ0xBV19TVEFUX0hBTFRfSU8gZXhpdFxuIiwKKwkJCQlkZXYtPm5hbWUpOworI2VuZGlmCisjaWZkZWYgRlVOQ1RSQUNFCisgICAgICAgICAgICAgICAgICAgICAgICBwcmludGsoS0VSTl9JTkZPICIlczolcyBFeGl0IG9uIGxpbmUgJWRcbiIsCisJCQkJZGV2LT5uYW1lLF9fRlVOQ1RJT05fXyxfX0xJTkVfXyk7CisjZW5kaWYKKwkJCUNMQVdfREJGX1RFWFQoNCx0cmFjZSwiaGFsdGlvIik7CisgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CisgICAgICAgICAgICAgICAgY2FzZSBDTEFXX1NUQVJUX1JFQUQ6CisJCQlDTEFXX0RCRl9URVhUKDQsdHJhY2UsIlJlYWRJUlEiKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwX2NoLT5pcmItPnNjc3cuZHN0YXQgJiBERVZfU1RBVF9VTklUX0NIRUNLKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsZWFyX2JpdCgwLCAodm9pZCAqKSZwX2NoLT5JT19hY3RpdmUpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoKHBfY2gtPmlyYi0+ZWN3WzBdICYgMHg0MSkgPT0gMHg0MSB8fAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKHBfY2gtPmlyYi0+ZWN3WzBdICYgMHg0MCkgPT0gMHg0MCB8fAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKHBfY2gtPmlyYi0+ZWN3WzBdKSAgICAgICAgPT0gMCkKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByaXZwdHItPnN0YXRzLnJ4X2Vycm9ycysrOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByaW50ayhLRVJOX0lORk8gIiVzOiBSZXN0YXJ0IGlzICIKKwkJCQkJCSJyZXF1aXJlZCBhZnRlciByZW1vdGUgIgorCQkJCQkJInNpZGUgcmVjb3ZlcnMgXG4iLAorCQkJCQkJZGV2LT5uYW1lKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQorI2lmZGVmIEZVTkNUUkFDRQorCQkJCXByaW50ayhLRVJOX0lORk8gIiVzOiVzIEV4aXQgb24gbGluZSAlZFxuIiwKKwkJCQkJZGV2LT5uYW1lLF9fRlVOQ1RJT05fXyxfX0xJTkVfXyk7CisjZW5kaWYKKwkJCQkJQ0xBV19EQkZfVEVYVCg0LHRyYWNlLCJub3RyZHkiKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CisgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgICAgICBpZiAoKHBfY2gtPmlyYi0+c2Nzdy5jc3RhdCAmIFNDSE5fU1RBVF9QQ0kpICYmCisJCQkgICAgKHBfY2gtPmlyYi0+c2Nzdy5kc3RhdD09MCkpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRlc3RfYW5kX3NldF9iaXQoQ0xBV19CSF9BQ1RJVkUsCisJCQkJCSh2b2lkICopJnBfY2gtPmZsYWdfYSkgPT0gMCkgeworCQkJCQl0YXNrbGV0X3NjaGVkdWxlKCZwX2NoLT50YXNrbGV0KTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQorCQkJCWVsc2UgeworCQkJCQlDTEFXX0RCRl9URVhUKDQsdHJhY2UsIlBDSU5vQkgiKTsKKwkJCQl9CisjaWZkZWYgRlVOQ1RSQUNFCisJCQkJcHJpbnRrKEtFUk5fSU5GTyAiJXM6JXMgRXhpdCBvbiBsaW5lICVkXG4iLAorCQkJCQlkZXYtPm5hbWUsX19GVU5DVElPTl9fLF9fTElORV9fKTsKKyNlbmRpZgorCQkJCUNMQVdfREJGX1RFWFQoNCx0cmFjZSwiUENJX3JlYWQiKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOworICAgICAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICAgICAgaWYoISgocF9jaC0+aXJiLT5zY3N3LnN0Y3RsICYgU0NTV19TVENUTF9TRUNfU1RBVFVTKSB8fAorCSAgICAJCSAocF9jaC0+aXJiLT5zY3N3LnN0Y3RsID09IFNDU1dfU1RDVExfU1RBVFVTX1BFTkQpIHx8CisJICAgIAkJIChwX2NoLT5pcmItPnNjc3cuc3RjdGwgPT0KKwkgICAgIAkJIChTQ1NXX1NUQ1RMX0FMRVJUX1NUQVRVUyB8IFNDU1dfU1RDVExfU1RBVFVTX1BFTkQpKSkpIHsKKyNpZmRlZiBGVU5DVFJBQ0UKKwkJCQlwcmludGsoS0VSTl9JTkZPICIlczolcyBFeGl0IG9uIGxpbmUgJWRcbiIsCisJCQkJCWRldi0+bmFtZSxfX0ZVTkNUSU9OX18sX19MSU5FX18pOworI2VuZGlmCisJCQkJQ0xBV19EQkZfVEVYVCg0LHRyYWNlLCJTUGVuZF9yZCIpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CisgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgICAgICBjbGVhcl9iaXQoMCwgKHZvaWQgKikmcF9jaC0+SU9fYWN0aXZlKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGNsYXdfY2xlYXJiaXRfYnVzeShUQl9SRVRSWSxkZXYpOworICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRlc3RfYW5kX3NldF9iaXQoQ0xBV19CSF9BQ1RJVkUsCisgICAgCQkJCSh2b2lkICopJnBfY2gtPmZsYWdfYSkgPT0gMCkgeworICAgIAkJCQl0YXNrbGV0X3NjaGVkdWxlKCZwX2NoLT50YXNrbGV0KTsKKyAgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgCQkJZWxzZSB7CisgICAgCQkJCUNMQVdfREJGX1RFWFQoNCx0cmFjZSwiUmRCSEFjdCIpOworICAgIAkJCX0KKworI2lmZGVmIERFQlVHTVNHCisgICAgICAgICAgICAgICAgICAgICAgICBwcmludGsoS0VSTl9JTkZPICIlczogcHJvY2VzcyBDTEFXX1NUQVJUX1JFQUQgZXhpdFxuIiwKKwkJCQlkZXYtPm5hbWUpOworI2VuZGlmCisjaWZkZWYgRlVOQ1RSQUNFCisJCQlwcmludGsoS0VSTl9JTkZPICIlczolcyBFeGl0IG9uIGxpbmUgJWRcbiIsCisJCQkJZGV2LT5uYW1lLF9fRlVOQ1RJT05fXyxfX0xJTkVfXyk7CisjZW5kaWYKKwkJCUNMQVdfREJGX1RFWFQoNCx0cmFjZSwiUmRJUlFYaXQiKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKKyAgICAgICAgICAgICAgICBjYXNlIENMQVdfU1RBUlRfV1JJVEU6CisgICAgICAgICAgICAgICAgICAgICAgICBpZiAocF9jaC0+aXJiLT5zY3N3LmRzdGF0ICYgREVWX1NUQVRfVU5JVF9DSEVDSykgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcmludGsoS0VSTl9JTkZPICIlczogVW5pdCBDaGVjayBPY2N1cmVkIGluICIKKwkJCQkJIndyaXRlIGNoYW5uZWxcbiIsZGV2LT5uYW1lKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xlYXJfYml0KDAsICh2b2lkICopJnBfY2gtPklPX2FjdGl2ZSk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwX2NoLT5pcmItPmVjd1swXSAmIDB4ODAgKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnRrKEtFUk5fSU5GTyAiJXM6IFJlc2V0dGluZyBFdmVudCAiCisJCQkJCQkib2NjdXJyZWQ6XG4iLGRldi0+bmFtZSk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW5pdF90aW1lcigmcF9jaC0+dGltZXIpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBfY2gtPnRpbWVyLmZ1bmN0aW9uID0KKwkJCQkJCSh2b2lkICopY2xhd193cml0ZV9yZXRyeTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwX2NoLT50aW1lci5kYXRhID0gKHVuc2lnbmVkIGxvbmcpcF9jaDsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwX2NoLT50aW1lci5leHBpcmVzID0gamlmZmllcyArIDEwKkhaOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFkZF90aW1lcigmcF9jaC0+dGltZXIpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByaW50ayhLRVJOX0lORk8gIiVzOiB3cml0ZSBjb25uZWN0aW9uICIKKwkJCQkJCSJyZXN0YXJ0aW5nXG4iLGRldi0+bmFtZSk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KKyNpZmRlZiBGVU5DVFJBQ0UKKwkJCQlwcmludGsoS0VSTl9JTkZPICIlczolcyBFeGl0IG9uIGxpbmUgJWRcbiIsCisJCQkJCWRldi0+bmFtZSxfX0ZVTkNUSU9OX18sX19MSU5FX18pOworI2VuZGlmCisJCQkJQ0xBV19EQkZfVEVYVCg0LHRyYWNlLCJyc3RydHdydCIpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CisgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgICAgICBpZiAocF9jaC0+aXJiLT5zY3N3LmRzdGF0ICYgREVWX1NUQVRfVU5JVF9FWENFUCkgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsZWFyX2JpdCgwLCAodm9pZCAqKSZwX2NoLT5JT19hY3RpdmUpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByaW50ayhLRVJOX0lORk8gIiVzOiBVbml0IEV4Y2VwdGlvbiAiCisJCQkJCQkiT2NjdXJlZCBpbiB3cml0ZSBjaGFubmVsXG4iLAorCQkJCQkJZGV2LT5uYW1lKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgICAgIGlmKCEoKHBfY2gtPmlyYi0+c2Nzdy5zdGN0bCAmIFNDU1dfU1RDVExfU0VDX1NUQVRVUykgfHwKKwkgICAgCQkocF9jaC0+aXJiLT5zY3N3LnN0Y3RsID09IFNDU1dfU1RDVExfU1RBVFVTX1BFTkQpIHx8CisJICAgIAkJKHBfY2gtPmlyYi0+c2Nzdy5zdGN0bCA9PQorCSAgICAgCQkoU0NTV19TVENUTF9BTEVSVF9TVEFUVVMgfCBTQ1NXX1NUQ1RMX1NUQVRVU19QRU5EKSkpKSB7CisjaWZkZWYgRlVOQ1RSQUNFCisJCQkJcHJpbnRrKEtFUk5fSU5GTyAiJXM6JXMgRXhpdCBvbiBsaW5lICVkXG4iLAorCQkJCQlkZXYtPm5hbWUsX19GVU5DVElPTl9fLF9fTElORV9fKTsKKyNlbmRpZgorCQkJCUNMQVdfREJGX1RFWFQoNCx0cmFjZSwid3JpdGVVRSIpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CisgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgICAgICBjbGVhcl9iaXQoMCwgKHZvaWQgKikmcF9jaC0+SU9fYWN0aXZlKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjbGF3X3Rlc3RfYW5kX3NldGJpdF9idXN5KFRCX1RYLGRldik9PTApIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xhd193cml0ZV9uZXh0KHBfY2gpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGF3X2NsZWFyYml0X2J1c3koVEJfVFgsZGV2KTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xhd19jbGVhcl9idXN5KGRldik7CisgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgICAgICBwX2NoX3I9KHN0cnVjdCBjaGJrICopJnByaXZwdHItPmNoYW5uZWxbUkVBRF07CisgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGVzdF9hbmRfc2V0X2JpdChDTEFXX0JIX0FDVElWRSwKKyAJCQkJCSh2b2lkICopJnBfY2hfci0+ZmxhZ19hKSA9PSAwKSB7CisJCQkgCXRhc2tsZXRfc2NoZWR1bGUoJnBfY2hfci0+dGFza2xldCk7CisgICAgICAgICAgICAgICAgICAgICAgICB9CisKKyNpZmRlZiBERUJVR01TRworICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnRrKEtFUk5fSU5GTyAiJXM6IHByb2Nlc3MgQ0xBV19TVEFSVF9XUklURSBleGl0XG4iLAorCQkJCSBkZXYtPm5hbWUpOworI2VuZGlmCisjaWZkZWYgRlVOQ1RSQUNFCisJCQlwcmludGsoS0VSTl9JTkZPICIlczolcyBFeGl0IG9uIGxpbmUgJWRcbiIsCisJCQkJZGV2LT5uYW1lLF9fRlVOQ1RJT05fXyxfX0xJTkVfXyk7CisjZW5kaWYKKwkJCUNMQVdfREJGX1RFWFQoNCx0cmFjZSwiU3RXdEV4aXQiKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKKyAgICAgICAgICAgICAgICBkZWZhdWx0OgorICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnRrKEtFUk5fV0FSTklORyAiJXM6IHdyb25nIHNlbGVjdGlvbiBjb2RlIC0gaXJxICIKKwkJCQkic3RhdGU9JWRcbiIsZGV2LT5uYW1lLHBfY2gtPmNsYXdfc3RhdGUpOworI2lmZGVmIEZVTkNUUkFDRQorCQkJcHJpbnRrKEtFUk5fSU5GTyAiJXM6JXMgRXhpdCBvbiBsaW5lICVkXG4iLAorCQkJCWRldi0+bmFtZSxfX0ZVTkNUSU9OX18sX19MSU5FX18pOworI2VuZGlmCisJCQlDTEFXX0RCRl9URVhUKDIsdHJhY2UsImJhZElSUSIpOworICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOworICAgICAgICB9CisKK30gICAgICAgLyogICBlbmQgb2YgY2xhd19pcnFfaGFuZGxlciAgICAqLworCisKKy8qLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSoKKyogICAgICAgY2xhd19pcnFfdGFza2xldCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICoKKyogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICoKKyotLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSovCitzdGF0aWMgdm9pZAorY2xhd19pcnFfdGFza2xldCAoIHVuc2lnbmVkIGxvbmcgZGF0YSApCit7CisJc3RydWN0IGNoYmsgKiBwX2NoOworICAgICAgICBzdHJ1Y3QgbmV0X2RldmljZSAgKmRldjsKKyAgICAgICAgc3RydWN0IGNsYXdfcHJpdmJrICogICAgICAgcHJpdnB0cjsKKworCXBfY2ggPSAoc3RydWN0IGNoYmsgKikgZGF0YTsKKyAgICAgICAgZGV2ID0gKHN0cnVjdCBuZXRfZGV2aWNlICopcF9jaC0+bmRldjsKKyNpZmRlZiBGVU5DVFJBQ0UKKyAgICAgICAgcHJpbnRrKEtFUk5fSU5GTyAiJXM6JXMgRW50ZXIgIFxuIixkZXYtPm5hbWUsX19GVU5DVElPTl9fKTsKKyNlbmRpZgorI2lmZGVmIERFQlVHTVNHCisgICAgICAgIHByaW50ayhLRVJOX0lORk8gIiVzOiB2YXJpYWJsZSBwX2NoID1cbiIsZGV2LT5uYW1lKTsKKyAgICAgICAgZHVtcGl0KChjaGFyICopIHBfY2gsIHNpemVvZihzdHJ1Y3QgY2hiaykpOworI2VuZGlmCisJQ0xBV19EQkZfVEVYVCg0LHRyYWNlLCJJUlF0YXNrIik7CisKKyAgICAgICAgcHJpdnB0ciA9IChzdHJ1Y3QgY2xhd19wcml2YmsgKikgZGV2LT5wcml2OworCisjaWZkZWYgREVCVUdNU0cKKyAgICAgICAgcHJpbnRrKEtFUk5fSU5GTyAiJXM6IGJoIHJvdXRpbmUgLSBzdGF0ZS0lMDJ4XG4iICwKKwkJZGV2LT5uYW1lLCBwX2NoLT5jbGF3X3N0YXRlKTsKKyNlbmRpZgorCisgICAgICAgIHVucGFja19yZWFkKGRldik7CisgICAgICAgIGNsZWFyX2JpdChDTEFXX0JIX0FDVElWRSwgKHZvaWQgKikmcF9jaC0+ZmxhZ19hKTsKKwlDTEFXX0RCRl9URVhUKDQsdHJhY2UsIlRza2xldFh0Iik7CisjaWZkZWYgRlVOQ1RSQUNFCisJcHJpbnRrKEtFUk5fSU5GTyAiJXM6JXMgRXhpdCBvbiBsaW5lICVkXG4iLAorCQlkZXYtPm5hbWUsX19GVU5DVElPTl9fLF9fTElORV9fKTsKKyNlbmRpZgorICAgICAgICByZXR1cm47Cit9ICAgICAgIC8qICAgIGVuZCBvZiBjbGF3X2lycV9iaCAgICAqLworCisvKi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0qCisqICAgICAgIGNsYXdfcmVsZWFzZSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqCisqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqCisqLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0qLworc3RhdGljIGludAorY2xhd19yZWxlYXNlKHN0cnVjdCBuZXRfZGV2aWNlICpkZXYpCit7CisgICAgICAgIGludCAgICAgICAgICAgICAgICByYzsKKyAgICAgICAgaW50ICAgICAgICAgICAgICAgIGk7CisgICAgICAgIHVuc2lnbmVkIGxvbmcgICAgICBzYXZlZmxhZ3M7CisgICAgICAgIHVuc2lnbmVkIGxvbmcgICAgICBwYXJtOworICAgICAgICBzdHJ1Y3QgY2xhd19wcml2YmsgKnByaXZwdHI7CisgICAgICAgIERFQ0xBUkVfV0FJVFFVRVVFKHdhaXQsIGN1cnJlbnQpOworICAgICAgICBzdHJ1Y3QgY2N3YmsqICAgICAgICAgICAgIHBfdGhpc19jY3c7CisgICAgICAgIHN0cnVjdCBjY3diayogICAgICAgICAgICAgcF9idWY7CisKKwlpZiAoIWRldikKKyAgICAgICAgICAgICAgICByZXR1cm4gMDsKKyAgICAgICAgcHJpdnB0ciA9IChzdHJ1Y3QgY2xhd19wcml2YmsgKikgZGV2LT5wcml2OworICAgICAgICBpZiAoIXByaXZwdHIpCisgICAgICAgICAgICAgICAgcmV0dXJuIDA7CisjaWZkZWYgRlVOQ1RSQUNFCisgICAgICAgIHByaW50ayhLRVJOX0lORk8gIiVzOiVzIEVudGVyICBcbiIsZGV2LT5uYW1lLF9fRlVOQ1RJT05fXyk7CisjZW5kaWYKKwlDTEFXX0RCRl9URVhUKDQsdHJhY2UsInJlbGVhc2UiKTsKKyNpZmRlZiBERUJVR01TRworICAgICAgICBwcmludGsoS0VSTl9JTkZPICIlczogdmFyaWFibGUgZGV2ID1cbiIsZGV2LT5uYW1lKTsKKyAgICAgICAgZHVtcGl0KChjaGFyICopIGRldiwgc2l6ZW9mKHN0cnVjdCBuZXRfZGV2aWNlKSk7CisJcHJpbnRrKEtFUk5fSU5GTyAiUHJpdiBCdWZmYWxsb2MgJWRcbiIscHJpdnB0ci0+YnVmZnNfYWxsb2MpOworCXByaW50ayhLRVJOX0lORk8gIlByaXYgcF9idWZmX2NjdyA9ICVwXG4iLCZwcml2cHRyLT5wX2J1ZmZfY2N3KTsKKyNlbmRpZgorICAgICAgICBwcml2cHRyLT5yZWxlYXNlX3BlbmQ9MTsKKyAgICAgICAgY2xhd19zZXRiaXRfYnVzeShUQl9TVE9QLGRldik7CisgICAgICAgIGZvciAoIGkgPSAxOyBpID49MCA7ICBpLS0pIHsKKyAgICAgICAgICAgICAgICBzcGluX2xvY2tfaXJxc2F2ZSgKKwkJCWdldF9jY3dkZXZfbG9jayhwcml2cHRyLT5jaGFubmVsW2ldLmNkZXYpLCBzYXZlZmxhZ3MpOworICAgICAgICAgICAgIC8qICAgZGVsX3RpbWVyKCZwcml2cHRyLT5jaGFubmVsW1JFQURdLnRpbWVyKTsgICovCisgCQlwcml2cHRyLT5jaGFubmVsW2ldLmNsYXdfc3RhdGUgPSBDTEFXX1NUT1A7CisgICAgICAgICAgICAgICAgcHJpdnB0ci0+Y2hhbm5lbFtpXS5JT19hY3RpdmUgPSAwOworICAgICAgICAgICAgICAgIHBhcm0gPSAodW5zaWduZWQgbG9uZykgJnByaXZwdHItPmNoYW5uZWxbaV07CisJCWlmIChpID09IFdSSVRFKQorCQkJY2xhd19wdXJnZV9za2JfcXVldWUoCisJCQkJJnByaXZwdHItPmNoYW5uZWxbV1JJVEVdLmNvbGxlY3RfcXVldWUpOworICAgICAgICAgICAgICAgIHJjID0gY2N3X2RldmljZV9oYWx0IChwcml2cHRyLT5jaGFubmVsW2ldLmNkZXYsIHBhcm0pOworCSAgICAgICAgaWYgKHByaXZwdHItPnN5c3RlbV92YWxpZGF0ZV9jb21wPT0weDAwKSAgLyogbmV2ZXIgb3BlbmVkPyAqLworICAgICAgICAgICAgICAgICAgIGluaXRfd2FpdHF1ZXVlX2hlYWQoJnByaXZwdHItPmNoYW5uZWxbaV0ud2FpdCk7CisgICAgICAgICAgICAgICAgYWRkX3dhaXRfcXVldWUoJnByaXZwdHItPmNoYW5uZWxbaV0ud2FpdCwgJndhaXQpOworICAgICAgICAgICAgICAgIHNldF9jdXJyZW50X3N0YXRlKFRBU0tfSU5URVJSVVBUSUJMRSk7CisJICAgICAgICBzcGluX3VubG9ja19pcnFyZXN0b3JlKAorCQkJZ2V0X2Njd2Rldl9sb2NrKHByaXZwdHItPmNoYW5uZWxbaV0uY2RldiksIHNhdmVmbGFncyk7CisJICAgICAgICBzY2hlZHVsZSgpOworCQlzZXRfY3VycmVudF9zdGF0ZShUQVNLX1JVTk5JTkcpOworCSAgICAgICAgc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h1bnNpZ25lZCBsb25nKXByaXZwdHItPnBfYnVmZl9yZWFkLAorCQkgICAgICAoaW50KXBhZ2VzX3RvX29yZGVyX29mX21hZyhwcml2cHRyLT5wX2J1ZmZfcmVhZF9udW0pKTsKKwkJfQorICAgICAgICB9CisgICAgICAgIGVsc2UgeworICAgICAgICAgICAgICAgIHBfYnVmPXByaXZwdHItPnBfcmVhZF9hY3RpdmVfZmlyc3Q7CisgICAgICAgICAgICAgICAgd2hpbGUgKHBfYnVmIT1OVUxMKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBmcmVlX3BhZ2VzKCh1bnNpZ25lZCBsb25nKXBfYnVmLT5wX2J1ZmZlciwKKwkJCSAgICAgKGludClwYWdlc190b19vcmRlcl9vZl9tYWcoCisJCQkgICAgIAlwcml2cHRyLT5wX2J1ZmZfcGFnZXNfcGVycmVhZCApKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHBfYnVmPXBfYnVmLT5uZXh0OworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgfQorCSBDTEFXX0RCRl9URVhUKDQsdHJhY2UsImZyZWV3cml0Iik7CisgICAgICAgIGlmIChwcml2cHRyLT5wX2Vudi0+d3JpdGVfc2l6ZSA8IFBBR0VfU0laRSApIHsKKyAgICAgICAgICAgICAgICBmcmVlX3BhZ2VzKCh1bnNpZ25lZCBsb25nKXByaXZwdHItPnBfYnVmZl93cml0ZSwKKwkJICAgICAgKGludClwYWdlc190b19vcmRlcl9vZl9tYWcocHJpdnB0ci0+cF9idWZmX3dyaXRlX251bSkpOworICAgICAgICB9CisgICAgICAgIGVsc2UgeworICAgICAgICAgICAgICAgIHBfYnVmPXByaXZwdHItPnBfd3JpdGVfYWN0aXZlX2ZpcnN0OworICAgICAgICAgICAgICAgIHdoaWxlIChwX2J1ZiE9TlVMTCkgeworICAgICAgICAgICAgICAgICAgICAgICAgZnJlZV9wYWdlcygodW5zaWduZWQgbG9uZylwX2J1Zi0+cF9idWZmZXIsCisJCQkgICAgICAoaW50KXBhZ2VzX3RvX29yZGVyX29mX21hZygKKwkJCSAgICAgIHByaXZwdHItPnBfYnVmZl9wYWdlc19wZXJ3cml0ZSApKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHBfYnVmPXBfYnVmLT5uZXh0OworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgfQorCSBDTEFXX0RCRl9URVhUKDQsdHJhY2UsImNsZWFycHRyIik7CisJcHJpdnB0ci0+YnVmZnNfYWxsb2MgPSAwOworICAgICAgICBwcml2cHRyLT5wX2J1ZmZfY2N3PU5VTEw7CisgICAgICAgIHByaXZwdHItPnBfYnVmZl9yZWFkPU5VTEw7CisgICAgICAgIHByaXZwdHItPnBfYnVmZl93cml0ZT1OVUxMOworICAgICAgICBwcml2cHRyLT5zeXN0ZW1fdmFsaWRhdGVfY29tcD0wOworICAgICAgICBwcml2cHRyLT5yZWxlYXNlX3BlbmQ9MDsKKyAgICAgICAgLyogICAgICBSZW1vdmUgYW55IHdyaXRlcyB0aGF0IHdlcmUgcGVuZGluZyBhbmQgcmVzZXQgYWxsIHJlYWRzICAgKi8KKyAgICAgICAgcF90aGlzX2Njdz1wcml2cHRyLT5wX3JlYWRfYWN0aXZlX2ZpcnN0OworICAgICAgICB3aGlsZSAocF90aGlzX2NjdyE9TlVMTCkgeworICAgICAgICAgICAgICAgIHBfdGhpc19jY3ctPmhlYWRlci5sZW5ndGg9MHhmZmZmOworICAgICAgICAgICAgICAgIHBfdGhpc19jY3ctPmhlYWRlci5vcGNvZGU9MHhmZjsKKyAgICAgICAgICAgICAgICBwX3RoaXNfY2N3LT5oZWFkZXIuZmxhZz0weDAwOworICAgICAgICAgICAgICAgIHBfdGhpc19jY3c9cF90aGlzX2Njdy0+bmV4dDsKKyAgICAgICAgfQorCisgICAgICAgIHdoaWxlIChwcml2cHRyLT5wX3dyaXRlX2FjdGl2ZV9maXJzdCE9TlVMTCkgeworICAgICAgICAgICAgICAgIHBfdGhpc19jY3c9cHJpdnB0ci0+cF93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ENMQVdfREJGX1RFWFQoMix0cmFjZSwiYmFkY2xvc2UiKTsKKyAgICAgICAgfQorI2lmZGVmIEZVTkNUUkFDRQorCXByaW50ayhLRVJOX0lORk8gIiVzOiVzIEV4aXQgb24gbGluZSAlZFxuIiwKKwkJZGV2LT5uYW1lLF9fRlVOQ1RJT05fXyxfX0xJTkVfXyk7CisjZW5kaWYKKwlDTEFXX0RCRl9URVhUKDQsdHJhY2UsInJsc2V4aXQiKTsKKyAgICAgICAgcmV0dXJuIDA7Cit9ICAgICAgLyogZW5kIG9mIGNsYXdfcmVsZWFzZSAgICAgKi8KKworCisKKy8qLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSoKKyogICAgICAgY2xhd193cml0ZV9yZXRyeSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICoKKyogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICoKKyotLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSovCisKK3N0YXRpYyB2b2lkCitjbGF3X3dyaXRlX3JldHJ5ICggc3RydWN0IGNoYmsgKnBfY2ggKQoreworCisgICAgICAgIHN0cnVjdCBuZXRfZGV2aWNlICAqZGV2PXBfY2gtPm5kZXY7CisKKworI2lmZGVmIEZVTkNUUkFDRQorICAgICAgICBwcmludGsoS0VSTl9JTkZPICIlczolcyBFbnRlclxuIixkZXYtPm5hbWUsX19GVU5DVElPTl9fKTsKKyAgICAgICAgcHJpbnRrKEtFUk5fSU5GTyAiY2xhdzogdmFyaWFibGUgcF9jaCA9XG4iKTsKKyAgICAgICAgZHVtcGl0KChjaGFyICopIHBfY2gsIHNpemVvZihzdHJ1Y3QgY2hiaykpOworI2VuZGlmCisJQ0xBV19EQkZfVEVYVCg0LHRyYWNlLCJ3X3JldHJ5Iik7CisgICAgICAgIGlmIChwX2NoLT5jbGF3X3N0YXRlID09IENMQVdfU1RPUCkgeworI2lmZGVmIEZVTkNUUkFDRQorCQlwcmludGsoS0VSTl9JTkZPICIlczolcyBFeGl0IG9uIGxpbmUgJWRcbiIsCisJCQlkZXYtPm5hbWUsX19GVU5DVElPTl9fLF9fTElORV9fKTsKKyNlbmRpZgorICAgICAgICAJcmV0dXJuOworICAgICAgICB9CisjaWZkZWYgREVCVUdNU0cKKyAgICAgICAgcHJpbnRrKCBLRVJOX0lORk8gIiVzOiVzICBzdGF0ZS0lMDJ4XG4iICwKKwkJZGV2LT5uYW1lLAorCQlfX0ZVTkNUSU9OX18sCisJCXBfY2gtPmNsYXdfc3RhdGUpOworI2VuZGlmCisJY2xhd19zdHJ0X291dF9JTyggZGV2ICk7CisjaWZkZWYgRlVOQ1RSQUNFCisJcHJpbnRrKEtFUk5fSU5GTyAiJXM6JXMgRXhpdCBvbiBsaW5lICVkXG4iLAorCQlkZXYtPm5hbWUsX19GVU5DVElPTl9fLF9fTElORV9fKTsKKyNlbmRpZgorCUNMQVdfREJGX1RFWFQoNCx0cmFjZSwicnRyeV94aXQiKTsKKyAgICAgICAgcmV0dXJuOworfSAgICAgIC8qIGVuZCBvZiBjbGF3X3dyaXRlX3JldHJ5ICAgICAgKi8KKworCisvKi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0qCisqICAgICAgIGNsYXdfd3JpdGVfbmV4dCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqCisqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqCisqLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS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wkJCXJjID0gY2xhd19od190eCggcGtfc2tiLCBkZXYsMSk7CisJCQlpZiAocHJpdnB0ci0+d3JpdGVfZnJlZV9jb3VudCA+IDApIHsKKwkgICAJCQlwa19za2IgPSBjbGF3X3BhY2tfc2tiKHByaXZwdHIpOworCQkJfSBlbHNlCisJCQkJcGtfc2tiID0gTlVMTDsKKwkJfQorCX0KKyAgICAgICAgaWYgKHByaXZwdHItPnBfd3JpdGVfYWN0aXZlX2ZpcnN0IT1OVUxMKSB7CisgICAgICAgICAgICAgICAgY2xhd19zdHJ0X291dF9JTyhkZXYpOworICAgICAgICB9CisKKyNpZmRlZiBGVU5DVFJBQ0UKKwlwcmludGsoS0VSTl9JTkZPICIlczolcyBFeGl0IG9uIGxpbmUgJWRcbiIsCisJCWRldi0+bmFtZSxfX0ZVTkNUSU9OX18sX19MSU5FX18pOworI2VuZGlmCisgICAgICAgIHJldHVybjsKK30gICAgICAvKiBlbmQgb2YgY2xhd193cml0ZV9uZXh0ICAgICAgKi8KKworLyotLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKgorKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKgorKiAgICAgICBjbGF3X3RpbWVyICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKgorKi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKi8KKworc3RhdGljIHZvaWQKK2NsYXdfdGltZXIgKCBzdHJ1Y3QgY2hiayAqIHBfY2ggKQoreworI2lmZGVmIEZVTkNUUkFDRQorICAgICAgICBwcmludGsoS0VSTl9JTkZPICIlczolcyBFbnRyeVxuIixwX2NoLT5uZGV2LT5uYW1lLF9fRlVOQ1RJT05fXyk7CisgICAgICAgIHByaW50ayhLRVJOX0lORk8gIiVzOiB2YXJpYWJsZSBwX2NoID1cbiIscF9jaC0+bmRldi0+bmFtZSk7CisgICAgICAgIGR1bXBpdCgoY2hhciAqKSBwX2NoLCBzaXplb2Yoc3RydWN0IGNoYmspKTsKKyNlbmRpZgorCUNMQVdfREJGX1RFWFQoNCx0cmFjZSwidGltZXIiKTsKKyAgICAgICAgcF9jaC0+ZmxhZyB8PSBDTEFXX1RJTUVSOworICAgICAgICB3YWtlX3VwKCZwX2NoLT53YWl0KTsKKyNpZmRlZiBGVU5DVFJBQ0UKKwlwcmludGsoS0VSTl9JTkZPICIlczolcyBFeGl0IG9uIGxpbmUgJWRcbiIsCisJCXBfY2gtPm5kZXYtPm5hbWUsX19GVU5DVElPTl9fLF9fTElORV9fKTsKKyNlbmRpZgorICAgICAgICByZXR1cm47Cit9ICAgICAgLyogZW5kIG9mIGNsYXdfdGltZXIgICovCisKKworLyoKKyoKKyogICAgICAgZnVuY3Rpb25zCisqLworCisKKy8qLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSoKKyogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICoKKyogICAgIHBhZ2VzX3RvX29yZGVyX29mX21hZyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICoKKyogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICoKKyogICAgdGFrZXMgYSBudW1iZXIgb2YgcGFnZXMgZnJvbSAxIHRvIDUxMiBhbmQgcmV0dXJucyB0aGUgICAgICAgICAgICoKKyogICAgbG9nKG51bV9wYWdlcykvbG9nKDIpIGdldF9mcmVlX3BhZ2VzKCkgbmVlZHMgYSBiYXNlIDIgb3JkZXI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lmZGVmIEZVTkNUUkFDRQorICAgICAgICBwcmludGsoS0VSTl9JTkZPICIlcyBFeGl0IG9uIGxpbmUgJWQsIG9yZGVyID0gJWRcbiIsCisJX19GVU5DVElPTl9fLF9fTElORV9fLCBvcmRlcl9vZl9tYWcpOworI2VuZGlmCisJQ0xBV19EQkZfVEVYVF8oNSx0cmFjZSwibWFnJWQiLG9yZGVyX29mX21hZyk7CisJcmV0dXJuIG9yZGVyX29mX21hZzsKK30KKworLyotLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKgorKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKgorKiAgICAgYWRkX2NsYXdfcmVhZHMgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKgorKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKgorKi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKi8KK3N0YXRpYyBpbnQKK2FkZF9jbGF3X3JlYWRzKHN0cnVjdCBuZXRfZGV2aWNlICpkZXYsIHN0cnVjdCBjY3diayogcF9maXJzdCwKKwlzdHJ1Y3QgY2N3YmsqIHBfbGFzdCkKK3sKKyAgICAgICAgc3RydWN0IGNsYXdfcHJpdmJrICpwcml2cHRyOworICAgICAgICBzdHJ1Y3QgY2N3MSAgdGVtcF9jY3c7CisgICAgICAgIHN0cnVjdCBlbmRjY3cgKiBwX2VuZDsKKyNpZmRlZiBJT1RSQUNFCisgICAgICAgIHN0cnVjdCBjY3diayogIHBfYnVmOworI2VuZGlmCisjaWZkZWYgRlVOQ1RSQUNFCisgICAgICAgIHByaW50ayhL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gICAgIH0KKworICAgICAgICAvKiBzZXQgdXAgZW5kaW5nIENDVyBzZXF1ZW5jZSBmb3IgdGhpcyBzZWdtZW50ICovCisgICAgICAgIGlmIChwX2VuZC0+cmVhZDEpIHsKKyAgICAgICAgICAgICAgICBwX2VuZC0+cmVhZDE9MHgwMDsgICAgLyogIHNlY29uZCBlbmRpbmcgQ0NXIGlzIG5vdyBhY3RpdmUgKi8KKyAgICAgICAgICAgICAgICAvKiAgICAgIHJlc2V0IGVuZGluZyBDQ1dzIGFuZCBzZXR1cCBUSUMgQ0NXcyAgICAgICAgICAgICAgKi8KKyAgICAgICAgICAgICAgICBwX2VuZC0+cmVhZDJfbm9wMi5jbWRfY29kZSA9IENDV19DTEFXX0NNRF9SRUFERkY7CisgICAgICAgICAgICAgICAgcF9lbmQtPnJlYWQyX25vcDIuZmxhZ3MgID0gQ0NXX0ZMQUdfU0xJIHwgQ0NXX0ZMQUdfU0tJUDsKKyAgICAgICAgICAgICAgICBwX2xhc3QtPnJfVElDXzEuY2RhID0oX191MzIpX19wYSgmcF9lbmQtPnJlYWQyX25vcDEpOworICAgICAgICAgICAgICAgIHBfbGFzdC0+cl9USUNfMi5jZGEgPShfX3UzMilfX3BhKCZwX2VuZC0+cmVhZDJfbm9wMSk7CisgICAgICAgICAgICAgICAgcF9lbmQtPnJlYWQyX25vcDIuY2RhPTA7CisgICAgICAgICAgICAgICAgcF9lbmQtPnJlYWQyX25vcDIuY291bnQ9MTsKKyAgICAgICAgfQorICAgICAgICBlbHNlIHsKKyAgICAgICAgICAgICAgICBwX2VuZC0+cmVhZDE9MHgwMTsgIC8qIGZpcnN0IGVuZGluZyBDQ1cgaXMgbm93IGFjdGl2ZSAqLworICAgICAgICAgICAgICAgIC8qICAgICAgcmVzZXQgZW5kaW5nIENDV3MgYW5kIHNldHVwIFRJQyBDQ1dzICAgICAgICAgICovCisgICAgICAgICAgICAgICAgcF9lbmQtPnJlYWQxX25vcDIuY21kX2NvZGUgPSBDQ1dfQ0xBV19DTURfUkVBREZGOworICAgICAgICAgICAgICAgIHBfZW5kLT5yZWFkMV9ub3AyLmZsYWdzICA9IENDV19GTEFHX1NMSSB8IENDV19GTEFHX1NLSVA7CisgICAgICAgICAgICAgICAgcF9sYXN0LT5yX1RJQ18xLmNkYSA9IChfX3UzMilfX3BhKCZwX2VuZC0+cmVhZDFfbm9wMSk7CisgICAgICAgICAgICAgICAgcF9sYXN0LT5yX1RJQ18yLmNkYSA9IChfX3UzMilfX3BhKCZwX2VuZC0+cmVhZDFfbm9wMSk7CisgICAgICAgICAgICAgICAgcF9lbmQtPnJlYWQxX25vcDIuY2RhPTA7CisgICAgICAgICAgICAgICAgcF9lbmQtPnJlYWQxX25vcDIuY291bnQ9MTsKKyAgICAgICAgfQorCisgICAgICAgIGlmICggcHJpdnB0ci0+IHBfcmVhZF9hY3RpdmVfZmlyc3QgPT1OVUxMICkgeworI2lmZGVmIERFQlVHTVNHCisgICAgICAgICAgICAgICAgcHJpbnRrKEtFUk5fSU5GTyAiJXM6JXMgcF9yZWFkX2FjdGl2ZV9mcmlzdCA9PSBOVUxMIFxuIiwKKwkJCWRldi0+bmFtZSxfX0ZVTkNUSU9OX18pOworICAgICAgICAgICAgICAgIHByaW50ayhLRVJOX0lORk8gIiVzOiVzIFJlYWQgYWN0aXZlIGZpcnN0L2xhc3QgY2hhbmdlZCBcbiIsCisJCQlkZXYtPm5hbWUsX19GVU5DVElPTl9fKTsKKyNlbmRpZgorICAgICAgICAgICAgICAgIHByaXZwdHItPiBwX3JlYWRfYWN0aXZlX2ZpcnN0PSBwX2ZpcnN0OyAgLyogICAgc2V0IG5ldyBmaXJzdCAqLworICAgICAgICAgICAgICAgIHByaXZwdHItPiBwX3JlYWRfYWN0aXZlX2xhc3QgPSBwX2xhc3Q7ICAgLyogICAgc2V0IG5ldyBsYXN0ICAqLworICAgICAgICB9CisgICAgICAgIGVsc2UgeworCisjaWZkZWYgREVCVUdNU0cKKyAgICAgICAgICAgICAgICBwcmludGsoS0VSTl9JTkZPICIlczolcyBSZWFkIGluIHByb2dyZXNzIFxuIiwKKwkJZGV2LT5uYW1lLF9fRlVOQ1RJT05fXyk7CisjZW5kaWYKKyAgICAgICAgICAgICAgICAvKiBzZXQgdXAgVElDIGNjdyAgKi8KKyAgICAgICAgICAgICAgICB0ZW1wX2Njdy5jZGE9IChfX3UzMilfX3BhKCZwX2ZpcnN0LT5yZWFkKTsKKyAgICAgICAgICAgICAgICB0ZW1wX2Njdy5jb3VudD0wOworICAgICAgICAgICAgICAgIHRlbXBfY2N3LmZsYWdzPTA7CisgICAgICAgICAgICAgICAgdGVtcF9jY3cuY21kX2NvZGUgPSBDQ1dfQ0xBV19DTURfVElDOworCisKKyAgICAgICAgICAgICAgICBpZiAocF9lbmQtPnJlYWQxKSB7CisKKyAgICAgICAgICAgICAgIC8qIGZpcnN0IHNldCBvZiBDQ1cncyBpcyBjaGFpbmVkIHRvIHRoZSBuZXcgcmVhZCAgICAgICAgICAgICAgKi8KKyAgICAgICAgICAgICAgIC8qIGNoYWluLCBzbyB0aGUgc2Vjb25kIHNldCBpcyBjaGFpbmVkIHRvIHRoZSBhY3RpdmUgY2hhaW4uICAgKi8KKyAgICAgICAgICAgICAgIC8qIFRoZXJlZm9yZSBtb2RpZnkgdGhlIHNlY29uZCBzZXQgdG8gcG9pbnQgdG8gdGhlIG5ldyAgICAgICAgKi8KKyAgICAgICAgICAgICAgIC8qIHJlYWQgY2hhaW4gc2V0IHVwIFRJQyBDQ1dzICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKi8KKyAgICAgICAgICAgICAgIC8qIG1ha2Ugc3VyZSB3ZSB1cGRhdGUgdGhlIENDVyBzbyBjaGFubmVsIGRvZXNuJ3QgZmV0Y2ggaXQgICAgKi8KKyAgICAgICAgICAgICAgIC8qIHdoZW4gaXQncyBvbmx5IGhhbGYgZG9uZSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKi8KKyAgICAgICAgICAgICAgICAgICAgICAgIG1lbWNweSggJnBfZW5kLT5yZWFkMl9ub3AyLCAmdGVtcF9jY3cgLAorCQkJCXNpemVvZihzdHJ1Y3QgY2N3MSkpOworICAgICAgICAgICAgICAgICAgICAgICAgcHJpdnB0ci0+cF9yZWFkX2FjdGl2ZV9sYXN0LT5yX1RJQ18xLmNkYT0KKwkJCQkoX191MzIpX19wYSgmcF9maXJzdC0+cmVhZCk7CisgICAgICAgICAgICAgICAgICAgICAgICBwcml2cHRyLT5wX3JlYWRfYWN0aXZlX2xhc3QtPnJfVElDXzIuY2RhPQorCQkJCShfX3UzMilfX3BhKCZwX2ZpcnN0LT5yZWFkKTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgZWxzZSB7CisgICAgICAgICAgICAgICAgICAgICAgICAvKiBtYWtlIHN1cmUgd2UgdXBkYXRlIHRoZSBDQ1cgc28gY2hhbm5lbCBkb2Vzbid0ICAgKi8KKwkJCS8qIGZldGNoIGl0IHdoZW4gaXQgaXMgb25seSBoYWxmIGRvbmUgICAgICAgICAgICAgICAqLworICAgICAgICAgICAgICAgICAgICAgICAgbWVtY3B5KCAmcF9lbmQtPnJlYWQxX25vcDIsICZ0ZW1wX2NjdyAsCisJCQkJc2l6ZW9mKHN0cnVjdCBjY3cxKSk7CisgICAgICAgICAgICAgICAgICAgICAgICBwcml2cHRyLT5wX3JlYWRfYWN0aXZlX2xhc3QtPnJfVElDXzEuY2RhPQorCQkJCShfX3UzMilfX3BhKCZwX2ZpcnN0LT5yZWFkKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHByaXZwdHItPnBfcmVhZF9hY3RpdmVfbGFzdC0+cl9USUNfMi5jZGE9CisJCQkJKF9fdTMyKV9fcGEoJnBfZmlyc3QtPnJlYWQpOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAvKiAgICAgIGNoYWluIGluIG5ldyBzZXQgb2YgYmxvY2tzICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKi8KKyAgICAg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N0IGNjd2JrKSk7CisgICAgICAgICAgICAgICAgcF9idWY9cF9idWYtPm5leHQ7CisgICAgICAgIH0KKyNlbmRpZgorI2lmZGVmIEZVTkNUUkFDRQorCXByaW50ayhLRVJOX0lORk8gIiVzOiVzIEV4aXQgb24gbGluZSAlZFxuIiwKKwkJZGV2LT5uYW1lLF9fRlVOQ1RJT05fXyxfX0xJTkVfXyk7CisjZW5kaWYKKwlDTEFXX0RCRl9URVhUKDQsdHJhY2UsImFkZGV4aXQiKTsKKyAgICAgICAgcmV0dXJuIDA7Cit9ICAgIC8qICAgICBlbmQgb2YgYWRkX2NsYXdfcmVhZHMgICAqLworCisvKi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0qCisgKiAgIGNjd19jaGVja19yZXR1cm5fY29kZSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqCisgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqCisgKi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0qLworCitzdGF0aWMgdm9pZCBpbmxpbmUKK2Njd19jaGVja19yZXR1cm5fY29kZShzdHJ1Y3QgY2N3X2RldmljZSAqY2RldiwgaW50IHJldHVybl9jb2RlKQoreworI2lmZGVmIEZVTkNUUkFDRQorICAgICAgICBwcmludGsoS0VSTl9JTkZPICIlczogJXMoKSA+IGVudGVyICBcbiIsCisJCWNkZXYtPmRldi5idXNfaWQsX19GVU5DVElPTl9fKTsKKyNlbmRpZgorCUNMQVdfREJGX1RFWFQoNCx0cmFjZSwiY2N3cmV0Iik7CisjaWZkZWYgREVCVUdNU0cKKyAgICAgICAgcHJpbnRrKEtFUk5fSU5GTyAidmFyaWFibGUgY2RldiA9XG4iKTsKKyAgICAgICAgZHVtcGl0KChjaGFyICopIGNkZXYsIHNpemVvZihzdHJ1Y3QgY2N3X2RldmljZSkpOworICAgICAgICBwcmludGsoS0VSTl9JTkZPICJ2YXJpYWJsZSByZXR1cm5fY29kZSA9ICVkXG4iLHJldHVybl9jb2RlKTsKKyNlbmRpZgorICAgICAgICBpZiAocmV0dXJuX2NvZGUgIT0gMCkgeworICAgICAgICAgICAgICAgIHN3aXRjaCAocmV0dXJuX2NvZGUpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgLUVCVVNZOgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcmludGsoS0VSTl9JTkZPICIlczogQnVzeSAhXG4iLAorCQkJCQljZGV2LT5kZXYuYnVzX2lkKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIC1FTk9ERVY6CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByaW50ayhLRVJOX0VNRVJHICIlczogTWlzc2luZyBkZXZpY2UgY2FsbGVkICIKKwkJCQkJImZvciBJTyBFTk9ERVZcbiIsIGNkZXYtPmRldi5idXNfaWQpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgLUVJTzoKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnRrKEtFUk5fRU1FUkcgIiVzOiBTdGF0dXMgcGVuZGluZy4uLiBFSU8gXG4iLAorCQkJCQljZGV2LT5kZXYuYnVzX2lkKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisJCQljYXNlIC1FSU5WQUw6CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByaW50ayhLRVJOX0VNRVJHICIlczogSW52YWxpZCBEZXYgU3RhdGUgRUlOVkFMIFxuIiwKKwkJCQkJY2Rldi0+ZGV2LmJ1c19pZCk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnRrKEtFUk5fRU1FUkcgIiVzOiBVbmtub3duIGVycm9yIGluICIKKwkJCQkgIkRvX0lPICVkXG4iLGNkZXYtPmRldi5idXNfaWQsIHJldHVybl9jb2RlKTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgIH0KKyNpZmRlZiBGVU5DVFJBQ0UKKyAgICAgICAgcHJpbnRrKEtFUk5fSU5GTyAiJXM6ICVzKCkgPiBleGl0IG9uIGxpbmUgJWRcbiIsCisJCWNkZXYtPmRldi5idXNfaWQsX19GVU5DVElPTl9fLF9fTElORV9fKTsKKyNlbmRpZgorCUNMQVdfREJGX1RFWFQoNCx0cmFjZSwiY2N3cmV0Iik7Cit9ICAgIC8qICAgIGVuZCBvZiBjY3dfY2hlY2tfcmV0dXJuX2NvZGUgICAqLworCisvKi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0qCisqICAgICAgIGNjd19jaGVja191bml0X2NoZWNrICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqCisqLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0qLworCitzdGF0aWMgdm9pZCBpbmxpbmUKK2Njd19jaGVja191bml0X2NoZWNrKHN0cnVjdCBjaGJrICogcF9jaCwgdW5zaWduZWQgY2hhciBzZW5zZSApCit7CisJc3RydWN0IG5ldF9kZXZpY2UgKmRldiA9IHBfY2gtPm5kZXY7CisKKyNpZmRlZiBGVU5DVFJBQ0UKKyAgICAgICAgcHJpbnRrKEtFUk5fSU5GTyAiJXM6ICVzKCkgPiBlbnRlclxuIixkZXYtPm5hbWUsX19GVU5DVElPTl9fKTsKKyNlbmRpZgorI2lmZGVmIERFQlVHTVNHCisgICAgICAgIHByaW50ayhLRVJOX0lORk8gIiVzOiB2YXJpYWJsZSBkZXYgPVxuIixkZXYtPm5hbWUpOworICAgICAgICBkdW1waXQoKGNoYXIgKilkZXYsIHNpemVvZihzdHJ1Y3QgbmV0X2RldmljZSkpOworICAgICAgICBwcmludGsoS0VSTl9JTkZPICIlczogdmFyaWFibGUgc2Vuc2UgPVxuIixkZXYtPm5hbWUpOworICAgICAgICBkdW1waXQoKGNoYXIgKikmc2Vuc2UsIDIpOworI2VuZGlmCisJQ0xBV19EQkZfVEVYVCg0LHRyYWNlLCJ1bml0Y2hlayIpOworCisgICAgICAgIHByaW50ayhLRVJOX0lORk8gIiVzOiBVbml0IENoZWNrIHdpdGggc2Vuc2UgYnl0ZToweCUwNHhcbiIsCisgICAgICAgICAgICAgICAgZGV2LT5uYW1lLCBzZW5zZSk7CisKKyAgICAgICAgaWYgKHNlbnNlICYgMHg0MCkgeworICAgICAgICAgICAgICAgIGlmIChzZW5zZSAmIDB4MDEpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIHByaW50ayhLRVJOX1dBUk5JTkcgIiVzOiBJbnRlcmZhY2UgZGlzY29ubmVjdCBvciAiCisJCQkJIlNlbGVjdGl2ZSByZXNldCAiCisJCQkgICAgICAgCSJvY2N1cnJlZCAocmVtb3RlIHNpZGUpXG4iLCBkZXYtPm5hbWUpOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBlbHNlIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIHByaW50ayhLRVJOX1dBUk5JTkcgIiVzOiBTeXN0ZW0gcmVzZXQgb2NjdXJlZCIKKwkJCQkiIChyZW1vdGUgc2lkZSlcbiIsIGRldi0+bmFtZSk7CisgICAgICAgICAgICAgICAgfQorICAgICAgICB9CisgICAgICAgIGVsc2UgaWYgKHNlbnNlICYgMHgyMCkgeworICAgICAgICAgICAgICAgIGlmIChzZW5zZSAmIDB4MDQpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIHByaW50ayhLRVJOX1dBUk5JTkcgIiVzOiBEYXRhLXN0cmVhbWluZyAiCisJCQkJInRpbWVvdXQpXG4iLCBkZXYtPm5hbWUpOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBlbHNlICB7CisgICAgICAgICAgICAgICAgICAgICAgICBwcmludGsoS0VSTl9XQVJOSU5HICIlczogRGF0YS10cmFuc2ZlciBwYXJpdHkiCisJCQkJIiBlcnJvclxuIiwgZGV2LT5uYW1lKTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgIH0KKyAgICAgICAgZWxzZSBpZiAoc2Vuc2UgJiAweDEwKSB7CisgICAgICAgICAgICAgICAgaWYgKHNlbnNlICYgMHgyMCkgeworICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnRrKEtFUk5fV0FSTklORyAiJXM6IEhhcmR3YXJlIG1hbGZ1bmN0aW9uICIKKwkJCQkiKHJlbW90ZSBzaWRlKVxuIiwgZGV2LT5uYW1lKTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgZWxzZSB7CisgICAgICAgICAgICAgICAgICAgICAgICBwcmludGsoS0VSTl9XQVJOSU5HICIlczogcmVhZC1kYXRhIHBhcml0eSBlcnJvciAiCisJCQkJIihyZW1vdGUgc2lkZSlcbiIsIGRldi0+bmFtZSk7CisgICAgICAgICAgICAgICAgfQorICAgICAgICB9CisKKyNpZmRlZiBGVU5DVFJBQ0UKKyAgICAgICAgcHJpbnRrKEtFUk5fSU5GTyAiJXM6ICVzKCkgZXhpdCBvbiBsaW5lICVkXG4iLAorCQlkZXYtPm5hbWUsX19GVU5DVElPTl9fLF9fTElORV9fKTsKKyNlbmRpZgorfSAgIC8qICAgIGVuZCBvZiBjY3dfY2hlY2tfdW5pdF9jaGVjayAgICAqLworCisKKworLyotLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKgorKiBEdW1wIGJ1ZmZlciBmb3JtYXQgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKgorKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKgorKi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKi8KKyNpZmRlZiBERUJVRworc3RhdGljIHZvaWQKK2R1bXBpdChjaGFyKiBidWYsIGludCBsZW4pCit7CisKKyAgICAgICAgX191MzIgICAgICBjdCwgc3csIHJtLCBkdXA7CisgICAgICAgIGNoYXIgICAgICAgKnB0ciwgKnJwdHI7CisgICAgICAgIGNoYXIgICAgICAgdGJ1Zls4Ml0sIHRkdXBbODJdOworI2lmIChDT05GSUdfQVJDSF9TMzkwWCkKKyAgICAgICAgY2hhciAgICAgICBhZGRyWzIyXTsKKyNlbHNlCisgICAgICAgIGNoYXIgICAgICAgYWRkclsxMl07CisjZW5kaWYKKyAgICAgICAgY2hhciAgICAgICBib2ZmWzEyXTsKKyAgICAgICAgY2hhciAgICAgICBiaGV4WzgyXSwgZHVwaGV4WzgyXTsKKyAgICAgICAgY2hhciAgICAgICBiYXNjWzQwXTsKKworICAgICAgICBzdyAgPSAwOworICAgICAgICBycHRyID1wdHI9YnVmOworICAgICAgICBybSAgPSAxNjsKKyAgICAgICAgZHVwaGV4WzBdICA9IDB4MDA7CisgICAgICAgIGR1cCA9IDA7CisgICAgICAgIGZvciAoIGN0PTA7IGN0IDwgbGVuOyBjdCsrLCBwdHIrKywgcnB0cisrICkgIHsKKyAgICAgICAgICAgICAgICBpZiAoc3cgPT0gMCkgeworI2lmIChDT05GSUdfQVJDSF9TMzkwWCkKKyAgICAgICAgICAgICAgICAgICAgICAgIHNwcmludGYoYWRkciwgIiUxNi4xNmxYIiwodW5zaWduZWQgbG9uZylycHRyKTsKKyNlbHNlCisgICAgICAgICAgICAgICAgICAgICAgICBzcHJpbnRmKGFkZHIsICIlOC44WCIsKF9fdTMyKXJwdHIpOworI2VuZGlmCisgICAgICAgICAgICAgICAgICAgICAgICBzcHJpbnRmKGJvZmYsICIlNC40WCIsIChfX3UzMiljdCk7CisgICAgICAgICAgICAgICAgICAgICAgICBiaGV4WzBdID0gJ1wwJzsKKyAgICAgICAgICAgICAgICAgICAgICAgIGJhc2NbMF0gPSAnXDAnOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBpZiAoKHN3ID09IDQpIHx8IChzdyA9PSAxMikpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIHN0cmNhdChiaGV4LCAiICIpOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBpZiAoc3cgPT0gOCkgeworICAgICAgICAgICAgICAgICAgICAgICAgc3RyY2F0KGJoZXgsICIgICIpOworICAgICAgICAgICAgICAgIH0KKyNpZiAoQ09ORklHX0FSQ0hfUzM5MFgpCisgICAgICAgICAgICAgICAgc3ByaW50Zih0YnVmLCIlMi4ybFgiLCAodW5zaWduZWQgbG9uZykqcHRyKTsKKyNlbHNlCisgICAgICAgICAgICAgICAgc3ByaW50Zih0YnVmLCIlMi4yWCIsIChfX3UzMikqcHRyKTsKKyNlbmRpZgorICAgICAgICAgICAgICAgIHRidWZbMl0gPSAnXDAnOworICAgICAgICAgICAgICAgIHN0cmNhdChiaGV4LCB0YnVmKTsKKyAgICAgICAgICAgICAgICBpZiAoKDAhPWlzcHJpbnQoKnB0cikpICYmICgqcHRyID49IDB4MjApKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBiYXNjW3N3XSA9ICpwdHI7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIGVsc2UgeworICAgICAgICAgICAgICAgICAgICAgICAgYmFzY1tzd10gPSAnLic7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIGJhc2Nbc3crMV0gPSAnXDAnOworICAgICAgICAgICAgICAgIHN3Kys7CisgICAgICAgICAgICAgICAgcm0tLTsKKyAgICAgICAgICAgICAgICBpZiAoc3c9PTE2KSB7CisgICAgICAgICAgICAgICAgICAgICAgICBpZiAoKHN0cmNtcChkdXBoZXgsIGJoZXgpKSAhPTApIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGR1cCAhPTApIHsKKwkJCQkJc3ByaW50Zih0ZHVwLCJEdXBsaWNhdGUgYXMgYWJvdmUgdG8iCisJCQkJCQkiICVzIiwgYWRkcik7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnRrKCBLRVJOX0lORk8gIiAgICAgICAgICAgICAgICAgIgorCQkJCQkJIiAgIC0tLSAlcyAtLS1cbiIsdGR1cCk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnRrKCBLRVJOX0lORk8gIiAgICVzICgrJXMpIDogJXMgIFslc11cbiIsCisJCQkJCSBhZGRyLCBib2ZmLCBiaGV4LCBiYXNjKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZHVwID0gMDsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyY3B5KGR1cGhleCwgYmhleCk7CisgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgICAgICBlbHNlIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZHVwKys7CisgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgICAgICBzdyA9IDA7CisgICAgICAgICAgICAgICAgICAgICAgICBybSA9IDE2OworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgfSAgLyogZW5kZm9yICovCisKKyAgICAgICAgaWYgKHN3ICE9IDApIHsKKyAgICAgICAgICAgICAgICBmb3IgKCA7IHJtID4gMDsgcm0tLSwgc3crKyApIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIGlmICgoc3c9PTQpIHx8IChzdz09MTIpKSBzdHJjYXQoYmhleCwgIiAiKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzdz09OCkgICAgICAgICAgICAgICBzdHJjYXQoYmhleCwgIiAgIik7CisgICAgICAgICAgICAgICAgICAgICAgICBzdHJjYXQoYmhleCwgIiAgIik7CisgICAgICAgICAgICAgICAgICAgICAgICBzdHJjYXQoYmFzYywgIiAiKTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgaWYgKGR1cCAhPTApIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIHNwcmludGYodGR1cCwiRHVwbGljYXRlIGFzIGFib3ZlIHRvICVzIiwgYWRkcik7CisgICAgICAgICAgICAgICAgICAgICAgICBwcmludGsoIEtFUk5fSU5GTyAiICAgICAgICAgICAgICAgICAgICAtLS0gJXMgLS0tXG4iLAorCQkJCXRkdXApOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBwcmludGsoIEtFUk5fSU5GTyAiICAgJXMgKCslcykgOiAlcyAgWyVzXVxuIiwKKwkJCWFkZHIsIGJvZmYsIGJoZXgsIGJhc2MpOworICAgICAgICB9CisgICAgICAgIGVsc2UgeworICAgICAgICAgICAgICAgIGlmIChkdXAgPj0xKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBzcHJpbnRmKHRkdXAsIkR1cGxpY2F0ZSBhcyBhYm92ZSB0byAlcyIsIGFkZHIpOworICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnRrKCBLRVJOX0lORk8gIiAgICAgICAgICAgICAgICAgICAgLS0tICVzIC0tLVxuIiwKKwkJCQl0ZHVwKTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgaWYgKGR1cCAhPTApIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIHByaW50ayggS0VSTl9JTkZPICIgICAlcyAoKyVzKSA6ICVzICBbJXNdXG4iLAorCQkJCWFkZHIsIGJvZmYsIGJoZXgsIGJhc2MpOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgfQorICAgICAgICByZXR1cm47CisKK30gICAvKiAgIGVuZCBvZiBkdW1waXQgICovCisjZW5kaWYKKworLyotLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKgorKiAgICAgICAgICAgICAgIGZpbmRfbGluayAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKgorKi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKi8KK3N0YXRpYyBpbnQKK2ZpbmRfbGluayhzdHJ1Y3QgbmV0X2RldmljZSAqZGV2LCBjaGFyICpob3N0X25hbWUsIGNoYXIgKndzX25hbWUgKQoreworCXN0cnVjdCBjbGF3X3ByaXZiayAqcHJpdnB0cjsKKwlzdHJ1Y3QgY2xhd19lbnYgKnBfZW52OworCWludCAgICByYz0wOworCisjaWZkZWYgRlVOQ1RSQUNFCisgICAgICAgIHByaW50ayhLRVJOX0lORk8gIiVzOiVzID4gZW50ZXIgIFxuIixkZXYtPm5hbWUsX19GVU5DVElPTl9fKTsKKyNlbmRpZgorCUNMQVdfREJGX1RFWFQoMixzZXR1cCwiZmluZGxpbmsiKTsKKyNpZmRlZiBERUJVR01TRworICAgICAgICBwcmludGsoS0VSTl9JTkZPICIlczogdmFyaWFibGUgZGV2ID0gXG4iLGRldi0+bmFtZSk7CisgICAgICAgIGR1bXBpdCgoY2hhciAqKSBkZXYsIHNpemVvZihzdHJ1Y3QgbmV0X2RldmljZSkpOworICAgICAgICBwcmludGsoS0VSTl9JTkZPICIlczogdmFyaWFibGUgaG9zdF9uYW1lID0gJXNcbiIsZGV2LT5uYW1lLCBob3N0X25hbWUpOworICAgICAgICBwcmludGsoS0VSTl9JTkZPICIlczogdmFyaWFibGUgd3NfbmFtZSA9ICVzXG4iLGRldi0+bmFtZSwgd3NfbmFtZSk7CisjZW5kaWYKKyAgICAgICAgcHJpdnB0cj1kZXYtPnByaXY7CisgICAgICAgIHBfZW52PXByaXZwdHItPnBfZW52OworCXN3aXRjaCAocF9lbnYtPnBhY2tpbmcpCisJeworCQljYXNlICBQQUNLSU5HX0FTSzoKKwkJCWlmICgobWVtY21wKFdTX0FQUExfTkFNRV9QQUNLRUQsIGhvc3RfbmFtZSwgOCkhPTApIHx8CisJCQkgICAgKG1lbWNtcChXU19BUFBMX05BTUVfUEFDS0VELCB3c19uYW1lLCA4KSE9MCApKQorICAgICAgICAJICAgICAgICAgICAgIHJjID0gRUlOVkFMOworCQkJYnJlYWs7CisJCWNhc2UgIERPX1BBQ0tFRDoKKwkJY2FzZSAgUEFDS19TRU5EOgorCQkJaWYgKChtZW1jbXAoV1NfQVBQTF9OQU1FX0lQX05BTUUsIGhvc3RfbmFtZSwgOCkhPTApIHx8CisJCQkgICAgKG1lbWNtcChXU19BUFBMX05BTUVfSVBfTkFNRSwgd3NfbmFtZSwgOCkhPTAgKSkKKyAgICAgICAgCSAgICAgICAgCXJjID0gRUlOVkFMOworCQkJYnJlYWs7CisJCWRlZmF1bHQ6CisJICAgICAgIAkJaWYgKChtZW1jbXAoSE9TVF9BUFBMX05BTUUsIGhvc3RfbmFtZSwgOCkhPTApIHx8CisJCSAgICAJICAgIChtZW1jbXAocF9lbnYtPmFwaV90eXBlICwgd3NfbmFtZSwgOCkhPTApKQorICAgICAgICAJICAgICAgICAJcmMgPSBFSU5WQUw7CisJCQlicmVhazsKKwl9CisKKyNpZmRlZiBGVU5DVFJBQ0UKKyAgICAgICAgcHJpbnRrKEtFUk5fSU5GTyAiJXM6JXMgRXhpdCBvbiBsaW5lICVkXG4iLAorCQlkZXYtPm5hbWUsX19GVU5DVElPTl9fLF9fTElORV9fKTsKKyNlbmRpZgorICAgICAgICByZXR1cm4gMDsKK30gICAgLyogICAgZW5kIG9mIGZpbmRfbGluayAgICAqLworCisvKi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0qCisgKiAgIGNsYXdfaHdfdHggICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqCisgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqCisgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqCisgKi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0qLworCitzdGF0aWMgaW50CitjbGF3X2h3X3R4KHN0cnVjdCBza19idWZmICpza2IsIHN0cnVjdCBuZXRfZGV2aWNlICpkZXYsIGxvbmcgbGlua2lkKQoreworICAgICAgICBpbnQgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJjPTA7CisgICAgICAgIHN0cnVjdCBjbGF3X3ByaXZiayAJCSpwcml2cHRyOworICAgICAgICBzdHJ1Y3QgY2N3YmsgICAgICAgICAgICpwX3RoaXNfY2N3OworICAgICAgICBzdHJ1Y3QgY2N3YmsgICAgICAgICAgICpwX2ZpcnN0X2NjdzsKKyAgICAgICAgc3RydWN0IGNjd2JrICAgICAgICAgICAqcF9sYXN0X2NjdzsKKyAgICAgICAgX191MzIgICAgICAgICAgICAgICAgICAgICAgICAgICBudW1CdWZmZXJzOworICAgICAgICBzaWduZWQgbG9uZyAgICAgICAgICAgICAgICAgICAgIGxlbl9vZl9kYXRhOworICAgICAgICB1bnNpZ25lZCBsb25nICAgICAgICAgICAgICAgICAgIGJ5dGVzSW5UaGlzQnVmZmVyOworICAgICAgICB1bnNpZ25lZCBjaGFyICAgICAgICAgICAgICAgICAgICpwRGF0YUFkZHJlc3M7CisgICAgICAgIHN0cnVjdCBlbmRjY3cgICAgICAgICAgICAgICAgICAgKnBFbmQ7CisgICAgICAgIHN0cnVjdCBjY3cxICAgICAgICAgICAgICAgICAgICAgdGVtcENDVzsKKyAgICAgICAgc3RydWN0IGNoYmsgICAgICAgICAgICAgICAgICAgICAqcF9jaDsKKwlzdHJ1Y3QgY2xhd19lbnYJCQkqcF9lbnY7CisgICAgICAgIGludCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9jazsKKwlzdHJ1Y3QgY2xhd3BoCQkJKnBrX2hlYWQ7CisJc3RydWN0IGNoYmsJCQkqY2g7CisjaWZkZWYgSU9UUkFDRQorICAgICAgICBzdHJ1Y3QgY2N3YmsgICAgICAgICAgICAgICAgICAgKnBfYnVmOworI2VuZGlmCisjaWZkZWYgRlVOQ1RSQUNFCisgICAgICAgIHByaW50ayhLRVJOX0lORk8gIiVzOiAlcygpID4gZW50ZXJcbiIsZGV2LT5uYW1lLF9fRlVOQ1RJT05fXyk7CisjZW5kaWYKKwlDTEFXX0RCRl9URVhUKDQsdHJhY2UsImh3X3R4Iik7CisjaWZkZWYgREVCVUdNU0cKKyAgICAgICAgcHJpbnRrKEtFUk5fSU5GTyAiJXM6IHZhcmlhYmxlIGRldiBza2IgPVxuIixkZXYtPm5hbWUpOworICAgICAgICBkdW1waXQoKGNoYXIgKikgc2tiLCBzaXplb2Yoc3RydWN0IHNrX2J1ZmYpKTsKKyAgICAgICAgcHJpbnRrKEtFUk5fSU5GTyAiJXM6IHZhcmlhYmxlIGRldiA9XG4iLGRldi0+bmFtZSk7CisgICAgICAgIGR1bXBpdCgoY2hhciAqKSBkZXYsIHNpemVvZihzdHJ1Y3QgbmV0X2RldmljZSkpOworICAgICAgICBwcm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ZWFkLT5sZW4lNCkpOworCQkJc2tiX3B1dChza2IsNC0ocGtfaGVhZC0+bGVuJTQpKTsKKwkJfQorCQlpZiAocF9lbnYtPnBhY2tpbmcgPT0gRE9fUEFDS0VEKQorCQkJcGtfaGVhZC0+bGlua19udW0gPSBsaW5raWQ7CisJCWVsc2UKKwkJCXBrX2hlYWQtPmxpbmtfbnVtID0gMDsKKwkJcGtfaGVhZC0+ZmxhZyA9IDB4MDA7CisJCXNrYl9wYWQoc2tiLDQpOworCQlza2ItPmNiWzFdID0gJ1AnOworCX0KKyAgICAgICAgaWYgKGxpbmtpZCA9PSAwKSB7CisgICAgICAgIAlpZiAoY2xhd19jaGVja19idXN5KGRldikpIHsKKyAgICAgICAgICAgICAgICAJaWYgKHByaXZwdHItPndyaXRlX2ZyZWVfY291bnQhPTApIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xhd19jbGVhcl9idXN5KGRldik7CisgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgICAgICBlbHNlIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xhd19zdHJ0X291dF9JTyhkZXYgKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xhd19mcmVlX3dydF9idWYoIGRldiApOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocHJpdnB0ci0+d3JpdGVfZnJlZV9jb3VudD09MCkgeworI2lmZGVmIElPVFJBQ0UKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCXByaW50ayhLRVJOX0lORk8gIiVzOiAiCisJCQkJCSAgICIoY2xhd19jaGVja19idXN5KSBubyBmcmVlIHdyaXRlICIKKwkJCQkJICAgImJ1ZmZlcnNcbiIsIGRldi0+bmFtZSk7CisjZW5kaWYKKwkJCQkJY2ggPSAmcHJpdnB0ci0+Y2hhbm5lbFtXUklURV07CisJCQkJCWF0b21pY19pbmMoJnNrYi0+dXNlcnMpOworCQkJCQlza2JfcXVldWVfdGFpbCgmY2gtPmNvbGxlY3RfcXVldWUsIHNrYik7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAlnb3RvIERvbmU7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxzZSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAljbGF3X2NsZWFyX2J1c3koZGV2KTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAvKiAgdHggbG9jayAgKi8KKyAgICAgICAgICAgICAgICBpZiAoY2xhd190ZXN0X2FuZF9zZXRiaXRfYnVzeShUQl9UWCxkZXYpKSB7IC8qIHNldCB0byBidXN5ICovCisjaWZkZWYgREVCVUdNU0cKKyAgICAgICAgICAgICAgICAgICAgICAgIHByaW50ayhLRVJOX0lORk8gIiVzOiAgYnVzeSAgKGNsYXdfdGVzdF9hbmRfc2V0Yml0XyIKKwkJCQkiYnVzeSlcbiIsIGRldi0+bmFtZSk7CisjZW5kaWYKKwkJCWNoID0gJnByaXZwdHItPmNoYW5uZWxbV1JJVEVdOworCQkJYXRvbWljX2luYygmc2tiLT51c2Vycyk7CisJCQlza2JfcXVldWVfdGFpbCgmY2gtPmNvbGxlY3RfcXVldWUsIHNrYik7CisgICAgICAgICAgICAgICAgICAgICAgICBjbGF3X3N0cnRfb3V0X0lPKGRldiApOworICAgICAgICAgICAgICAgICAgICAgICAgcmM9LUVCVVNZOworICAgICAgICAgICAgICAgICAgICAgICAgZ290byBEb25lMjsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgIH0KKyAgICAgICAgLyogICAgICBTZWUgaG93IG1hbnkgd3JpdGUgYnVmZmVycyBhcmUgcmVxdWlyZWQgdG8gaG9sZCB0aGlzIGRhdGEgKi8KKyAgICAgICAgbnVtQnVmZmVycz0gKCBza2ItPmxlbiArIHByaXZwdHItPnBfZW52LT53cml0ZV9zaXplIC0gMSkgLworCQkJKCBwcml2cHRyLT5wX2Vudi0+d3JpdGVfc2l6ZSk7CisKKyAgICAgICAgLyogICAgICBJZiB0aGF0IG51bWJlciBvZiBidWZmZXJzIGlzbid0IGF2YWlsYWJsZSwgZ2l2ZSB1cCBmb3Igbm93ICovCisgICAgICAgIGlmIChwcml2cHRyLT53cml0ZV9mcmVlX2NvdW50IDwgbnVtQnVmZmVycyB8fAorICAgICAgICAgICAgcHJpdnB0ci0+cF93cml0ZV9mcmVlX2NoYWluID09IE5VTEwgKSB7CisKKyAgICAgICAgICAgICAgICBjbGF3X3NldGJpdF9idXN5KFRCX05PQlVGRkVSLGRldik7CisKKyNpZmRlZiBERUJVR01TRworICAgICAgICAgICAgICAgIHByaW50ayhLRVJOX0lORk8gIiVzOiAgYnVzeSAgKGNsYXdfc2V0Yml0X2J1c3kiCisJCQkiKFRCX05PQlVGRkVSKSlcbiIsIGRldi0+bmFtZSk7CisgICAgICAgICAgICAgICAgcHJpbnRrKEtFUk5fSU5GTyAiICAgICAgIGZyZWVfY291bnQ6ICVkLCBudW1CdWZmZXJzIDogJWRcbiIsCisJCQkoaW50KXByaXZwdHItPndyaXRlX2ZyZWVfY291bnQsKGludCkgbnVtQnVmZmVycyApOworI2VuZGlmCisJCWNoID0gJnByaXZwdHItPmNoYW5uZWxbV1JJVEVdOworCQlhdG9taWNfaW5jKCZza2ItPnVzZXJzKTsKKwkJc2tiX3F1ZXVlX3RhaWwoJmNoLT5jb2xsZWN0X3F1ZXVlLCBza2IpOworCQlDTEFXX0RCRl9URVhUKDIsdHJhY2UsImNsYXdidXN5Iik7CisgICAgICAgICAgICAgICAgZ290byBEb25lMjsKKyAgICAgICAgfQorICAgICAgICBwRGF0YUFkZHJlc3M9c2tiLT5kYXRhOworICAgICAgICBsZW5fb2ZfZGF0YT1za2ItPmxlbjsKKworICAgICAgICB3aGlsZSAobGVuX29mX2RhdGEgPiAwKSB7CisjaWZkZWYgREVCVUdNU0cKKyAgICAgICAgICAgICAgICBwcmludGsoS0VSTl9JTkZPICIlczogJXMoKSBsZW5ndGgtb2YtZGF0YSBpcyAlbGQgXG4iLAorCQkJZGV2LT5uYW1lICxfX0ZVTkNUSU9OX18sbGVuX29mX2RhdGEpOworICAgICAgICAgICAgICAgIGR1bXBpdCgoY2hhciAqKXBEYXRhQWRkcmVzcyAsNjQpOworI2VuZGlmCisgICAgICAgICAgICAgICAgcF90aGlzX2Njdz1wcml2cHRyLT5wX3dyaXRlX2ZyZWVfY2hhaW47ICAvKiBnZXQgYSBibG9jayAqLworCQlpZiAocF90aGlzX2NjdyA9PSBOVUxMKSB7IC8qIGxvc3QgdGhlIHJhY2UgKi8KKwkJCWNoID0gJnByaXZwdHItPmNoYW5uZWxbV1JJVEVdOworCQkJYXRvbWljX2luYygmc2tiLT51c2Vycyk7CisJCQlza2JfcXVldWVfdGFpbCgmY2gtPmNvbGxlY3RfcXVldWUsIHNrYik7CisJCQlnb3RvIERvbmUyOworCQl9CisgICAgICAgICAgICAgICAgcHJpdnB0ci0+cF93cml0ZV9mcmVlX2NoYWluPXBfdGhpc19jY3ctPm5leHQ7CisgICAgICAgICAgICAgICAgcF90aGlzX2Njdy0+bmV4dD1OVUxMOworICAgICAgICAgICAgICAgIC0tcHJpdnB0ci0+d3JpdGVfZnJlZV9jb3VudDsgLyogLTEgKi8KKyAgICAgICAgICAgICAgICBieXRlc0luVGhpc0J1ZmZlcj1sZW5fb2ZfZGF0YTsKKyAgICAgICAgICAgICAgICBtZW1jcHkoIHBfdGhpc19jY3ctPnBfYnVmZmVyLHBEYXRhQWRkcmVzcywgYnl0ZXNJblRoaXNCdWZmZXIpOworICAgICAgICAgICAgICAgIGxlbl9vZl9kYXRhLT1ieXRlc0luVGhpc0J1ZmZlcjsKKyAgICAgICAgICAgICAgICBwRGF0YUFkZHJlc3MrPSh1bnNpZ25lZCBsb25nKWJ5dGVzSW5UaGlzQnVmZmVyOworICAgICAgICAgICAgICAgIC8qICAgICAgc2V0dXAgd3JpdGUgQ0NXICAgICAgICAgKi8KKyAgICAgICAgICAgICAgICBwX3RoaXNfY2N3LT53cml0ZS5jbWRfY29kZSA9IChsaW5raWQgKiA4KSArMTsKKyAgICAgICAgICAgICAgICBpZiAobGVuX29mX2RhdGE+MCkgeworICAgICAgICAgICAgICAgICAgICAgICAgcF90aGlzX2Njdy0+d3JpdGUuY21kX2NvZGUrPU1PUkVfdG9fQ09NRV9GTEFHOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBwX3RoaXNfY2N3LT53cml0ZS5jb3VudD1ieXRlc0luVGhpc0J1ZmZlcjsKKyAgICAgICAgICAgICAgICAvKiAgICAgIG5vdyBhZGQgdG8gZW5kIG9mIHRoaXMgY2hhaW4gICAgKi8KKyAgICAgICAgICAgICAgICBpZiAocF9maXJzdF9jY3c9PU5VTEwpICAgIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIHBfZmlyc3RfY2N3PXBfdGhpc19jY3c7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIGlmIChwX2xhc3RfY2N3IT1OVUxMKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBwX2xhc3RfY2N3LT5uZXh0PXBfdGhpc19jY3c7CisgICAgICAgICAgICAgICAgICAgICAgICAvKiAgICAgIHNldCB1cCBUSUMgY2N3cyAgICAgICAgICovCisgICAgICAgICAgICAgICAgICAgICAgICBwX2xhc3RfY2N3LT53X1RJQ18xLmNkYT0KKwkJCQkoX191MzIpX19wYSgmcF90aGlzX2Njdy0+d3JpdGUpOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBwX2xhc3RfY2N3PXBfdGhpc19jY3c7ICAgICAgLyogc2F2ZSBuZXcgbGFzdCBibG9jayAqLworI2lmZGVmIElPVFJBQ0UKKwkJcHJpbnRrKEtFUk5fSU5GTyAiJXM6ICVzKCkgPiBDQ1cgYW5kIEJ1ZmZlciAlbGQgYnl0ZXMgbG9uZyBcbiIsCisJCQlkZXYtPm5hbWUsX19GVU5DVElPTl9fLGJ5dGVzSW5UaGlzQnVmZmVyKTsKKyAgICAgICAgICAgICAgICBkdW1waXQoKGNoYXIgKilwX3RoaXNfY2N3LCBzaXplb2Yoc3RydWN0IGNjd2JrKSk7CisgICAgICAgICAgICAgICAgZHVtcGl0KChjaGFyICopcF90aGlzX2Njdy0+cF9idWZmZXIsIDY0KTsKKyNlbmRpZgorICAgICAgICB9CisKKyAgICAgICAgLyogICAgICBGaXJzdENDVyBhbmQgTGFzdENDVyBub3cgY29udGFpbiBhIG5ldyBzZXQgb2Ygd3JpdGUgY2hhbm5lbAorICAgICAgICAqICAgICAgIHByb2dyYW1zIHRvIGFwcGVuZCB0byB0aGUgcnVubmluZyBjaGFubmVsIHByb2dyYW0KKyAgICAgICAgKi8KKworICAgICAgICBpZiAocF9maXJzdF9jY3chPU5VTEwpIHsKKyAgICAgICAgICAgICAgICAvKiAgICAgIHNldHVwIGVuZGluZyBjY3cgc2VxdWVuY2UgZm9yIHRoaXMgc2VnbWVudCAgICAgICAgICAgICAgKi8KKyAgICAgICAgICAgICAgICBwRW5kPXByaXZwdHItPnBfZW5kX2NjdzsKKyAgICAgICAgICAgICAgICBpZiAocEVuZC0+d3JpdGUxKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBwRW5kLT53cml0ZTE9MHgwMDsgICAvKiBzZWNvbmQgZW5kIGNjdyBpcyBub3cgYWN0aXZlICovCisgICAgICAgICAgICAgICAgICAgICAgICAvKiAgICAgIHNldCB1cCBUaWMgQ0NXcyAgICAgICAgICovCisgICAgICAgICAgICAgICAgICAgICAgICBwX2xhc3RfY2N3LT53X1RJQ18xLmNkYT0KKwkJCQkoX191MzIpX19wYSgmcEVuZC0+d3JpdGUyX25vcDEpOworICAgICAgICAgICAgICAgICAgICAgICAgcEVuZC0+d3JpdGUyX25vcDIuY21kX2NvZGUgPSBDQ1dfQ0xBV19DTURfUkVBREZGOworICAgICAgICAgICAgICAgICAgICAgICAgcEVuZC0+d3JpdGUyX25vcDIuZmxhZ3MgICAgPQorCQkJCUNDV19GTEFHX1NMSSB8IENDV19GTEFHX1NLSVA7CisgICAgICAgICAgICAgICAgICAgICAgICBwRW5kLT53cml0ZTJfbm9wMi5jZGE9MDsKKyAgICAgICAgICAgICAgICAgICAgICAgIHBFbmQtPndyaXRlMl9ub3AyLmNvdW50PTE7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIGVsc2UgeyAgLyogIGVuZCBvZiBpZiAocEVuZC0+d3JpdGUxKSovCisgICAgICAgICAgICAgICAgICAgICAgICBwRW5kLT53cml0ZTE9MHgwMTsgICAvKiBmaXJzdCBlbmQgY2N3IGlzIG5vdyBhY3RpdmUgKi8KKyAgICAgICAgICAgICAgICAgICAgICAgIC8qICAgICAgc2V0IHVwIFRpYyBDQ1dzICAgICAgICAgKi8KKyAgICAgICAgICAgICAgICAgICAgICAgIHBfbGFzdF9jY3ctPndfVElDXzEuY2RhPQorCQkJCShfX3UzMilfX3BhKCZwRW5kLT53cml0ZTFfbm9wMSk7CisgICAgICAgICAgICAgICAgICAgICAgICBwRW5kLT53cml0ZTFfbm9wMi5jbWRfY29kZSA9IENDV19DTEFXX0NNRF9SRUFERkY7CisgICAgICAgICAgICAgICAgICAgICAgICBwRW5kLT53cml0ZTFfbm9wMi5mbGFncyAgICA9CisJCQkJQ0NXX0ZMQUdfU0xJIHwgQ0NXX0ZMQUdfU0tJUDsKKyAgICAgICAgICAgICAgICAgICAgICAgIHBFbmQtPndyaXRlMV9ub3AyLmNkYT0wOworICAgICAgICAgICAgICAgICAgICAgICAgcEVuZC0+d3JpdGUxX25vcDIuY291bnQ9MTsKKyAgICAgICAgICAgICAgICB9ICAvKiBlbmQgaWYgaWYgKHBFbmQtPndyaXRlMSkgKi8KKworCisgICAgICAgICAgICAgICAgaWYgKHByaXZwdHItPnBfd3JpdGVfYWN0aXZlX2ZpcnN0PT1OVUxMICkgeworICAgICAgICAgICAgICAgICAgICAgICAgcHJpdnB0ci0+cF93cml0ZV9hY3RpdmVfZmlyc3Q9cF9maXJzdF9jY3c7CisgICAgICAgICAgICAgICAgICAgICAgICBwcml2cHRyLT5wX3dyaXRlX2FjdGl2ZV9sYXN0PXBfbGFzdF9jY3c7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIGVsc2UgeworCisgICAgICAgICAgICAgICAgICAgICAgICAvKiAgICAgIHNldCB1cCBUaWMgQ0NXcyAgICAgICAgICovCisKKyAgICAgICAgICAgICAgICAgICAgICAgIHRlbXBDQ1cuY2RhPShfX3UzMilfX3BhKCZwX2ZpcnN0X2Njdy0+d3JpdGUpOworICAgICAgICAgICAgICAgICAgICAgICAgdGVtcENDVy5jb3VudD0wOworICAgICAgICAgICAgICAgICAgICAgICAgdGVtcENDVy5mbGFncz0wOworICAgICAgICAgICAgICAgICAgICAgICAgdGVtcENDVy5jbWRfY29kZT1DQ1dfQ0xBV19DTURfVElDOworCisgICAgICAgICAgICAgICAgICAgICAgICBpZiAocEVuZC0+d3JpdGUxKSB7CisKKyAgICAgICAgICAgICAgICAgLyoKKyAgICAgICAgICAgICAgICAgKiBmaXJzdCBzZXQgb2YgZW5kaW5nIENDVydzIGlzIGNoYWluZWQgdG8gdGhlIG5ldyB3cml0ZQorICAgICAgICAgICAgICAgICAqIGNoYWluLCBzbyB0aGUgc2Vjb25kIHNldCBpcyBjaGFpbmVkIHRvIHRoZSBhY3RpdmUgY2hhaW4KKyAgICAgICAgICAgICAgICAgKiBUaGVyZWZvcmUgbW9kaWZ5IHRoZSBzZWNvbmQgc2V0IHRvIHBvaW50IHRoZSBuZXcgd3JpdGUgY2hhaW4uCisgICAgICAgICAgICAgICAgICogbWFrZSBzdXJlIHdlIHVwZGF0ZSB0aGUgQ0NXIGF0b21pY2FsbHkKKyAgICAgICAgICAgICAgICAgKiBzbyBjaGFubmVsIGRvZXMgbm90IGZldGNoIGl0IHdoZW4gaXQncyBvbmx5IGhhbGYgZG9uZQorICAgICAgICAgICAgICAgICAqLworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtZW1jcHkoICZwRW5kLT53cml0ZTJfbm9wMiwgJnRlbXBDQ1cgLAorCQkJCQlzaXplb2Yoc3RydWN0IGNjdzEpKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJpdnB0ci0+cF93cml0ZV9hY3RpdmVfbGFzdC0+d19USUNfMS5jZGE9CisJCQkJCShfX3UzMilfX3BhKCZwX2ZpcnN0X2Njdy0+d3JpdGUpOworICAgICAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICAgICAgZWxzZSB7CisKKyAgICAgICAgICAgICAgICAgICAgICAgIC8qbWFrZSBzdXJlIHdlIHVwZGF0ZSB0aGUgQ0NXIGF0b21pY2FsbHkKKyAgICAgICAgICAgICAgICAgICAgICAgICAqc28gY2hhbm5lbCBkb2VzIG5vdCBmZXRjaCBpdCB3aGVuIGl0J3Mgb25seSBoYWxmIGRvbmUKKyAgICAgICAgICAgICAgICAgICAgICAgICAqLworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtZW1jcHkoJnBFbmQtPndyaXRlMV9ub3AyLCAmdGVtcENDVyAsCisJCQkJCXNpemVvZihzdHJ1Y3QgY2N3MSkpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcml2cHRyLT5wX3dyaXRlX2FjdGl2ZV9sYXN0LT53X1RJQ18xLmNkYT0KKwkJCQkgICAgICAgIChfX3UzMilfX3BhKCZwX2ZpcnN0X2Njdy0+d3JpdGUpOworCisgICAgICAgICAgICAgICAgICAgICAgICB9IC8qIGVuZCBpZiBpZiAocEVuZC0+d3JpdGUxKSAqLworCisgICAgICAgICAgICAgICAgICAgICAgICBwcml2cHRyLT5wX3dyaXRlX2FjdGl2ZV9sYXN0LT5uZXh0PXBfZmlyc3RfY2N3OworICAgICAgICAgICAgICAgICAgICAgICAgcHJpdnB0ci0+cF93cml0ZV9hY3RpdmVfbGFzdD1wX2xhc3RfY2N3OworICAgICAgICAgICAgICAgIH0KKworICAgICAgICB9IC8qIGVuZGlmIChwX2ZpcnN0X2NjdyE9TlVMTCkgICovCisKKworI2lmZGVmIElPVFJBQ0UKKyAgICAgICAgcHJpbnRrKEtFUk5fSU5GTyAiJXM6ICVzKCkgPiAgRHVtcCBBY3RpdmUgQ0NXIGNoYWluIFxuIiwKKwkJZGV2LT5uYW1lLF9fRlVOQ1RJT05fXyk7CisgICAgICAgIHBfYnVmPXByaXZwdHItPnBfd3JpdGVfYWN0aXZlX2ZpcnN0OworICAgICAgICB3aGlsZSAocF9idWYhPU5VTEwpIHsKKyAgICAgICAgICAgICAgICBkdW1waXQoKGNoYXIgKilwX2J1Ziwgc2l6ZW9mKHN0cnVjdCBjY3diaykpOworICAgICAgICAgICAgICAgIHBfYnVmPXBfYnVmLT5uZXh0OworICAgICAgICB9CisgICAgICAgIHBfYnVmPShzdHJ1Y3QgY2N3YmsqKXByaXZwdHItPnBfZW5kX2NjdzsKKyAgICAgICAgZHVtcGl0KChjaGFyICopcF9idWYsIHNpemVvZihzdHJ1Y3QgZW5kY2N3KSk7CisjZW5kaWYKKyAgICAgICAgZGV2X2tmcmVlX3NrYihza2IpOworCWlmIChsaW5raWQ9PTApIHsKKyAgICAgICAgCWxvY2s9TE9DS19OTzsKKyAgICAgICAgfQorICAgICAgICBlbHNlICB7CisgICAgICAgICAgICAgICAgbG9jaz1MT0NLX1lFUzsKKyAgICAgICAgfQorICAgICAgICBjbGF3X3N0cnRfb3V0X0lPKGRldiApOworICAgICAgICAvKiAgICAgIGlmIHdyaXRlIGZyZWUgY291bnQgaXMgemVybyAsIHNldCBOT0JVRkZFUiAgICAgICAqLworI2lmZGVmIERFQlVHTVNHCisgICAgICAgIHByaW50ayhLRVJOX0lORk8gIiVzOiAlcygpID4gZnJlZV9jb3VudCBpcyAlZFxuIiwKKwkJZGV2LT5uYW1lLF9fRlVOQ1RJT05fXywKKwkJKGludCkgcHJpdnB0ci0+d3JpdGVfZnJlZV9jb3VudCApOworI2VuZGlmCisJaWYgKHByaXZwdHItPndyaXRlX2ZyZWVfY291bnQ9PTApIHsKKwkJY2xhd19zZXRiaXRfYnVzeShUQl9OT0JVRkZFUixkZXYpOworICAgICAgICB9CitEb25lMjoKKwljbGF3X2NsZWFyYml0X2J1c3koVEJfVFgsZGV2KTsKK0RvbmU6CisjaWZkZWYgRlVOQ1RSQUNFCisgICAgICAgIHByaW50ayhLRVJOX0lORk8gIiVzOiAlcygpID4gZXhpdCBvbiBsaW5lICVkLCByYyA9ICVkIFxuIiwKKwkJZGV2LT5uYW1lLF9fRlVOQ1RJT05fXyxfX0xJTkVfXywgcmMpOworI2VuZGlmCisJcmV0dXJuKHJjKTsKK30gICAgLyogICAgZW5kIG9mIGNsYXdfaHdfdHggICAgKi8KKworLyotLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKgorKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKgorKiAgICAgaW5pdF9jY3dfYmsgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKgorKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKgorKi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKi8KKworc3RhdGljIGludAoraW5pdF9jY3dfYmsoc3RydWN0IG5ldF9kZXZpY2UgKmRldikKK3sKKworICAgICAgICBfX3UzMiAgIGNjd19ibG9ja3NfcmVxdWlyZWQ7CisgICAgICAgIF9fdTMyICAgY2N3X2Jsb2Nrc19wZXJw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UdFX1NJWkUgLyBwcml2cHRyLT5wX2Vudi0+cmVhZF9zaXplOworICAgICAgICAgICAgY2xhd19yZWFkX3BhZ2VzPSAocHJpdnB0ci0+cF9lbnYtPnJlYWRfYnVmZmVycyArCisJICAgIAljbGF3X3JlYWRzX3BlcnBhZ2UgLTEpIC8gY2xhd19yZWFkc19wZXJwYWdlOworICAgICAgICAgfQorICAgICAgICAgZWxzZSB7ICAgICAgIC8qID4gb3IgZXF1YWwgICovCisgICAgICAgICAgICBwcml2cHRyLT5wX2J1ZmZfcGFnZXNfcGVycmVhZD0KKwkgICAgCShwcml2cHRyLT5wX2Vudi0+cmVhZF9zaXplICsgUEFHRV9TSVpFIC0gMSkgLyBQQUdFX1NJWkU7CisgICAgICAgICAgICBjbGF3X3JlYWRfcGFnZXM9CisJICAgIAlwcml2cHRyLT5wX2Vudi0+cmVhZF9idWZmZXJzICogcHJpdnB0ci0+cF9idWZmX3BhZ2VzX3BlcnJlYWQ7CisgICAgICAgICB9CisgICAgICAgIGlmIChwcml2cHRyLT5wX2Vudi0+d3JpdGVfc2l6ZSA8IFBBR0VfU0laRSkgeworICAgICAgICAgICAgY2xhd193cml0ZXNfcGVycGFnZT0KKwkgICAgCVBBR0VfU0laRSAvIHByaXZwdHItPnBfZW52LT53cml0ZV9zaXplOworICAgICAgICAgICAgY2xhd193cml0ZV9wYWdlcz0KKwkgICAgCShwcml2cHRyLT5wX2Vudi0+d3JpdGVfYnVmZmVycyArIGNsYXdfd3JpdGVzX3BlcnBhZ2UgLTEpIC8KKwkJCWNsYXdfd3JpdGVzX3BlcnBhZ2U7CisKKyAgICAgICAgfQorICAgICAgICBlbHNlIHsgICAgICAvKiA+ICBvciBlcXVhbCAgKi8KKyAgICAgICAgICAgIHByaXZwdHItPnBfYnVmZl9wYWdlc19wZXJ3cml0ZT0KKwkgICAgCSAocHJpdnB0ci0+cF9lbnYtPnJlYWRfc2l6ZSArIFBBR0VfU0laRSAtIDEpIC8gUEFHRV9TSVpFOworICA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hbWUsX19GVU5DVElPTl9fLAorCQlwcml2cHRyLT5wX2J1ZmZfcGFnZXNfcGVyd3JpdGUpOworICAgICAgICB9CisgICAgICAgIHByaW50ayhLRVJOX0lORk8gIiVzOiAlcygpIHdyaXRlX3BhZ2VzPSVkXG4iLAorCQlkZXYtPm5hbWUsX19GVU5DVElPTl9fLAorCQljbGF3X3dyaXRlX3BhZ2VzKTsKKyNlbmRpZgorCisKKyAgICAgICAgLyoKKyAgICAgICAgKiAgICAgICAgICAgICAgIGFsbG9jYXRlIGNjd19wYWdlc19yZXF1aXJlZAorICAgICAgICAqLworICAgICAgICBpZiAocHJpdnB0ci0+cF9idWZmX2Njdz09TlVMTCkgeworICAgICAgICAgICAgICAgIHByaXZwdHItPnBfYnVmZl9jY3c9CisJCQkodm9pZCAqKV9fZ2V0X2ZyZWVfcGFnZXMoX19HRlBfRE1BLAorCQkgICAgICAgIChpbnQpcGFnZXNfdG9fb3JkZXJfb2ZfbWFnKGNjd19wYWdlc19yZXF1aXJlZCApKTsKKyAgICAgICAgICAgICAgICBpZiAocHJpdnB0ci0+cF9idWZmX2Njdz09TlVMTCkgeworICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnRrKEtFUk5fSU5GTyAiJXM6ICVzKCkgICIKKwkJCQkiX19nZXRfZnJlZV9wYWdlcyBmb3IgQ0NXcyBmYWlsZWQgOiAiCisJCQkJInBhZ2VzIGlzICVkXG4iLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXYtPm5hbWUsX19GVU5DVElPTl9fLAorCQkJCWNjd19wYWdlc19yZXF1aXJlZCApOworI2lmZGVmIEZVTkNUUkFDRQorICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnRrKEtFUk5fSU5GTyAiJXM6ICVzKCkgPiAiCisJCQkJImV4aXQgb24gbGluZSAlZCwgcmMgPSBFTk9NRU1cbiIsCisJCQkJZGV2LT5uYW1lLF9fRlVOQ1RJT05fXywKKwkJCQkgX19MSU5FX18pOworI2VuZGlmCisgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gLUVOT01FTTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgcHJpdnB0ci0+cF9idWZmX2Njd19udW09Y2N3X3BhZ2VzX3JlcXVpcmVkOworICAgICAgICB9CisgICAgICAgIG1lbXNldChwcml2cHRyLT5wX2J1ZmZfY2N3LCAweDAwLAorCQlwcml2cHRyLT5wX2J1ZmZfY2N3X251bSAqIFBBR0VfU0laRSk7CisKKyAgICAgICAgLyoKKyAgICAgICAgKiAgICAgICAgICAgICAgIG9idGFpbiBlbmRpbmcgY2N3IGJsb2NrIGFkZHJlc3MKKyAgICAgICAgKgorICAgICAgICAqLworICAgICAgICBwcml2cHRyLT5wX2VuZF9jY3cgPSAoc3RydWN0IGVuZGNjdyAqKSZwcml2cHRyLT5lbmRfY2N3OworICAgICAgICByZWFsX2FkZHJlc3MgID0gKF9fdTMyKV9fcGEocHJpdnB0ci0+cF9lbmRfY2N3KTsKKyAgICAgICAgLyogICAgICAgICAgICAgICAgICAgICAgICAgICAgICBJbml0aWFsaXplIGVuZGluZyBDQ1cgYmxvY2sgICAgICAgKi8KKyNpZmRlZiBERUJVR01TRworICAgICAgICBwcmludGsoS0VSTl9JTkZPICIlczogJXMoKSBiZWdpbiBpbml0aWFsaXplIGVuZGluZyBDQ1cgYmxvY2tzXG4iLAorCQlkZXYtPm5hbWUsX19GVU5DVElPTl9fKTsKKyNlbmRpZgorCisgICAgICAgIHBfZW5kY2N3PXByaXZwdHItPnBfZW5kX2NjdzsKKyAgICAgICAgcF9lbmRjY3ctPnJlYWw9cmVhbF9hZGRyZXNzOworICAgICAgICBwX2VuZGNjdy0+d3JpdGUxPTB4MDA7CisgICAgICAgIHBfZW5kY2N3LT5yZWFkMT0weDAwOworCisgICAgICAgIC8qICAgICAgd3JpdGUxX25vcDEgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKi8KKyAgICAgICAgcF9lbmRjY3ctPndyaXRlMV9ub3AxLmNtZF9jb2RlID0gQ0NXX0NMQVdfQ01EX05PUDsKKyAgICAgICAgcF9lbmRjY3ctPndyaXRlMV9ub3AxLmZsYWdzICAgICAgID0gQ0NXX0ZMQUdfU0xJIHwgQ0NXX0ZMQUdfQ0M7CisgICAgICAgIHBfZW5kY2N3LT53cml0ZTFfbm9wMS5jb3VudCAgICAgICA9IDE7CisgICAgICAgIHBfZW5kY2N3LT53cml0ZTFfbm9wMS5jZGEgICAgICAgICA9IDA7CisKKyAgICAgICAgLyogICAgICB3cml0ZTFfbm9wMiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqLworICAgICAgICBwX2VuZGNjdy0+d3JpdGUxX25vcDIuY21kX2NvZGUgPSBDQ1dfQ0xBV19DTURfUkVBREZGOworICAgICAgICBwX2VuZGNjdy0+d3JpdGUxX25vcDIuZmxhZ3MgICAgICAgID0gQ0NXX0ZMQUdfU0xJIHwgQ0NXX0ZMQUdfU0tJUDsKKyAgICAgICAgcF9lbmRjY3ctPndyaXRlMV9ub3AyLmNvdW50ICAgICAgPSAxOworICAgICAgICBwX2VuZGNjdy0+d3JpdGUxX25vcDIuY2RhICAgICAgICA9IDA7CisKKyAgICAgICAgLyogICAgICB3cml0ZTJfbm9wMSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqLworICAgICAgICBwX2VuZGNjdy0+d3JpdGUyX25vcDEuY21kX2NvZGUgPSBDQ1dfQ0xBV19DTURfTk9QOworICAgICAgICBwX2VuZGNjdy0+d3JpdGUyX25vcDEuZmxhZ3MgICAgICAgID0gQ0NXX0ZMQUdfU0xJIHwgQ0NXX0ZMQUdfQ0M7CisgICAgICAgIHBfZW5kY2N3LT53cml0ZTJfbm9wMS5jb3VudCAgICAgICAgPSAxOworICAgICAgICBwX2VuZGNjdy0+d3JpdGUyX25vcDEuY2RhICAgICAgICAgID0gMDsKKworICAgICAgICAvKiAgICAgIHdyaXRlMl9ub3AyICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICovCisgICAgICAgIHBfZW5kY2N3LT53cml0ZTJfbm9wMi5jbWRfY29kZSA9IENDV19DTEFXX0NNRF9SRUFERkY7CisgICAgICAgIHBfZW5kY2N3LT53cml0ZTJfbm9wMi5mbGFncyAgICAgICAgPSBDQ1dfRkxBR19TTEkgfCBDQ1dfRkxBR19TS0lQOworICAgICAgICBwX2VuZGNjdy0+d3JpdGUyX25vcDIuY291bnQgICAgICAgID0gMTsKKyAgICAgICAgcF9lbmRjY3ctPndyaXRlMl9ub3AyLmNkYSAgICAgICAgICA9IDA7CisKKyAgICAgICAgLyogICAgICByZWFkMV9ub3AxICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqLworICAgICAgICBwX2VuZGNjdy0+cmVhZDFfbm9wMS5jbWRfY29kZSA9IENDV19DTEFXX0NNRF9OT1A7CisgICAgICAgIHBfZW5kY2N3LT5yZWFkMV9ub3AxLmZsYWdzICAgICAgICA9IENDV19GTEFHX1NMSSB8IENDV19GTEFHX0NDOworICAgICAgICBwX2VuZGNjdy0+cmVhZDFfbm9wMS5jb3VudCAgICAgICAgPSAxOworICAgICAgICBwX2VuZGNjdy0+cmVhZDFfbm9wMS5jZGEgICAgICAgICAgPSAwOworCisgICAgICAgIC8qICAgICAgcmVhZDFfbm9wMiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKi8KKyAgICAgICAgcF9lbmRjY3ctPnJlYWQxX25vcDIuY21kX2NvZGUgPSBDQ1dfQ0xBV19DTURfUkVBREZGOworICAgICAgICBwX2VuZGNjdy0+cmVhZDFfbm9wMi5mbGFncyAgICAgICAgPSBDQ1dfRkxBR19TTEkgfCBDQ1dfRkxBR19TS0lQOworICAgICAgICBwX2VuZGNjdy0+cmVhZDFfbm9wMi5jb3VudCAgICAgICAgPSAxOworICAgICAgICBwX2VuZGNjdy0+cmVhZDFfbm9wMi5jZGEgICAgICAgICAgPSAwOworCisgICAgICAgIC8qICAgICAgcmVhZDJfbm9wMSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKi8KKyAgICAgICAgcF9lbmRjY3ctPnJlYWQyX25vcDEuY21kX2NvZGUgPSBDQ1dfQ0xBV19DTURfTk9QOworICAgICAgICBwX2VuZGNjdy0+cmVhZDJfbm9wMS5mbGFncyAgICAgICAgPSBDQ1dfRkxBR19TTEkgfCBDQ1dfRkxBR19DQzsKKyAgICAgICAgcF9lbmRjY3ctPnJlYWQyX25vcDEuY291bnQgICAgICAgID0gMTsKKyAgICAgICAgcF9lbmRjY3ctPnJlYWQyX25vcDEuY2RhICAgICAgICAgID0gMDsKKworICAgICAgICAvKiAgICAgIHJlYWQyX25vcDIgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICovCisgICAgICAgIHBfZW5kY2N3LT5yZWFkMl9ub3AyLmNtZF9jb2RlID0gQ0NXX0NMQVdfQ01EX1JFQURGRjsKKyAgICAgICAgcF9lbmRjY3ctPnJlYWQyX25vcDIuZmxhZ3MgICAgICAgID0gQ0NXX0ZMQUdfU0xJIHwgQ0NXX0ZMQUdfU0tJUDsKKyAgICAgICAgcF9lbmRjY3ctPnJlYWQyX25vcDIuY291bnQgICAgICAgID0gMTsKKyAgICAgICAgcF9lbmRjY3ctPnJlYWQyX25vcDIuY2RhICAgICAgICAgID0gMDsKKworI2lmZGVmIElPVFJBQ0UKKyAgICAgICAgcHJpbnRrKEtFUk5fSU5GTyAiJXM6ICVzKCkgZHVtcCBjbGF3IGVuZGluZyBDQ1cgQksgXG4iLAorCQlkZXYtPm5hbWUsX19GVU5DVElPTl9fKTsKKyAgICAgICAgZHVtcGl0KChjaGFyICopcF9lbmRjY3csIHNpemVvZihzdHJ1Y3QgZW5kY2N3KSk7CisjZW5kaWYKKworICAgICAgICAvKgorICAgICAgICAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEJ1aWxkIGEgY2hhaW4gb2YgQ0NXcworICAgICAgICAqCisgICAgICAgICovCisKKyNpZmRlZiBERUJVR01TRworICAgICAgICBwcmludGsoS0VSTl9JTkZPICIlczogJXMoKSAgQmVnaW4gYnVpbGQgYSBjaGFpbiBvZiBDQ1cgYnVmZmVyIFxuIiwKKwkJZGV2LT5uYW1lLF9fRlVOQ1RJT05fXyk7CisjZW5kaWYKKyAgICAgICAgcF9idWZmPXByaXZwdHItPnBfYnVmZl9jY3c7CisKKyAgICAgICAgcF9mcmVlX2NoYWluPU5VTEw7CisgICAgICAgIGZvciAoaT0wIDsgaSA8IGNjd19wYWdlc19yZXF1aXJlZDsgaSsrICkgeworICAgICAgICAgICAgICAgIHJlYWxfYWRkcmVzcyAgPSAoX191MzIpX19wYShwX2J1ZmYpOworICAgICAgICAgICAgICAgIHBfYnVmPXBfYnVmZjsKKyAgICAgICAgICAgICAgICBmb3IgKGo9MCA7IGogPCBjY3dfYmxvY2tzX3BlcnBhZ2UgOyBqKyspIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIHBfYnVmLT5uZXh0ICA9IHBfZnJlZV9jaGFpbjsKKyAgICAgICAgICAgICAgICAgICAgICAgIHBfZnJlZV9jaGFpbiA9IHBfYnVmOworICAgICAgICAgICAgICAgICAgICAgICAgcF9idWYtPnJlYWw9KF9fdTMyKV9fcGEocF9idWYpOworICAgICAgICAgICAgICAgICAgICAgICAgKytwX2J1ZjsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgcF9idWZmKz1QQUdFX1NJWkU7CisgICAgICAgIH0KKyNpZmRlZiBERUJVR01TRworICAgICAgICBwcmludGsoS0VSTl9JTkZPICIlczogJXMoKSAiCisJCSJFbmQgYnVpbGQgYSBjaGFpbiBvZiBDQ1cgYnVmZmVyIFxuIiwKKwkJCWRldi0+bmFtZSxfX0ZVTkNUSU9OX18pOworICAgICAgICBwX2J1Zj1wX2ZyZWVfY2hhaW47CisgICAgICAgIHdoaWxlIChwX2J1ZiE9TlVMTCkgeworICAgICAgICAgICAgICAgIGR1bXBpdCgoY2hhciAqKXBfYnVmLCBzaXplb2Yoc3RydWN0IGNjd2JrKSk7CisgICAgICAgICAgICAgICAgcF9idWY9cF9idWYtPm5leHQ7CisgICAgICAgIH0KKyNlbmRpZgorCisgICAgICAgIC8qCisgICAgICAgICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgSW5pdGlhbGl6ZSBDbGF3U2lnbmFsQmxvY2sKKyAgICAgICAgKgorICAgICAgICAqLworI2lmZGVmIERFQlVHTVNHCisgICAgICAgIHByaW50ayhLRVJOX0lORk8gIiVzOiAlcygpICIKKwkJIkJlZ2luIGluaXRpYWxpemUgQ2xhd1NpZ25hbEJsb2NrIFxuIiwKKwkJZGV2LT5uYW1lLF9fRlVOQ1RJT05fXyk7CisjZW5kaWYKKyAgICAgICAgaWYgKHByaXZwdHItPnBfY2xhd19zaWduYWxfYmxrPT1OVUxMKSB7CisgICAgICAgICAgICAgICAgcHJpdnB0ci0+cF9jbGF3X3NpZ25hbF9ibGs9cF9mcmVlX2NoYWluOworICAgICAgICAgICAgICAgIHBfZnJlZV9jaGFpbj1wX2ZyZWVfY2hhaW4tPm5leHQ7CisgICAgICAgICAgICAgICAgcENsYXdIPShzdHJ1Y3QgY2xhd2ggKilwcml2cHRyLT5wX2NsYXdfc2lnbmFsX2JsazsKKyAgICAgICAgICAgICAgICBwQ2xhd0gtPmxlbmd0aD0weGZmZmY7CisgICAgICAgICAgICAgICAgcENsYXdILT5vcGNvZGU9MHhmZjsKKyAgICAgICAgICAgICAgICBwQ2xhd0gtPmZsYWc9Q0xBV19CVVNZOworICAgICAgICB9CisjaWZkZWYgREVCVUdNU0cKKyAgICAgICAgcHJpbnRrKEtFUk5fSU5GTyAiJXM6ICVzKCkgPiAgRW5kIGluaXRpYWxpemUgIgorCSAJIkNsYXdTaWduYWxCbG9ja1xuIiwKKwkJZGV2LT5uYW1lLF9fRlVOQ1RJT05fXyk7CisgICAgICAgIGR1bXBpdCgoY2hhciAqKXByaXZwdHItPnBfY2xhd19zaWduYWxfYmxrLCBzaXplb2Yoc3RydWN0IGNjd2JrKSk7CisjZW5kaWYKKworICAgICAgICAvKgorICAgICAgICAqICAgICAgICAgICAgICAgYWxsb2NhdGUgd3JpdGVfcGFnZXNfcmVxdWlyZWQgYW5kIGFkZCB0byBmcmVlIGNoYWluCisgICAgICAgICovCisgICAgICAgIGlmIChwcml2cHRyLT5wX2J1ZmZfd3JpdGU9PU5VTEwpIHsKKyAgICAgICAgICAgIGlmIChwcml2cHRyLT5wX2Vudi0+d3JpdGVfc2l6ZSA8IFBBR0VfU0laRSkgeworICAgICAgICAgICAgICAgIHByaXZwdHItPnBfYnVmZl93cml0ZT0KKwkJCSh2b2lkICopX19nZXRfZnJlZV9wYWdlcyhfX0dGUF9ETUEsCisJCQkoaW50KXBhZ2VzX3RvX29yZGVyX29mX21hZyhjbGF3X3dyaXRlX3BhZ2VzICkpOworICAgICAgICAgICAgICAgIGlmIChwcml2cHRyLT5wX2J1ZmZfd3JpdGU9PU5VTEwpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIHByaW50ayhLRVJOX0lORk8gIiVzOiAlcygpIF9fZ2V0X2ZyZWVfcGFnZXMgZm9yIHdyaXRlIgorCQkJCSIgYnVmcyBmYWlsZWQgOiBnZXQgaXMgZm9yICVkIHBhZ2VzXG4iLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXYtPm5hbWUsX19GVU5DVElPTl9fLGNsYXdfd3JpdGVfcGFnZXMgKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGZyZWVfcGFnZXMoKHVuc2lnbmVkIGxvbmcpcHJpdnB0ci0+cF9idWZmX2NjdywKKwkJCSAgIChpbnQpcGFnZXNfdG9fb3JkZXJfb2ZfbWFnKHByaXZwdHItPnBfYnVmZl9jY3dfbnVtKSk7CisgICAgICAgICAgICAgICAgICAgICAgICBwcml2cHRyLT5wX2J1ZmZfY2N3PU5VTEw7CisjaWZkZWYgRlVOQ1RSQUNFCisgICAgICAgICAgICAgICAgICAgICAgICBwcmludGsoS0VSTl9JTkZPICIlczogJXMoKSA+IGV4aXQgb24gbGluZSAlZCwiCisJCQkgCSJyYyA9IEVOT01FTVxuIiwKKwkJCQlkZXYtPm5hbWUsX19GVU5DVElPTl9fLF9fTElORV9fKTsKKyNlbmRpZgorICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIC1FTk9NRU07CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIC8qCisgICAgICAgICAgICAgICAgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBCdWlsZCBDTEFXIHdyaXRlIGZyZWUgY2hhaW4KKyAgICAgICAgICAgICAgICAqCisgICAgICAgICAgICAgICAgKi8KKworICAgICAgICAgICAgICAgIG1lbXNldChwcml2cHRyLT5wX2J1ZmZfd3JpdGUsIDB4MDAsCisJCQljY3dfcGFnZXNfcmVxdWlyZWQgKiBQQUdFX1NJWkUpOworI2lmZGVmIERFQlVHTVNHCisgICAgICAgICAgICAgICAgcHJpbnRrKEtFUk5fSU5GTyAiJXM6ICVzKCkgQmVnaW4gYnVpbGQgY2xhdyB3cml0ZSBmcmVlICIKKwkJCSJjaGFpbiBcbiIsZGV2LT5uYW1lLF9fRlVOQ1RJT05fXyk7CisjZW5kaWYKKyAgICAgICAgICAgICAgICBwcml2cHRyLT5wX3dyaXRlX2ZyZWVfY2hhaW49TlVMTDsKKworICAgICAgICAgICAgICAgIHBfYnVmZj1wcml2cHRyLT5wX2J1ZmZfd3JpdGU7CisKKyAgICAgICAgICAgICAgICBmb3IgKGk9MCA7IGk8IHByaXZwdHItPnBfZW52LT53cml0ZV9idWZmZXJzIDsgaSsrKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBwX2J1ZiAgICAgICAgPSBwX2ZyZWVfY2hhaW47ICAgICAgLyogIGdldCBhIENDVyAqLworICAgICAgICAgICAgICAgICAgICAgICAgcF9mcmVlX2NoYWluID0gcF9idWYtPm5leHQ7CisgICAgICAgICAgICAgICAgICAgICAgICBwX2J1Zi0+bmV4dCAgPXByaXZwdHItPnBfd3JpdGVfZnJlZV9jaGFpbjsKKyAgICAgICAgICAgICAgICAgICAgICAgIHByaXZwdHItPnBfd3JpdGVfZnJlZV9jaGFpbiA9IHBfYnVmOworICAgICAgICAgICAgICAgICAgICAgICAgcF9idWYtPiBwX2J1ZmZlcgk9IChzdHJ1Y3QgY2xhd2J1ZiAqKXBfYnVmZjsKKyAgICAgICAgICAgICAgICAgICAgICAgIHBfYnVmLT4gd3JpdGUuY2RhICAgICAgID0gKF9fdTMyKV9fcGEocF9idWZmKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHBfYnVmLT4gd3JpdGUuZmxhZ3MgICAgID0gQ0NXX0ZMQUdfU0xJIHwgQ0NXX0ZMQUdfQ0M7CisgICAgICAgICAgICAgICAgICAgICAgICBwX2J1Zi0+IHdfcmVhZF9GRi5jbWRfY29kZSA9IENDV19DTEFXX0NNRF9SRUFERkY7CisgICAgICAgICAgICAgICAgICAgICAgICBwX2J1Zi0+IHdfcmVhZF9GRi5mbGFncyAgID0gQ0NXX0ZMQUdfU0xJIHwgQ0NXX0ZMQUdfQ0M7CisgICAgICAgICAgICAgICAgICAgICAgICBwX2J1Zi0+IHdfcmVhZF9GRi5jb3VudCAgID0gMTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHBfYnVmLT4gd19yZWFkX0ZGLmNkYSAgICAgPQorCQkJCShfX3UzMilfX3BhKCZwX2J1Zi0+IGhlYWRlci5mbGFnKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHBfYnVmLT4gd19USUNfMS5jbWRfY29kZSA9IENDV19DTEFXX0NNRF9USUM7CisgICAgICAgICAgICAgICAgICAgICAgICBwX2J1Zi0+IHdfVElDXzEuZmxhZ3MgICAgICA9IDA7CisgICAgICAgICAgICAgICAgICAgICAgICBwX2J1Zi0+IHdfVElDXzEuY291bnQgICAgICA9IDA7CisKKyAgICAgICAgICAgICAgICAgICAgICAgIGlmICgoKHVuc2lnbmVkIGxvbmcpcF9idWZmK3ByaXZwdHItPnBfZW52LT53cml0ZV9zaXplKSA+PQorCQkJICAgKCh1bnNpZ25lZCBsb25nKShwX2J1ZmYrMioKKwkJCQkocHJpdnB0ci0+cF9lbnYtPndyaXRlX3NpemUpIC0xKSAmIFBBR0VfTUFTSykpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIHBfYnVmZj0gcF9idWZmK3ByaXZwdHItPnBfZW52LT53cml0ZV9zaXplOworICAgICAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgfQorICAgICAgICAgICBlbHNlICAgICAgLyogIEJ1ZmZlcnMgYXJlID0+IFBBR0VfU0laRS4gMSBidWZmIHBlciBnZXRfZnJlZV9wYWdlcyAqLworICAgICAgICAgICB7CisgICAgICAgICAgICAgICBwcml2cHRyLT5wX3dyaXRlX2ZyZWVfY2hhaW49TlVMTDsKKyAgICAgICAgICAgICAgIGZvciAoaSA9IDA7IGk8IHByaXZwdHItPnBfZW52LT53cml0ZV9idWZmZXJzIDsgaSsrKSB7CisgICAgICAgICAgICAgICAgICAgcF9idWZmPSh2b2lkICopX19nZXRfZnJlZV9wYWdlcyhfX0dGUF9ETUEsCisJCSAgICAgICAgKGludClwYWdlc190b19vcmRlcl9vZl9tYWcoCisJCQlwcml2cHRyLT5wX2J1ZmZfcGFnZXNfcGVyd3JpdGUpICk7CisjaWZkZWYgSU9UUkFDRQorICAgICAgICAgICAgICAgICAgIHByaW50ayhLRVJOX0lORk8gIiVzOiVzIF9fZ2V0X2ZyZWVfcGFnZXMgIgorCQkgICAgImZvciB3cml0ZXMgYnVmOiBnZXQgZm9yICVkIHBhZ2VzXG4iLAorCQkgICAgZGV2LT5uYW1lLF9fRlVOQ1RJT05fXywKKwkJICAgIHByaXZwdHItPnBfYnVmZl9wYWdlc19wZXJ3cml0ZSk7CisjZW5kaWYKKyAgICAgICAgICAgICAgICAgICBpZiAocF9idWZmPT1OVUxMKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBwcmludGsoS0VSTl9JTkZPICIlczolcyBfX2dldF9mcmVlX3BhZ2VzIgorCQkJIAkiZm9yIHdyaXRlcyBidWYgZmFpbGVkIDogZ2V0IGlzIGZvciAlZCBwYWdlc1xuIiwKKwkJCQlkZXYtPm5hbWUsCisJCQkJX19GVU5DVElPTl9fLAorCQkJCXByaXZwdHItPnBfYnVmZl9wYWdlc19wZXJ3cml0ZSApOworICAgICAgICAgICAgICAgICAgICAgICAgZnJlZV9wYWdlcygodW5zaWduZWQgbG9uZylwcml2cHRyLT5wX2J1ZmZfY2N3LAorCQkJICAgICAgKGludClwYWdlc190b19vcmRlcl9vZl9tYWcoCisJCQkgICAgICAJCXByaXZwdHItPnBfYnVmZl9jY3dfbnVtKSk7CisgICAgICAgICAgICAgICAgICAgICAgICBwcml2cHRyLT5wX2J1ZmZfY2N3PU5VTEw7CisJCQlwX2J1Zj1wcml2cHRyLT5wX2J1ZmZfd3JpdGU7CisgICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAocF9idWYhPU5VTEwpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZnJlZV9wYWdlcygodW5zaWduZWQgbG9uZykKKwkJCQkJcF9idWYtPnBfYnVmZmVyLAorCQkJCQkoaW50KXBhZ2VzX3RvX29yZGVyX29mX21hZygKKwkJCQkJcHJpdnB0ci0+cF9idWZmX3BhZ2VzX3BlcndyaXRlKSk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBfYnVmPXBfYnVmLT5uZXh0OworICAgICAgICAgICAgICAgICAgICAgICAgfQorI2lmZGVmIEZVTkNUUkFDRQorICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnRrKEtFUk5fSU5GTyAiJXM6ICVzIGV4aXQgb24gbGluZSAlZCwgcmMgPSBFTk9NRU1cbiIsCisJCQlkZXYtPm5hbWUsCisJCQlfX0ZVTkNUSU9OX18sCisJCQlfX0xJTkVfXyk7CisjZW5kaWYKKyAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAtRU5PTUVNOworICAgICAgICAgICAgICAgICAgIH0gIC8qIEVycm9yIG9uIGdldF9wYWdlcyAgICovCisgICAgICAgICAgICAgICAgICAgbWVtc2V0KHBfYnVmZiwgMHgwMCwgcHJpdnB0ci0+cF9lbnYtPndyaXRlX3NpemUgKTsKKyAgICAgICAgICAgICAgICAgICBwX2J1ZiAgICAgICAgID0gcF9mcmVlX2NoYWluOworICAgICAgICAgICAgICAgICAgIHBfZnJlZV9jaGFpbiAgPSBwX2J1Zi0+bmV4dDsKKyAgICAgICAgICAgICAgICAgICBwX2J1Zi0+bmV4dCAgID0gcHJpdnB0ci0+cF93cml0ZV9mcmVlX2NoYWluOworICAgICAgICAgICAgICAgICAgIHByaXZwdHItPnBfd3JpdGVfZnJlZV9jaGFpbiA9IHBfYnVmOworICAgICAgICAgICAgICAgICAgIHByaXZwdHItPnBfYnVmZl93cml0ZSA9IHBfYnVmOworICAgICAgICAgICAgICAgICAgIHBfYnVmLT5wX2J1ZmZlcj0oc3RydWN0IGNsYXdidWYgKilwX2J1ZmY7CisgICAgICAgICAgICAgICAgICAgcF9idWYtPiB3cml0ZS5jZGEgICAgID0gKF9fdTMyKV9fcGEocF9idWZmKTsKKyAgICAgICAgICAgICAgICAgICBwX2J1Zi0+IHdyaXRlLmZsYWdzICAgPSBDQ1dfRkxBR19TTEkgfCBDQ1dfRkxBR19DQzsKKyAgICAgICAgICAgICAgICAgICBwX2J1Zi0+IHdfcmVhZF9GRi5jbWRfY29kZSA9IENDV19DTEFXX0NNRF9SRUFERkY7CisgICAgICAgICAgICAgICAgICAgcF9idWYtPiB3X3JlYWRfRkYuZmxhZ3MgICAgPSBDQ1dfRkxBR19TTEkgfCBDQ1dfRkxBR19DQzsKKyAgICAgICAgICAgICAgICAgICBwX2J1Zi0+IHdfcmVhZF9GRi5jb3VudCAgICA9IDE7CisgICAgICAgICAgICAgICAgICAgcF9idWYtPiB3X3JlYWRfRkYuY2RhICAgICAgPQorCQkJKF9fdTMyKV9fcGEoJnBfYnVmLT4gaGVhZGVyLmZsYWcpOworICAgICAgICAgICAgICAgICAgIHBfYnVmLT4gd19USUNfMS5jbWRfY29kZSA9IENDV19DTEFXX0NNRF9USUM7CisgICAgICAgICAgICAgICAgICAgcF9idWYtPiB3X1RJQ18xLmZsYWdzICAgPSAwOworICAgICAgICAgICAgICAgICAgIHBfYnVmLT4gd19USUNfMS5jb3VudCAgID0gMDsKKyAgICAgICAgICAgICAgIH0gIC8qIGZvciBhbGwgd3JpdGVfYnVmZmVycyAgICovCisKKyAgICAgICAgICAgfSAgICAvKiBlbHNlIGJ1ZmZlcnMgYXJlIFBBR0VfU0laRSBvciBiaWdnZXIgKi8KKworICAgICAgICB9CisgICAgICAgIHByaXZwdHItPnBfYnVmZl93cml0ZV9udW09Y2xhd193cml0ZV9wYWdlczsKKyAgICAgICAgcHJpdnB0ci0+d3JpdGVfZnJlZV9jb3VudD1wcml2cHRyLT5wX2Vudi0+d3JpdGVfYnVmZmVyczsKKworCisjaWZkZWYgREVCVUdNU0cKKyAgICAgICAgcHJpbnRrKEtFUk5fSU5GTyAiJXM6JXMgIEVuZCBidWlsZCBjbGF3IHdyaXRlIGZyZWUgY2hhaW4gXG4iLAorCWRldi0+bmFtZSxfX0ZVTkNUSU9OX18pOworICAgICAgICBwX2J1Zj1wcml2cHRyLT5wX3dyaXRlX2ZyZWVfY2hhaW47CisgICAgICAgIHdoaWxlIChwX2J1ZiE9TlVMTCkgeworICAgICAgICAgICAgICAgIGR1bXBpdCgoY2hhciAqKXBfYnVmLCBzaXplb2Yoc3RydWN0IGNjd2JrKSk7CisgICAgICAgICAgICAgICAgcF9idWY9cF9idWYtPm5leHQ7CisgICAgICAgIH0KKyNlbmRpZgorICAgICAgICAvKgorICAgICAgICAqICAgICAgICAgICAgICAgYWxsb2NhdGUgcmVhZF9wYWdlc19yZXF1aXJlZCBhbmQgY2hhaW4gdG8gZnJlZSBjaGFpbgorICAgICAgICAqLworICAgICAgICBpZiAocHJpdnB0ci0+cF9idWZmX3JlYWQ9PU5VTEwpIHsKKyAgICAgICAgICAgIGlmIChwcml2cHRyLT5wX2Vudi0+cmVhZF9zaXplIDwgUEFHRV9TSVpFKSAgeworICAgICAgICAgICAgICAgIHByaXZwdHItPnBfYnVmZl9yZWFkPQorCQkJKHZvaWQgKilfX2dldF9mcmVlX3BhZ2VzKF9fR0ZQX0RNQSwKKwkJCShpbnQpcGFnZXNfdG9fb3JkZXJfb2ZfbWFnKGNsYXdfcmVhZF9wYWdlcykgKTsKKyAgICAgICAgICAgICAgICBpZiAocHJpdnB0ci0+cF9idWZmX3JlYWQ9PU5VTEwpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIHByaW50ayhLRVJOX0lORk8gIiVzOiAlcygpICIKKwkJCSAJIl9fZ2V0X2ZyZWVfcGFnZXMgZm9yIHJlYWQgYnVmIGZhaWxlZCA6ICIKKwkJCSAJImdldCBpcyBmb3IgJWQgcGFnZXNcbiIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRldi0+bmFtZSxfX0ZVTkNUSU9OX18sY2xhd19yZWFkX3BhZ2VzICk7CisgICAgICAgICAgICAgICAgICAgICAgICBmcmVlX3BhZ2VzKCh1bnNpZ25lZCBsb25nKXByaXZwdHItPnBfYnVmZl9jY3csCisJCQkJKGludClwYWdlc190b19vcmRlcl9vZl9tYWcoCisJCQkJCXByaXZwdHItPnBfYnVmZl9jY3dfbnVtKSk7CisJCQkvKiBmcmVlIHRoZSB3cml0ZSBwYWdlcyBzaXplIGlzIDwgcGFnZSBzaXplICAqLworICAgICAgICAgICAgICAgICAgICAgICAgZnJlZV9wYWdlcygodW5zaWduZWQgbG9uZylwcml2cHRyLT5wX2J1ZmZfd3JpdGUsCisJCQkJKGludClwYWdlc190b19vcmRlcl9vZl9tYWcoCisJCQkJcHJpdnB0ci0+cF9idWZmX3dyaXRlX251bSkpOworICAgICAgICAgICAgICAgICAgICAgICAgcHJpdnB0ci0+cF9idWZmX2Njdz1OVUxMOworICAgICAgICAgICAgICAgICAgICAgICAgcHJpdnB0ci0+cF9idWZmX3dyaXRlPU5VTEw7CisjaWZkZWYgRlVOQ1RSQUNFCisgICAgICAgICAgICAgICAgICAgICAgICBwcmludGsoS0VSTl9JTkZPICIlczogJXMoKSA+IGV4aXQgb24gbGluZSAlZCwgcmMgPSIKKwkJCQkiIEVOT01FTVxuIixkZXYtPm5hbWUsX19GVU5DVElPTl9fLF9fTElORV9fKTsKKyNlbmRpZgorICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIC1FTk9NRU07CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIG1lbXNldChwcml2cHRyLT5wX2J1ZmZfcmVhZCwgMHgwMCwgY2xhd19yZWFkX3BhZ2VzICogUEFHRV9TSVpFKTsKKyAgICAgICAgICAgICAgICBwcml2cHRyLT5wX2J1ZmZfcmVhZF9udW09Y2xhd19yZWFkX3BhZ2VzOworICAgICAgICAgICAgICAgIC8qCisgICAgICAgICAgICAgICAgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBCdWlsZCBDTEFXIHJlYWQgZnJlZSBjaGFpbgorICAgICAgICAgICAgICAgICoKKyAgICAgICAgICAgICAgICAqLworI2lmZGVmIERFQlVHTVNHCisgICAgICAgICAgICAgICAgcHJpbnRrKEtFUk5fSU5GTyAiJXM6ICVzKCkgQmVnaW4gYnVpbGQgY2xhdyByZWFkIGZyZWUgY2hhaW4gXG4iLAorCQkJZGV2LT5uYW1lLF9fRlVOQ1RJT05fXyk7CisjZW5kaWYKKyAgICAgICAgICAgICAgICBwX2J1ZmY9cHJpdnB0ci0+cF9idWZmX3JlYWQ7CisgICAgICAgICAgICAgICAgZm9yIChpPTAgOyBpPCBwcml2cHRyLT5wX2Vudi0+cmVhZF9idWZmZXJzIDsgaSsrKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBwX2J1ZiAgICAgICAgPSBwX2ZyZWVfY2hhaW47CisgICAgICAgICAgICAgICAgICAgICAgICBwX2ZyZWVfY2hhaW4gPSBwX2J1Zi0+bmV4dDsKKworICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBfbGFzdF9DQ1dCPT1OVUxMKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBfYnVmLT5uZXh0PU5VTEw7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlYWxfVElDX2FkZHJlc3M9MDsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcF9sYXN0X0NDV0I9cF9idWY7CisgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgICAgICBlbHNlIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcF9idWYtPm5leHQ9cF9maXJzdF9DQ1dCOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWFsX1RJQ19hZGRyZXNzPQorCQkJCShfX3UzMilfX3BhKCZwX2ZpcnN0X0NDV0IgLT4gcmVhZCApOworICAgICAgICAgICAgICAgICAgICAgICAgfQorCisgICAgICAgICAgICAgICAgICAgICAgICBwX2ZpcnN0X0NDV0I9cF9idWY7CisKKyAgICAgICAgICAgICAgICAgICAgICAgIHBfYnVmLT5wX2J1ZmZlcj0oc3RydWN0IGNsYXdidWYgKilwX2J1ZmY7CisgICAgICAgICAgICAgICAgICAgICAgICAvKiAgaW5pdGlhbGl6ZSByZWFkIGNvbW1hbmQgKi8KKyAgICAgICAgICAgICAgICAgICAgICAgIHBfYnVmLT4gcmVhZC5jbWRfY29kZSA9IENDV19DTEFXX0NNRF9SRUFEOworICAgICAgICAgICAgICAgICAgICAgICAgcF9idWYtPiByZWFkLmNkYSA9IChfX3UzMilfX3BhKHBfYnVmZik7CisgICAgICAgICAgICAgICAgICAgICAgICBwX2J1Zi0+IHJlYWQuZmxhZ3MgPSBDQ1dfRkxBR19TTEkgfCBDQ1dfRkxBR19DQzsKKyAgICAgICAgICAgICAgICAgICAgICAgIHBfYnVmLT4gcmVhZC5jb3VudCAgICAgICA9IHByaXZwdHItPnBfZW52LT5yZWFkX3NpemU7CisKKyAgICAgICAgICAgICAgICAgICAgICAgIC8qICBpbml0aWFsaXplIHJlYWRfaCBjb21tYW5kICovCisgICAgICAgICAgICAgICAgICAgICAgICBwX2J1Zi0+IHJlYWRfaC5jbWRfY29kZSA9IENDV19DTEFXX0NNRF9SRUFESEVBREVSOworICAgICAgICAgICAgICAgICAgICAgICAgcF9idWYtPiByZWFkX2guY2RhID0KKwkJCQkoX191MzIpX19wYSgmKHBfYnVmLT5oZWFkZXIpKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHBfYnVmLT4gcmVhZF9oLmZsYWdzID0gQ0NXX0ZMQUdfU0xJIHwgQ0NXX0ZMQUdfQ0M7CisgICAgICAgICAgICAgICAgICAgICAgICBwX2J1Zi0+IHJlYWRfaC5jb3VudCAgICAgID0gc2l6ZW9mKHN0cnVjdCBjbGF3aCk7CisKKyAgICAgICAgICAgICAgICAgICAgICAgIC8qICBpbml0aWFsaXplIFNpZ25hbCBjb21tYW5kICovCisgICAgICAgICAgICAgICAgICAgICAgICBwX2J1Zi0+IHNpZ25hbC5jbWRfY29kZSA9IENDV19DTEFXX0NNRF9TSUdOQUxfU01PRDsKKyAgICAgICAgICAgICAgICAgICAgICAgIHBfYnVmLT4gc2lnbmFsLmNkYSA9CisJCQkJKF9fdTMyKV9fcGEoJihwQ2xhd0gtPmZsYWcpKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHBfYnVmLT4gc2lnbmFsLmZsYWdzID0gQ0NXX0ZMQUdfU0xJIHwgQ0NXX0ZMQUdfQ0M7CisgICAgICAgICAgICAgICAgICAgICAgICBwX2J1Zi0+IHNpZ25hbC5jb3VudCAgICAgPSAxOworCisgICAgICAgICAgICAgICAgICAgICAgICAvKiAgaW5pdGlhbGl6ZSByX1RJQ18xIGNvbW1hbmQgKi8KKyAgICAgICAgICAgICAgICAgICAgICAgIHBfYnVmLT4gcl9USUNfMS5jbWRfY29kZSA9IENDV19DTEFXX0NNRF9USUM7CisgICAgICAgICAgICAgICAgICAgICAgICBwX2J1Zi0+IHJfVElDXzEuY2RhID0gKF9fdTMyKXJlYWxfVElDX2FkZHJlc3M7CisgICAgICAgICAgICAgICAgICAgICAgICBwX2J1Zi0+IHJfVElDXzEuZmxhZ3MgPSAwOworICAgICAgICAgICAgICAgICAgICAgICAgcF9idWYtPiByX1RJQ18xLmNvdW50ICAgICAgPSAwOworCisgICAgICAgICAgICAgICAgICAgICAgICAvKiAgaW5pdGlhbGl6ZSByX3JlYWRfRkYgY29tbWFuZCAqLworICAgICAgICAgICAgICAgICAgICAgICAgcF9idWYtPiByX3JlYWRfRkYuY21kX2NvZGUgPSBDQ1dfQ0xBV19DTURfUkVBREZGOworICAgICAgICAgICAgICAgICAgICAgICAgcF9idWYtPiByX3JlYWRfRkYuY2RhID0KKwkJCQkoX191MzIpX19wYSgmKHBDbGF3SC0+ZmxhZykpOworICAgICAgICAgICAgICAgICAgICAgICAgcF9idWYtPiByX3JlYWRfRkYuZmxhZ3MgPQorCQkJCUNDV19GTEFHX1NMSSB8IENDV19GTEFHX0NDIHwgQ0NXX0ZMQUdfUENJOworICAgICAgICAgICAgICAgICAgICAgICAgcF9idWYtPiByX3JlYWRfRkYuY291bnQgICAgPSAxOworCisgICAgICAgICAgICAgICAgICAgICAgICAvKiAgICBpbml0aWFsaXplIHJfVElDXzIgICAgICAgICAgKi8KKyAgICAgICAgICAgICAgICAgICAgICAgIG1lbWNweSgmcF9idWYtPnJfVElDXzIsCisJCQkJJnBfYnVmLT5yX1RJQ18xLCBzaXplb2Yoc3RydWN0IGNjdzEpKTsKKworICAgICAgICAgICAgICAgICAgICAgICAgLyogICAgIGluaXRpYWxpemUgSGVhZGVyICAgICAqLworICAgICAgICAgICAgICAgICAgICAgICAgcF9idWYtPmhlYWRlci5sZW5ndGg9MHhmZmZmOworICAgICAgICAgICAgICAgICAgICAgICAgcF9idWYtPmhlYWRlci5vcGNvZGU9MHhmZjsKKyAgICAgICAgICAgICAgICAgICAgICAgIHBfYnVmLT5oZWFkZXIuZmxhZz1DTEFXX1BFTkRJTkc7CisKKyAgICAgICAgICAgICAgICAgICAgICAgIGlmICgoKHVuc2lnbmVkIGxvbmcpcF9idWZmK3ByaXZwdHItPnBfZW52LT5yZWFkX3NpemUpID49CisJCQkJKCh1bnNpZ25lZCBsb25nKShwX2J1ZmYrMioocHJpdnB0ci0+cF9lbnYtPnJlYWRfc2l6ZSkgLTEpCisJCQkJICYgUEFHRV9NQVNLKSApIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcF9idWZmPSBwX2J1ZmYrcHJpdnB0ci0+cF9lbnYtPnJlYWRfc2l6ZTsKKyAgICAgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgICAgIGVsc2UgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwX2J1ZmY9CisJCQkJKHZvaWQgKikoKHVuc2lnbmVkIGxvbmcpCisJCQkJCShwX2J1ZmYrMioocHJpdnB0ci0+cF9lbnYtPnJlYWRfc2l6ZSkgLTEpCisJCQkJCSAmIFBBR0VfTUFTSykgOworICAgICAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIH0gICAvKiBmb3IgcmVhZF9idWZmZXJzICAgKi8KKyAgICAgICAgICB9ICAgICAgICAgLyogcmVhZF9zaXplIDwgUEFHRV9TSVpFICAqLworICAgICAgICAgIGVsc2UgeyAgLyogcmVhZCBTaXplID49IFBBR0VfU0laRSAgKi8KKworI2lmZGVmIERFQlVHTVNHCisgICAgICAgIHByaW50ayhLRVJOX0lORk8gIiVzOiAlcygpIEJlZ2luIGJ1aWxkIGNsYXcgcmVhZCBmcmVlIGNoYWluIFxuIiwKKwkJZGV2LT5uYW1lLF9fRlVOQ1RJT05fXyk7CisjZW5kaWYKKyAgICAgICAgICAgICAgICBmb3IgKGk9MCA7IGk8IHByaXZwdHItPnBfZW52LT5yZWFkX2J1ZmZlcnMgOyBpKyspIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIHBfYnVmZiA9ICh2b2lkICopX19nZXRfZnJlZV9wYWdlcyhfX0dGUF9ETUEsCisJCQkJKGludClwYWdlc190b19vcmRlcl9vZl9tYWcocHJpdnB0ci0+cF9idWZmX3BhZ2VzX3BlcnJlYWQpICk7CisgICAgICAgICAgICAgICAgICAgICAgICBpZiAocF9idWZmPT1OVUxMKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByaW50ayhLRVJOX0lORk8gIiVzOiAlcygpIF9fZ2V0X2ZyZWVfcGFnZXMgZm9yIHJlYWQgIgorCQkJCQkiYnVmIGZhaWxlZCA6IGdldCBpcyBmb3IgJWQgcGFnZXNcbiIsCisJCQkJCWRldi0+bmFtZSxfX0ZVTkNUSU9OX18sCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJpdnB0ci0+cF9idWZmX3BhZ2VzX3BlcnJlYWQgKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZnJlZV9wYWdlcygodW5zaWduZWQgbG9uZylwcml2cHRyLT5wX2J1ZmZfY2N3LAorCQkJCQkoaW50KXBhZ2VzX3RvX29yZGVyX29mX21hZyhwcml2cHRyLT5wX2J1ZmZfY2N3X251bSkpOworCQkJCS8qIGZyZWUgdGhlIHdyaXRlIHBhZ2VzICAqLworCSAgICAgICAgICAgICAgICAgICAgICAgIHBfYnVmPXByaXZwdHItPnBfYnVmZl93cml0ZTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKHBfYnVmIT1OVUxMKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZnJlZV9wYWdlcygodW5zaWduZWQgbG9uZylwX2J1Zi0+cF9idWZmZXIsCisJCQkJCQkoaW50KXBhZ2VzX3RvX29yZGVyX29mX21hZygKKwkJCQkJCXByaXZwdHItPnBfYnVmZl9wYWdlc19wZXJ3cml0ZSApKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwX2J1Zj1wX2J1Zi0+bmV4dDsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQorCQkJCS8qIGZyZWUgYW55IHJlYWQgcGFnZXMgYWxyZWFkeSBhbGxvYyAgKi8KKwkgICAgICAgICAgICAgICAgICAgICAgICBwX2J1Zj1wcml2cHRyLT5wX2J1ZmZfcmVhZDsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKHBfYnVmIT1OVUxMKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZnJlZV9wYWdlcygodW5zaWduZWQgbG9uZylwX2J1Zi0+cF9idWZmZXIsCisJCQkJCQkoaW50KXBhZ2VzX3RvX29yZGVyX29mX21hZygKKwkJCQkJCXByaXZwdHItPnBfYnVmZl9wYWdlc19wZXJyZWFkICkpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBfYnVmPXBfYnVmLT5uZXh0OworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByaXZwdHItPnBfYnVmZl9jY3c9TlVMTDsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJpdnB0ci0+cF9idWZmX3dyaXRlPU5VTEw7CisjaWZkZWYgRlVOQ1RSQUNFCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByaW50ayhLRVJOX0lORk8gIiVzOiAlcygpIGV4aXQgb24gbGluZSAlZCwgcmMgPSBFTk9NRU1cbiIsCisJCQkJCWRldi0+bmFtZSxfX0ZVTkNUSU9OX18sCisJCQkJCV9fTElORV9fKTsKKyNlbmRpZgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gLUVOT01FTTsKKyAgICAgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgICAgIG1lbXNldChwX2J1ZmYsIDB4MDAsIHByaXZwdHItPnBfZW52LT5yZWFkX3NpemUpOworICAgICAgICAgICAgICAgICAgICAgICAgcF9idWYgICAgICAgID0gcF9mcmVlX2NoYWluOworICAgICAgICAgICAgICAgICAgICAgICAgcHJpdnB0ci0+cF9idWZmX3JlYWQgPSBwX2J1ZjsKKyAgICAgICAgICAgICAgICAgICAgICAgIHBfZnJlZV9jaGFpbiA9IHBfYnVmLT5uZXh0OworCisgICAgICAgICAgICAgICAgICAgICAgICBpZiAocF9sYXN0X0NDV0I9PU5VTEwpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcF9idWYtPm5leHQ9TlVMTDsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhbF9USUNfYWRkcmVzcz0wOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwX2xhc3RfQ0NXQj1wX2J1ZjsKKyAgICAgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgICAgIGVsc2UgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwX2J1Zi0+bmV4dD1wX2ZpcnN0X0NDV0I7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlYWxfVElDX2FkZHJlc3M9CisJCQkJCShhZGRyX3QpX19wYSgKKwkJCQkJCSZwX2ZpcnN0X0NDV0IgLT4gcmVhZCApOworICAgICAgICAgICAgICAgICAgICAgICAgfQorCisgICAgICAgICAgICAgICAgICAgICAgICBwX2ZpcnN0X0NDV0I9cF9idWY7CisJCQkJLyogc2F2ZSBidWZmIGFkZHJlc3MgKi8KKyAgICAgICAgICAgICAgICAgICAgICAgIHBfYnVmLT5wX2J1ZmZlcj0oc3RydWN0IGNsYXdidWYgKilwX2J1ZmY7CisgICAgICAgICAgICAgICAgICAgICAgICAvKiAgaW5pdGlhbGl6ZSByZWFkIGNvbW1hbmQgKi8KKyAgICAgICAgICAgICAgICAgICAgICAgIHBfYnVmLT4gcmVhZC5jbWRfY29kZSA9IENDV19DTEFXX0NNRF9SRUFEOworICAgICAgICAgICAgICAgICAgICAgICAgcF9idWYtPiByZWFkLmNkYSA9IChfX3UzMilfX3BhKHBfYnVmZik7CisgICAgICAgICAgICAgICAgICAgICAgICBwX2J1Zi0+IHJlYWQuZmxhZ3MgPSBDQ1dfRkxBR19TTEkgfCBDQ1dfRkxBR19DQzsKKyAgICAgICAgICAgICAgICAgICAgICAgIHBfYnVmLT4gcmVhZC5jb3VudCAgICAgICA9IHByaXZwdHItPnBfZW52LT5yZWFkX3NpemU7CisKKyAgICAgICAgICAgICAgICAgICAgICAgIC8qICBpbml0aWFsaXplIHJlYWRfaCBjb21tYW5kICovCisgICAgICAgICAgICAgICAgICAgICAgICBwX2J1Zi0+IHJlYWRfaC5jbWRfY29kZSA9IENDV19DTEFXX0NNRF9SRUFESEVBREVSOworICAgICAgICAgICAgICAgICAgICAgICAgcF9idWYtPiByZWFkX2guY2RhID0KKwkJCQkoX191MzIpX19wYSgmKHBfYnVmLT5oZWFkZXIpKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHBfYnVmLT4gcmVhZF9oLmZsYWdzID0gQ0NXX0ZMQUdfU0xJIHwgQ0NXX0ZMQUdfQ0M7CisgICAgICAgICAgICAgICAgICAgICAgICBwX2J1Zi0+IHJlYWRfaC5jb3VudCAgICAgID0gc2l6ZW9mKHN0cnVjdCBjbGF3aCk7CisKKyAgICAgICAgICAgICAgICAgICAgICAgIC8qICBpbml0aWFsaXplIFNpZ25hbCBjb21tYW5kICovCisgICAgICAgICAgICAgICAgICAgICAgICBwX2J1Zi0+IHNpZ25hbC5jbWRfY29kZSA9IENDV19DTEFXX0NNRF9TSUdOQUxfU01PRDsKKyAgICAgICAgICAgICAgICAgICAgICAgIHBfYnVmLT4gc2lnbmFsLmNkYSA9CisJCQkJKF9fdTMyKV9fcGEoJihwQ2xhd0gtPmZsYWcpKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHBfYnVmLT4gc2lnbmFsLmZsYWdzID0gQ0NXX0ZMQUdfU0xJIHwgQ0NXX0ZMQUdfQ0M7CisgICAgICAgICAgICAgICAgICAgICAgICBwX2J1Zi0+IHNpZ25hbC5jb3VudCAgICAgPSAxOworCisgICAgICAgICAgICAgICAgICAgICAgICAvKiAgaW5pdGlhbGl6ZSByX1RJQ18xIGNvbW1hbmQgKi8KKyAgICAgICAgICAgICAgICAgICAgICAgIHBfYnVmLT4gcl9USUNfMS5jbWRfY29kZSA9IENDV19DTEFXX0NNRF9USUM7CisgICAgICAgICAgICAgICAgICAgICAgICBwX2J1Zi0+IHJfVElDXzEuY2RhID0gKF9fdTMyKXJlYWxfVElDX2FkZHJlc3M7CisgICAgICAgICAgICAgICAgICAgICAgICBwX2J1Zi0+IHJfVElDXzEuZmxhZ3MgPSAwOworICAgICAgICAgICAgICAgICAgICAgICAgcF9idWYtPiByX1RJQ18xLmNvdW50ICAgICAgPSAwOworCisgICAgICAgICAgICAgICAgICAgICAgICAvKiAgaW5pdGlhbGl6ZSByX3JlYWRfRkYgY29tbWFuZCAqLworICAgICAgICAgICAgICAgICAgICAgICAgcF9idWYtPiByX3JlYWRfRkYuY21kX2NvZGUgPSBDQ1dfQ0xBV19DTURfUkVBREZGOworICAgICAgICAgICAgICAgICAgICAgICAgcF9idWYtPiByX3JlYWRfRkYuY2RhID0KKwkJCQkoX191MzIpX19wYSgmKHBDbGF3SC0+ZmxhZykpOworICAgICAgICAgICAgICAgICAgICAgICAgcF9idWYtPiByX3JlYWRfRkYuZmxhZ3MgPQorCQkJCUNDV19GTEFHX1NMSSB8IENDV19GTEFHX0NDIHwgQ0NXX0ZMQUdfUENJOworICAgICAgICAgICAgICAgICAgICAgICAgcF9idWYtPiByX3JlYWRfRkYuY291bnQgICAgPSAxOworCisgICAgICAgICAgICAgICAgICAgICAgICAvKiAgICBpbml0aWFsaXplIHJfVElDXzIgICAgICAgICAgKi8KKyAgICAgICAgICAgICAgICAgICAgICAgIG1lbWNweSgmcF9idWYtPnJfVElDXzIsICZwX2J1Zi0+cl9USUNfMSwKKwkJCQlzaXplb2Yoc3RydWN0IGNjdzEpKTsKKworICAgICAgICAgICAgICAgICAgICAgICAgLyogICAgIGluaXRpYWxpemUgSGVhZGVyICAgICAqLworICAgICAgICAgICAgICAgICAgICAgICAgcF9idWYtPmhlYWRlci5sZW5ndGg9MHhmZmZmOworICAgICAgICAgICAgICAgICAgICAgICAgcF9idWYtPmhlYWRlci5vcGNvZGU9MHhmZjsKKyAgICAgICAgICAgICAgICAgICAgICAgIHBfYnVmLT5oZWFkZXIuZmxhZz1DTEFXX1BFTkRJTkc7CisKKyAgICAgICAgICAgICAgICB9ICAgIC8qIEZvciByZWFkX2J1ZmZlcnMgICAqLworICAgICAgICAgIH0gICAgIC8qICByZWFkX3NpemUgPj0gUEFHRV9TSVpFICAgKi8KKyAgICAgICAgfSAgICAgICAvKiAgcEJ1ZmZyZWFkID0gTlVMTCAqLworI2lmZGVmIERFQlVHTVNHCisgICAgICAgIHByaW50ayhLRVJOX0lORk8gIiVzOiAlcygpID4gIEVuZCBidWlsZCBjbGF3IHJlYWQgZnJlZSBjaGFpbiBcbiIsCisJCWRldi0+bmFtZSxfX0ZVTkNUSU9OX18pOworICAgICAgICBwX2J1Zj1wX2ZpcnN0X0NDV0I7CisgICAgICAgIHdoaWxlIChwX2J1ZiE9TlVMTCkgeworICAgICAgICAgICAgICAgIGR1bXBpdCgoY2hhciAqKXBfYnVmLCBzaXplb2Yoc3RydWN0IGNjd2JrKSk7CisgICAgICAgICAgICAgICAgcF9idWY9cF9idWYtPm5leHQ7CisgICAgICAgIH0KKworI2VuZGlmCisgICAgICAgIGFkZF9jbGF3X3JlYWRzKCBkZXYgICxwX2ZpcnN0X0NDV0IgLCBwX2xhc3RfQ0NXQik7CisJcHJpdnB0ci0+YnVmZnNfYWxsb2MgPSAxOworI2lmZGVmIEZVTkNUUkFDRQorICAgICAgICBwcmludGsoS0VSTl9JTkZPICIlczogJXMoKSBleGl0IG9uIGxpbmUgJWRcbiIsCisJCWRldi0+bmFtZSxfX0ZVTkNUSU9OX18sX19MSU5FX18pOworI2VuZGlmCisgICAgICAgIHJldHVybiAwOworfSAgICAvKiAgICBlbmQgb2YgaW5pdF9jY3dfYmsgKi8KKworLyotLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKgorKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKgorKiAgICAgICBwcm9iZV9lcnJvciAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKgorKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKgorKi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKi8KKworc3RhdGljIHZvaWQKK3Byb2JlX2Vycm9yKCBzdHJ1Y3QgY2N3Z3JvdXBfZGV2aWNlICpjZ2RldikKK3sKKyAgc3RydWN0IGNsYXdfcHJpdmJrICpwcml2cHRyOworI2lmZGVmIEZVTkNUUkFDRQorICAgICAgICBwcmludGsoS0VSTl9JTkZPICIlcyBlbnRlciAgXG4iLF9fRlVOQ1RJT05fXyk7CisjZW5kaWYKKwlDTEFXX0RCRl9URVhUKDQsdHJhY2UsInByb2JlcnIiKTsKKyNpZmRlZiBERUJVR01TRworICAgICAgICBwcmludGsoS0VSTl9JTkZPICIlcyB2YXJpYWJsZSBjZ2RldiA9XG4iLF9fRlVOQ1RJT05fXyk7CisgICAgICAgIGR1bXBpdCgoY2hhciAqKSBjZ2Rldiwgc2l6ZW9mKHN0cnVjdCBjY3dncm91cF9kZXZpY2UpKTsKKyNlbmRpZgorICAgICAgICBwcml2cHRyPShzdHJ1Y3QgY2xhd19wcml2YmsgKiljZ2Rldi0+ZGV2LmRyaXZlcl9kYXRhOworCWlmIChwcml2cHRyIT1OVUxMKSB7CisJCWlmIChwcml2cHRyLT5wX2VudiAhPSBOVUxMKSB7CisJCQlrZnJlZShwcml2cHRyLT5wX2Vudik7CisJCQlwcml2cHRyLT5wX2Vudj1OVUxMOworCQl9CisgICAgICAgIAlpZiAocHJpdnB0ci0+cF9tdGNfZW52ZWxvcGUhPU5VTEwpIHsKKyAgICAgICAgICAgICAgICAJa2ZyZWUocHJpdnB0ci0+cF9tdGNfZW52ZWxvcGUpOworICAgICAgICAgICAgICAgIAlwcml2cHRyLT5wX210Y19lbnZlbG9wZT1OVUxMOworICAgICAgICAJfQorICAgICAgICAgICAgICAgIGtmcmVlKHByaXZwdHIpOworICAgICAgICAgICAgICAgIHByaXZwdHI9TlVMTDsKKyAgICAgICAgfQorI2lmZGVmIEZVTkNUUkFDRQorICAgICAgICBwcmludGsoS0VSTl9JTkZPICIlcyA+IGV4aXQgb24gbGluZSAlZFxuIiwKKwkJIF9fRlVOQ1RJT05fXyxfX0xJTkVfXyk7CisjZW5kaWYKKworICAgICAgICByZXR1cm47Cit9ICAgIC8qICAgIHByb2JlX2Vycm9yICAgICovCisKKworCisvKi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0qCisqICAgIGNsYXdfcHJvY2Vzc19jb250cm9sICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqCisqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqCisqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqCisqLS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ls0XSwgc2l6ZW9mKHN0cnVjdCBjbGF3Y3RsKSk7CisJfSBlbHNlIHsKKwkJbWVtY3B5KHBfY3RsYmssIHBfYnVmLCBzaXplb2Yoc3RydWN0IGNsYXdjdGwpKTsKKwl9CisjaWZkZWYgSU9UUkFDRQorICAgICAgICBwcmludGsoS0VSTl9JTkZPICIlczogZHVtcCBjbGF3IGNvbnRyb2wgZGF0YSBpbmJvdW5kXG4iLGRldi0+bmFtZSk7CisgICAgICAgIGR1bXBpdCgoY2hhciAqKXBfY3RsYmssIHNpemVvZihzdHJ1Y3QgY2xhd2N0bCkpOworI2VuZGlmCisgICAgICAgIHN3aXRjaCAocF9jdGxiay0+Y29tbWFuZCkKKyAgICAgICAgeworICAgICAgICAgICAgICAgIGNhc2UgU1lTVEVNX1ZBTElEQVRFX1JFUVVFU1Q6CisgICAgICAgICAgICAgICAgICAgICAgICBpZiAocF9jdGxiay0+dmVyc2lvbiE9Q0xBV19WRVJTSU9OX0lEKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsYXdfc25kX3N5c192YWxpZGF0ZV9yc3AoZGV2LCBwX2N0bGJrLAorCQkJCQlDTEFXX1JDX1dST05HX1ZFUlNJT04gKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnRrKCIlczogJWQgaXMgd3JvbmcgdmVyc2lvbiBpZC4gIgorCQkJCQkiRXhwZWN0ZWQgJWRcbiIsCisJCQkJCWRldi0+bmFtZSwgcF9jdGxiay0+dmVyc2lvbiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDTEFXX1ZFUlNJT05fSUQpOworICAgICAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICAgICAgcF9zeXN2YWw9KHN0cnVjdCBzeXN2YWwgKikmKHBfY3RsYmstPmRhdGEpOworCQkJcHJpbnRrKCAiJXM6IFJlY3YgU3lzIFZhbGlkYXRlIFJlcXVlc3Q6ICIKKwk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IH0KKyAgICAgICAgICAgICAgICAgICAgICAgIGlmICgwIT1tZW1jbXAodGVtcF93c19uYW1lLHBfc3lzdmFsLT5XU19uYW1lLDgpKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsYXdfc25kX3N5c192YWxpZGF0ZV9yc3AoZGV2LCBwX2N0bGJrLAorCQkJCQlDTEFXX1JDX05BTUVfTUlTTUFUQ0ggKTsKKwkJCQlDTEFXX0RCRl9URVhUKDIsc2V0dXAsIldTTkJBRCIpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDTEFXX0RCRl9URVhUXygyLHNldHVwLCIlcyIscF9zeXN2YWwtPldTX25hbWUpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDTEFXX0RCRl9URVhUXygyLHNldHVwLCIlcyIsdGVtcF93c19uYW1lKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnRrKEtFUk5fSU5GTyAiJXM6IFdTIG5hbWUgbWlzbWF0Y2hcbiIsCisJCQkJCWRldi0+bmFtZSk7CisJCQkJIHByaW50ayhLRVJOX0lORk8gIiVzOiBSZWNlaXZlZCA6JXM6ICIKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAiZXhwZWN0ZWQgOiVzOiBcbiIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGV2LT5uYW1lLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBfc3lzdmFsLT5XU19uYW1lLAorCQkJCQl0ZW1wX3dzX25hbWUpOworICAgICAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCggcF9zeXN2YWwtPndyaXRlX2ZyYW1lX3NpemUgPCBwX2Vudi0+d3JpdGVfc2l6ZSkgJiYKKwkJCSAgICggcF9lbnYtPnBhY2tpbmcgPT0gMCkpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xhd19zbmRfc3lzX3ZhbGlkYXRlX3JzcChkZXYsIHBfY3RsYmssCisJCQkJCUNMQVdfUkNfSE9TVF9SQ1ZfVE9PX1NNQUxMICk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByaW50ayhLRVJOX0lORk8gIiVzOiBob3N0IHdyaXRlIHNpemUgaXMgdG9vICIKKwkJCQkJInNtYWxsXG4iLCBkZXYtPm5hbWUpOworCQkJCUNMQVdfREJGX1RFWFQoMixzZXR1cCwid3J0c3piYWQiKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgICAgIGlmICgoIHBfc3lzdmFsLT5yZWFkX2ZyYW1lX3NpemUgPCBwX2Vudi0+cmVhZF9zaXplKSAmJgorCQkJICAgKCBwX2Vudi0+cGFja2luZyA9PSAwKSkgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGF3X3NuZF9zeXNfdmFsaWRhdGVfcnNwKGRldiwgcF9jdGxiaywKKwkJCQkJQ0xBV19SQ19IT1NUX1JDVl9UT09fU01BTEwgKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnRrKEtFUk5fSU5GTyAiJXM6IGhvc3QgcmVhZCBzaXplIGlzIHRvbyAiCisJCQkJCSJzbWFsbFxuIiwgZGV2LT5uYW1lKTsKKwkJCQlDTEFXX0RCRl9URVhUKDIsc2V0dXAsInJkc2l6YmFkIik7CisgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgICAgICBjbGF3X3NuZF9zeXNfdmFsaWRhdGVfcnNwKGRldiwgcF9jdGxiaywgMCApOworICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnRrKCIlczogQ0xBVyBkZXZpY2UgJS44czogU3lzdGVtIHZhbGlkYXRlIgorCQkJCSIgY29tcGxldGVkLlxuIixkZXYtPm5hbWUsIHRlbXBfd3NfbmFtZSk7CisJCQlwcmludGsoIiVzOiBzeXMgVmFsaWRhdGUgUnNpemU6JWQgV3NpemU6JWRcbiIsZGV2LT5uYW1lLAorCQkJCXBfc3lzdmFsLT5yZWFkX2ZyYW1lX3NpemUscF9zeXN2YWwtPndyaXRlX2ZyYW1lX3NpemUpOworICAgICAgICAgICAgICAgICAgICAgICAgcHJpdnB0ci0+c3lzdGVtX3ZhbGlkYXRlX2NvbXA9MTsKKyAgICAgICAgICAgICAgICAJaWYoc3RybmNtcChwX2Vudi0+YXBpX3R5cGUsV1NfQVBQTF9OQU1FX1BBQ0tFRCw2KSA9PSAwKSB7CisJCQkJcF9lbnYtPnBhY2tpbmcgPSBQQUNLSU5HX0FTSzsKKwkJCX0KKyAgICAgICAgICAgICAgICAgICAgICAgIGNsYXdfc3RydF9jb25uX3JlcShkZXYpOworICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisKKyAgICAgICAgICAgICAgICBjYXNlIFNZU1RFTV9WQUxJREFURV9SRVNQT05TRToKKwkJCXBfc3lzdmFsPShzdHJ1Y3Qgc3lzdmFsICopJihwX2N0bGJrLT5kYXRhKTsKKwkJCXByaW50aygiJXM6IFJlY3YgU3lzIFZhbGlkYXRlIFJlc3A6IFZlcnM9JWQsQ29ycj0lZCxSQz0lZCwiCisJCQkJIldTIG5hbWU9JS44cyxIb3N0IG5hbWU9JS44c1xuIiwKKyAgICAgICAgICAgICAgICAgICAgICAgIAlkZXYtPm5hbWUsCisgICAgICAgICAgICAgICAgICAgICAgICAJcF9jdGxiay0+dmVyc2lvbiwKKyAgICAgICAgICAgICAgICAgICAgICAgIAlwX2N0bGJrLT5jb3JyZWxhdG9yLAorICAgICAgICAgICAgICAgICAgICAgICAgCXBfY3RsYmstPnJjLAorICAgICAgICAgICAgICAgICAgICAgICAgCXBfc3lzdmFsLT5XU19uYW1lLAorICAgICAgICAgICAgICAgICAgICAgICAgCXBfc3lzdmFsLT5ob3N0X25hbWUpOworICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChwX2N0bGJrLT5yYykKKyAgICAgICAgICAgICAgICAgICAgICAgIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAwOgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByaW50ayhLRVJOX0lORk8gIiVzOiBDTEFXIGRldmljZSAiCisJCQkJCQkiJS44czogU3lzdGVtIHZhbGlkYXRlICIKKwkJCQkJCSJjb21wbGV0ZWQuXG4iLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGV2LT5uYW1lLCB0ZW1wX3dzX25hbWUpOworCQkJCQlpZiAocHJpdnB0ci0+c3lzdGVtX3ZhbGlkYXRlX2NvbXAgPT0gMCkKKwkgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xhd19zdHJ0X2Nvbm5fcmVxKGRldik7CisJCQkJCXByaXZwdHItPnN5c3RlbV92YWxpZGF0ZV9jb21wPTE7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgQ0xBV19SQ19OQU1FX01JU01BVENIOgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByaW50ayhLRVJOX0lORk8gIiVzOiBTeXMgVmFsaWRhdGUgIgorCQkJCQkJIlJlc3AgOiBIb3N0LCBXUyBuYW1lIGlzICIKKwkJCQkJCSJtaXNtYXRjaFxuIiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRldi0+bmFtZSk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgQ0xBV19SQ19XUk9OR19WRVJTSU9OOgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByaW50ayhLRVJOX0lORk8gIiVzOiBTeXMgVmFsaWRhdGUgIgorCQkJCQkJIlJlc3AgOiBXcm9uZyB2ZXJzaW9uXG4iLAorCQkJCQkJZGV2LT5uYW1lKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBDTEFXX1JDX0hPU1RfUkNWX1RPT19TTUFMTDoKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcmludGsoS0VSTl9JTkZPICIlczogU3lzIFZhbGlkYXRlICIKKwkJCQkJCSJSZXNwIDogYmFkIGZyYW1lIHNpemVcbiIsCisJCQkJCQlkZXYtPm5hbWUpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByaW50ayhLRVJOX0lORk8gIiVzOiBTeXMgVmFsaWRhdGUgIgorCQkJCQkJImVycm9yIGNvZGU9JWQgXG4iLAorCQkJCQkJIGRldi0+bmFtZSwgcF9jdGxiay0+cmMgKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOworCisgICAgICAgICAgICAgICAgY2FzZSBDT05ORUNUSU9OX1JFUVVFU1Q6CisgICAgICAgICAgICAgICAgICAgICAgICBwX2Nvbm5lY3Q9KHN0cnVjdCBjb25uY21kICopJihwX2N0bGJrLT5kYXRhKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHByaW50ayhLRVJOX0lORk8gIiVzOiBSZWN2IENvbm4gUmVxOiBWZXJzPSVkLGxpbmtfaWQ9JWQsIgorCQkJCSJDb3JyPSVkLEhPU1QgYXBwbD0lLjhzLFdTIGFwcGw9JS44c1xuIiwKKyAgICAgICAgICAgICAgICAgICAgICAgIAlkZXYtPm5hbWUsCisJICAgICAgICAgICAgICAgICAgICAgICAgcF9jdGxiay0+dmVyc2lvbiwKKyAgICAgICAgCSAgICAgICAgICAgICAgICBwX2N0bGJrLT5saW5raWQsCisgICAgICAgICAgICAgICAgCSAgICAgICAgcF9jdGxiay0+Y29ycmVsYXRvciwKKyAgICAgICAgICAgICAgICAgICAgICAgIAlwX2Nvbm5lY3QtPmhvc3RfbmFtZSwKKyAgICAgICAgICAgICAgICAgICAgICAJCXBfY29ubmVjdC0+V1NfbmFtZSk7CisgICAgICAgICAgICAgICAgICAgICAgICBpZiAocHJpdnB0ci0+YWN0aXZlX2xpbmtfSUQhPTAgKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsYXdfc25kX2Rpc2MoZGV2LCBwX2N0bGJrKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnRrKEtFUk5fSU5GTyAiJXM6IENvbm4gUmVxIGVycm9yIDogIgorCQkJCQkiYWxyZWFkeSBsb2dpY2FsIGxpbmsgaXMgYWN0aXZlIFxuIiwKKwkJCQkJZGV2LT5uYW1lKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwX2N0bGJrLT5saW5raWQhPTEgKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsYXdfc25kX2Rpc2MoZGV2LCBwX2N0bGJrKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnRrKEtFUk5fSU5GTyAiJXM6IENvbm4gUmVxIGVycm9yIDogIgorCQkJCQkicmVxIGxvZ2ljYWwgbGluayBpZCBpcyBub3QgMVxuIiwKKwkJCQkJZGV2LT5uYW1lKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgICAgIHJjPWZpbmRfbGluayhkZXYsCisJCQkJcF9jb25uZWN0LT5ob3N0X25hbWUsIHBfY29ubmVjdC0+V1NfbmFtZSk7CisgICAgICAgICAgICAgICAgICAgICAgICBpZiAocmMhPTApIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xhd19zbmRfZGlzYyhkZXYsIHBfY3RsYmspOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcmludGsoS0VSTl9JTkZPICIlczogQ29ubiBSZXEgZXJyb3IgOiAiCisJCQkJCSJyZXEgYXBwbCBuYW1lIGRvZXMgbm90IG1hdGNoXG4iLAorCQkJCQkgZGV2LT5uYW1lKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgICAgIGNsYXdfc2VuZF9jb250cm9sKGRldiwKKwkJCQlDT05ORUNUSU9OX0NPTkZJUk0sIHBfY3RsYmstPmxpbmtpZCwKKwkJCQlwX2N0bGJrLT5jb3JyZWxhdG9yLAorCQkJCTAsIHBfY29ubmVjdC0+aG9zdF9uYW1lLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwX2Nvbm5lY3QtPldTX25hbWUpOworCQkJaWYgKHBfZW52LT5wYWNraW5nID09IFBBQ0tJTkdfQVNLKSB7CisJCQkJcHJpbnRrKCIlczogTm93IFBhY2sgYXNrXG4iLGRldi0+bmFtZSk7CisJCQkJcF9lbnYtPnBhY2tpbmcgPSBQQUNLX1NFTkQ7CisJCQkJY2xhd19zbmRfY29ubl9yZXEoZGV2LDApOworCQkJfQorICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnRrKEtFUk5fSU5GTyAiJXM6IENMQVcgZGV2aWNlICUuOHM6IENvbm5lY3Rpb24gIgorCQkJCSJjb21wbGV0ZWQgbGlua19pZD0lZC5cbiIsCisJCQkJZGV2LT5uYW1lLCB0ZW1wX3dzX25hbWUsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBfY3RsYmstPmxpbmtpZCk7CisgICAgICAgICAgICAgICAgICAgICAgICBwcml2cHRyLT5hY3RpdmVfbGlua19JRD1wX2N0bGJrLT5saW5raWQ7CisgICAgICAgICAgICAgICAgICAgICAgICBwX2NoPSZwcml2cHRyLT5jaGFubmVsW1dSSVRFXTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHdha2VfdXAoJnBfY2gtPndhaXQpOyAgLyogd2FrZSB1cCBjbGF3X29wZW4gKCBXUklURSkgKi8KKyAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgIGNhc2UgQ09OTkVDVElPTl9SRVNQT05TRToKKyAgICAgICAgICAgICAgICAgICAgICAgIHBfY29ubmVjdD0oc3RydWN0IGNvbm5jbWQgKikmKHBfY3RsYmstPmRhdGEpOworICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnRrKEtFUk5fSU5GTyAiJXM6IFJldmMgQ29ubiBSZXNwOiBWZXJzPSVkLGxpbmtfaWQ9JWQsIgorCQkJCSJDb3JyPSVkLFJDPSVkLEhvc3QgYXBwbD0lLjhzLCBXUyBhcHBsPSUuOHNcbiIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRldi0+bmFtZSwKKwkJCQlwX2N0bGJrLT52ZXJzaW9uLAorCQkJCXBfY3RsYmstPmxpbmtpZCwKKwkJCQlwX2N0bGJrLT5jb3JyZWxhdG9yLAorCQkJCXBfY3RsYmstPnJjLAorCQkJCXBfY29ubmVjdC0+aG9zdF9uYW1lLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwX2Nvbm5lY3QtPldTX25hbWUpOworCisgICAgICAgICAgICAgICAgICAgICAgICBpZiAocF9jdGxiay0+cmMgIT0wICkgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcmludGsoS0VSTl9JTkZPICIlczogQ29ubiBSZXNwIGVycm9yOiByYz0lZCBcbiIsCisJCQkJCWRldi0+bmFtZSwgcF9jdGxiay0+cmMpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gMTsKKyAgICAgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgICAgIHJjPWZpbmRfbGluayhkZXYsCisJCQkJcF9jb25uZWN0LT5ob3N0X25hbWUsIHBfY29ubmVjdC0+V1NfbmFtZSk7CisgICAgICAgICAgICAgICAgICAgICAgICBpZiAocmMhPTApIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xhd19zbmRfZGlzYyhkZXYsIHBfY3RsYmspOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcmludGsoS0VSTl9JTkZPICIlczogQ29ubiBSZXNwIGVycm9yOiAiCisJCQkJCSJyZXEgYXBwbCBuYW1lIGRvZXMgbm90IG1hdGNoXG4iLAorCQkJCQkgZGV2LT5uYW1lKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIH0KKwkJCS8qIHNob3VsZCBiZSB1bnRpbCBDT05ORUNUSU9OX0NPTkZJUk0gKi8KKyAgICAgICAgICAgICAgICAgICAgICAgIHByaXZwdHItPmFjdGl2ZV9saW5rX0lEID0gIC0gKHBfY3RsYmstPmxpbmtpZCk7CisgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgICBjYXNlIENPTk5FQ1RJT05fQ09ORklSTToKKyAgICAgICAgICAgICAgICAgICAgICAgIHBfY29ubmVjdD0oc3RydWN0IGNvbm5jbWQgKikmKHBfY3RsYmstPmRhdGEpOworICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnRrKEtFUk5fSU5GTyAiJXM6IFJlY3YgQ29ubiBDb25maXJtOlZlcnM9JWQsbGlua19pZD0lZCwiCisJCQkJIkNvcnI9JWQsSG9zdCBhcHBsPSUuOHMsV1MgYXBwbD0lLjhzXG4iLAorICAgICAgICAgICAgICAgICAgICAgICAgZGV2LT5uYW1lLAorICAgICAgICAgICAgICAgICAgICAgICAgcF9jdGxiay0+dmVyc2lvbiwKKyAgICAgICAgICAgICAgICAgICAgICAgIHBfY3RsYmstPmxpbmtpZCwKKyAgICAgICAgICAgICAgICAgICAgICAgIHBfY3RsYmstPmNvcnJlbGF0b3IsCisgICAgICAgICAgICAgICAgICAgICAgICBwX2Nvbm5lY3QtPmhvc3RfbmFtZSwKKyAgICAgICAgICAgICAgICAgICAgICAgIHBfY29ubmVjdC0+V1NfbmFtZSk7CisgICAgICAgICAgICAgICAgICAgICAgICBpZiAocF9jdGxiay0+bGlua2lkPT0gLShwcml2cHRyLT5hY3RpdmVfbGlua19JRCkpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJpdnB0ci0+YWN0aXZlX2xpbmtfSUQ9cF9jdGxiay0+bGlua2lkOworCQkJCWlmIChwX2Vudi0+cGFja2luZyA+IFBBQ0tJTkdfQVNLKSB7CisJCQkJCXByaW50ayhLRVJOX0lORk8gIiVzOiBDb25maXJtZWQgTm93IHBhY2tpbmdcbiIsZGV2LT5uYW1lKTsKKwkJCQkJcF9lbnYtPnBhY2tpbmcgPSBET19QQUNLRUQ7CisJCQkJCX0KKwkJCQlwX2NoPSZwcml2cHRyLT5jaGFubmVsW1dSSVRFXTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2FrZV91cCgmcF9jaC0+d2FpdCk7CisgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgICAgICBlbHNlIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnRrKEtFUk5fSU5GTyAiJXM6IENvbm4gY29uZmlybTogIgorCQkJCQkidW5leHBlY3RlZCBsaW5raWQ9JWQgXG4iLAorCQkJCQlkZXYtPm5hbWUsIHBfY3RsYmstPmxpbmtpZCk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsYXdfc25kX2Rpc2MoZGV2LCBwX2N0bGJrKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgIGNhc2UgRElTQ09OTkVDVDoKKyAgICAgICAgICAgICAgICAgICAgICAgIHByaW50ayhLRVJOX0lORk8gIiVzOiBEaXNjb25uZWN0OiAiCisJCQkJIlZlcnM9JWQsbGlua19pZD0lZCxDb3JyPSVkXG4iLAorCQkJCWRldi0+bmFtZSwgcF9jdGxiay0+dmVyc2lvbiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcF9jdGxiay0+bGlua2lkLCBwX2N0bGJrLT5jb3JyZWxhdG9yKTsKKwkJCWlmICgocF9jdGxiay0+bGlua2lkID09IDIpICYmCisJCQkgICAgKHBfZW52LT5wYWNraW5nID09IFBBQ0tfU0VORCkpIHsKKwkJCQlwcml2cHRyLT5hY3RpdmVfbGlua19JRCA9IDE7CisJCQkJcF9lbnYtPnBhY2tpbmcgPSBET19QQUNLRUQ7CisJCQl9CisJCQllbHNlCisJICAgICAgICAgICAgICAgICAgICAgICAgcHJpdnB0ci0+YWN0aXZlX2xpbmtfSUQ9MDsKKyAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgIGNhc2UgQ0xBV19FUlJPUjoKKyAgICAgICAgICAgICAgICAgICAgICAgIHByaW50ayhLRVJOX0lORk8gIiVzOiBDTEFXIEVSUk9SIGRldGVjdGVkXG4iLAorCQkJCWRldi0+bmFtZSk7CisgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgICBkZWZhdWx0OgorICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnRrKEtFUk5fSU5GTyAiJXM6ICBVbmV4cGVjdGVkIGNvbW1hbmQgY29kZT0lZCBcbiIsCisJCQkJZGV2LT5uYW1lLCAgcF9jdGxiay0+Y29tbWFuZCk7CisgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgfQorCisjaWZkZWYgRlVOQ1RSQUNFCisgICAgICAgIHByaW50ayhLRVJOX0lORk8gIiVzOiAlcygpIGV4aXQgb24gbGluZSAlZCwgcmMgPSAwXG4iLAorCQlkZXYtPm5hbWUsX19GVU5DVElPTl9fLF9fTElORV9fKTsKKyNlbmRpZgorCisgICAgICAgIHJldHVybiAwOworfSAgIC8qICAgIGVuZCBvZiBjbGF3X3Byb2Nlc3NfY29udHJvbCAgICAqLworCisKKy8qLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSoKKyogICAgICAgICAgICAgICBjbGF3X3NlbmRfY29udHJvbCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICoKKyogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICoKKyotLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSovCisKK3N0YXRpYyBpbnQKK2NsYXdfc2VuZF9jb250cm9sKHN0cnVjdCBuZXRfZGV2aWNlICpkZXYsIF9fdTggdHlwZSwgX191OCBsaW5rLAorCSBfX3U4IGNvcnJlbGF0b3IsIF9fdTggcmMsIGNoYXIgKmxvY2FsX25hbWUsIGNoYXIgKnJlbW90ZV9uYW1lKQoreworICAgICAgICBzdHJ1Y3QgY2xhd19wcml2YmsgCQkqcHJpdnB0cjsKKyAgICAgICAgc3RydWN0IGNsYXdjdGwgICAgICAgICAgICAgICAgICAqcF9jdGw7CisgICAgICAgIHN0cnVjdCBzeXN2YWwgICAgICAgICAgICAgICAgICAgKnBfc3lzdmFsOworICAgICAgICBzdHJ1Y3QgY29ubmNtZCAgICAgICAgICAgICAgICAgICpwX2Nvbm5lY3Q7CisgICAgICAgIHN0cnVjdCBza19idWZmIAkJCSpza2I7CisKKyNpZmRlZiBGVU5DVFJBQ0UKKyAgICAgICAgcHJpbnRrKEtFUk5fSU5GTyAiJXM6JXMgPiBlbnRlciA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TVEVNX1ZBTElEQVRFX1JFUVVFU1Q6CisgICAgICAgICAgICAgICAgY2FzZSBTWVNURU1fVkFMSURBVEVfUkVTUE9OU0U6CisgICAgICAgICAgICAgICAgICAgICAgICBtZW1jcHkoJnBfc3lzdmFsLT5ob3N0X25hbWUsIGxvY2FsX25hbWUsIDgpOworICAgICAgICAgICAgICAgICAgICAgICAgbWVtY3B5KCZwX3N5c3ZhbC0+V1NfbmFtZSwgcmVtb3RlX25hbWUsIDgpOworCQkJaWYgKHByaXZwdHItPnBfZW52LT5wYWNraW5nID4gMCkgeworICAgICAgICAgICAgICAgICAgICAgICAgCXBfc3lzdmFsLT5yZWFkX2ZyYW1lX3NpemU9REVGX1BBQ0tfQlVGU0laRTsKKwkgICAgICAgICAgICAgICAgICAgICAgICBwX3N5c3ZhbC0+d3JpdGVfZnJhbWVfc2l6ZT1ERUZfUEFDS19CVUZTSVpFOworCQkJfSBlbHNlIHsKKwkJCQkvKiBob3cgYmlnIGlzIHRoZSBwaWdnZXN0IGdyb3VwIG9mIHBhY2tldHMgKi8KKwkJCQlwX3N5c3ZhbC0+cmVhZF9mcmFtZV9zaXplPXByaXZwdHItPnBfZW52LT5yZWFkX3NpemU7CisJICAgICAgICAgICAgICAgICAgICAgICAgcF9zeXN2YWwtPndyaXRlX2ZyYW1lX3NpemU9cHJpdnB0ci0+cF9lbnYtPndyaXRlX3NpemU7CisJCQl9CisgICAgICAgICAgICAgICAgICAgICAgICBtZW1zZXQoJnBfc3lzdmFsLT5yZXNlcnZlZCwgMHgwMCwgNCk7CisgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgICBjYXNlIENPTk5FQ1RJT05fUkVRVUVTVDoKKyAgICAgICAgICAgICAgICBjYXNlIENPTk5FQ1RJT05fUkVTUE9OU0U6CisgICAgICAgICAgICAgICAgY2FzZSBDT05ORUNUSU9OX0NPTkZJUk06CisgICAgICAgICAgICAgICAgY2FzZSBESVNDT05ORUNUOgorICAgICAgICAgICAgICAgICAgICAgICAgbWVtY3B5KCZwX3N5c3ZhbC0+aG9zdF9uYW1lLCBsb2NhbF9uYW1lLCA4KTsKKyAgICAgICAgICAgICAgICAgICAgICAgIG1lbWNweSgmcF9zeXN2YWwtPldTX25hbWUsIHJlbW90ZV9uYW1lLCA4KTsKKwkJCWlmIChwcml2cHRyLT5wX2Vudi0+cGFja2luZyA+IDApIHsKKwkJCS8qIEhvdyBiaWcgaXMgdGhlIGJpZ2dlc3QgcGFja2V0ICovCisJCQkJcF9jb25uZWN0LT5yZXNlcnZlZDFbMF09Q0xBV19GUkFNRV9TSVpFOworICAgICAgICAgICAgICAgICAgICAgICAgCXBfY29ubmVjdC0+cmVzZXJ2ZWQxWzFdPUNMQVdfRlJBTUVfU0laRTsKKwkJCX0gZWxzZSB7CisJICAgICAgICAgICAgICAgICAgICAgICAgbWVtc2V0KCZwX2Nvbm5lY3QtPnJlc2VydmVkMSwgMHgwMCwgNCk7CisgICAgICAgIAkgICAgICAgICAgICAgICAgbWVtc2V0KCZwX2Nvbm5lY3QtPnJlc2VydmVkMiwgMHgwMCwgNCk7CisJCQl9CisgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgICBkZWZhdWx0OgorICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIH0KKworICAgICAgICAvKiAgICAgIHdyaXRlIENvbnRyb2wgUmVjb3JkIHRvIHRoZSBkZXZpY2UgICAgICAgICAgICAgICAgICAgKi8KKworCisgICAgICAgIHNrYiA9IGRldl9hbGxvY19za2Ioc2l6ZW9mKHN0cnVjdCBjbGF3Y3RsKSk7CisgICAgICAgIGlmICghc2tiKSB7CisgICAgICAgICAgICAgICAgcHJpbnRrKCAgIiVzOiVzIGxvdyBvbiBtZW0sIHJldHVybmluZy4uLlxuIiwKKwkJCWRldi0+bmFtZSxfX0ZVTkNUSU9OX18pOworI2lmZGVmIERFQlVHCisgICAgICAgICAgICAgICAgcHJpbnRrKE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AgICAgICAgICoKKyotLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSovCitzdGF0aWMgaW50CitjbGF3X3NuZF9jb25uX3JlcShzdHJ1Y3QgbmV0X2RldmljZSAqZGV2LCBfX3U4IGxpbmspCit7CisgICAgICAgIGludCAgICAgICAgICAgICAgICByYzsKKyAgICAgICAgc3RydWN0IGNsYXdfcHJpdmJrICpwcml2cHRyPWRldi0+cHJpdjsKKyAgICAgICAgc3RydWN0IGNsYXdjdGwgCSAgICpwX2N0bDsKKworI2lmZGVmIEZVTkNUUkFDRQorICAgICAgICBwcmludGsoS0VSTl9JTkZPICIlczolcyBFbnRlciAgXG4iLGRldi0+bmFtZSxfX0ZVTkNUSU9OX18pOworI2VuZGlmCisJQ0xBV19EQkZfVEVYVCgyLHNldHVwLCJzbmRfY29ubiIpOworI2lmZGVmICBERUJVR01TRworICAgICAgICBwcmludGsoS0VSTl9JTkZPICIlczogdmFyaWFibGUgbGluayA9ICVYLCBkZXYgPVxuIixkZXYtPm5hbWUsIGxpbmspOworICAgICAgICBkdW1waXQoKGNoYXIgKikgZGV2LCBzaXplb2Yoc3RydWN0IG5ldF9kZXZpY2UpKTsKKyNlbmRpZgorCXJjID0gMTsKKyAgICAgICAgcF9jdGw9KHN0cnVjdCBjbGF3Y3RsICopJnByaXZwdHItPmN0bF9iazsKKwlwX2N0bC0+bGlua2lkID0gbGluazsKKyAgICAgICAgaWYgKCBwcml2cHRyLT5zeXN0ZW1fdmFsaWRhdGVfY29tcD09MHgwMCApIHsKKyNpZmRlZiBGVU5DVFJBQ0UKKyAgICAgICAgICAgICAgICBwcmludGsoS0VSTl9JTkZPICIlczolcyBFeGl0IG9uIGxpbmUgJWQsIHJjID0gMVxuIiwKKwkJCWRldi0+bmFtZSxfX0ZVTkNUSU9OX18sX19MSU5FX18pOworI2VuZGlmCisgICAgICAgICAgICAgICAgcmV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AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKgorKi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKi8KKworc3RhdGljIGludAorY2xhd19zbmRfZGlzYyhzdHJ1Y3QgbmV0X2RldmljZSAqZGV2LCBzdHJ1Y3QgY2xhd2N0bCAqIHBfY3RsKQoreworICAgICAgICBpbnQgcmM7CisgICAgICAgIHN0cnVjdCBjb25uY21kICogIHBfY29ubmVjdDsKKworI2lmZGVmIEZVTkNUUkFDRQorICAgICAgICBwcmludGsoS0VSTl9JTkZPICIlczolcyBFbnRlclxuIixkZXYtPm5hbWUsX19GVU5DVElPTl9fKTsKKyNlbmRpZgorCUNMQVdfREJGX1RFWFQoMixzZXR1cCwic25kX2RzYyIpOworI2lmZGVmICBERUJVR01TRworICAgICAgICBwcmludGsoS0VSTl9JTkZPICIlczogdmFyaWFibGUgZGV2ID1cbiIsZGV2LT5uYW1lKTsKKyAgICAgICAgZHVtcGl0KChjaGFyICopIGRldiwgc2l6ZW9mKHN0cnVjdCBuZXRfZGV2aWNlKSk7CisgICAgICAgIHByaW50ayhLRVJOX0lORk8gIiVzOiB2YXJpYWJsZSBwX2N0bCIsZGV2LT5uYW1lKTsKKyAgICAgICAgZHVtcGl0KChjaGFyICopIHBfY3RsLCBzaXplb2Yoc3RydWN0IGNsYXdjdGwpKTsKKyNlbmRpZgorICAgICAgICBwX2Nvbm5lY3Q9KHN0cnVjdCBjb25uY21kICopJnBfY3RsLT5kYXRhOworCisgICAgICAgIHJjPWNsYXdfc2VuZF9jb250cm9sKGRldiwgRElTQ09OTkVDVCwgcF9jdGwtPmxpbmtpZCwKKwkJcF9jdGwtPmNvcnJlbGF0b3IsIDAsCisgICAgICAgICAgICAgICAgcF9jb25uZWN0LT5ob3N0X25hbWUsIHBfY29ubmVjdC0+V1NfbmFtZSk7CisjaWZkZWYgRlVOQ1RSQUNFCisgICAgICAgIHByaW50ayhLRVJOX0lORk8gIiVzOiVzIEV4aXQgb24gbGluZSAlZCwgcmMgPSAlZFxuIiwKKwkJZGV2LT5uYW1lLF9fRlVOQ1RJT05fXywgX19MSU5FX18sIHJjKTsKKyNlbmRpZgorICAgICAgICByZXR1cm4gcmM7Cit9ICAgICAvKiAgIGVuZCBvZiBjbGF3X3NuZF9kaXNjICAgICovCisKKworLyotLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKgorKiAgICAgICAgICAgICAgIGNsYXdfc25kX3N5c192YWxpZGF0ZV9yc3AgICAgICAgICAgICAgICAgICAgICAgICAgICAgKgorKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKgorKi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKi8KKworc3RhdGljIGludAorY2xhd19zbmRfc3lzX3ZhbGlkYXRlX3JzcChzdHJ1Y3QgbmV0X2RldmljZSAqZGV2LAorCXN0cnVjdCBjbGF3Y3RsICpwX2N0bCwgX191MzIgcmV0dXJuX2NvZGUpCit7CisgICAgICAgIHN0cnVjdCBjbGF3X2VudiAqICBwX2VudjsKKyAgICAgICAgc3RydWN0IGNsYXdfcHJpdmJrICpwcml2cHRyOworICAgICAgICBpbnQgICAgcmM7CisKKyNpZmRlZiBGVU5DVFJBQ0UKKyAgICAgICAgcHJpbnRrKEtFUk5fSU5GTyAiJXM6JXMgRW50ZXJcbiIsCisJCWRldi0+bmFtZSxfX0ZVTkNUSU9OX18pOworI2VuZGlmCisJQ0xBV19EQkZfVEVYVCgyLHNldHVwLCJjaGtyZXNwIik7CisjaWZkZWYgREVCVUdNU0cKK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tLS0tLS0tLS0tLSoKKyAqICAgY2xhd19zdGF0cyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICoKKyAqLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSovCisKK3N0YXRpYyBzdHJ1Y3QKK25ldF9kZXZpY2Vfc3RhdHMgKmNsYXdfc3RhdHMoc3RydWN0IG5ldF9kZXZpY2UgKmRldikKK3sKKyAgICAgICAgc3RydWN0IGNsYXdfcHJpdmJrICpwcml2cHRyOworI2lmZGVmIEZVTkNUUkFDRQorICAgICAgICBwcmludGsoS0VSTl9JTkZPICIlczolcyBFbnRlclxuIixkZXYtPm5hbWUsX19GVU5DVElPTl9fKTsKKyNlbmRpZgorCUNMQVdfREJGX1RFWFQoNCx0cmFjZSwic3RhdHMiKTsKKyAgICAgICAgcHJpdnB0ciA9IGRldi0+cHJpdjsKKyNpZmRlZiBGVU5DVFJBQ0UKKyAgICAgICAgcHJpbnRrKEtFUk5fSU5GTyAiJXM6JXMgRXhpdCBvbiBsaW5lICVkXG4iLAorCQlkZXYtPm5hbWUsX19GVU5DVElPTl9fLF9fTElORV9fKTsKKyNlbmRpZgorICAgICAgICByZXR1cm4gJnByaXZwdHItPnN0YXRzOworfSAgICAgLyogICBlbmQgb2YgY2xhd19zdGF0cyAgICovCisKKworLyotLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKgorKiAgICAgICB1bnBhY2tfcmVhZCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKgorKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKgorKi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tL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sgIC8qIHBlZWsgcGFzdCBwYWNrIGhlYWRlciAqLworCQkJcF9jdGxyZWMgPSAoc3RydWN0IGNsYXdjdGwgKilwX3BhY2toOworCQkJcF9wYWNraC0tOyAgLyogdW4gcGVlayAqLworCQkJaWYgKChwX2N0bHJlYy0+Y29tbWFuZCA9PSBDT05ORUNUSU9OX1JFU1BPTlNFKSB8fAorCQkgICAgICAgICAgICAocF9jdGxyZWMtPmNvbW1hbmQgPT0gQ09OTkVDVElPTl9DT05GSVJNKSkKKwkJCQlwX2Vudi0+cGFja2luZyA9IERPX1BBQ0tFRDsKKwkJfQorCQlpZiAocF9lbnYtPnBhY2tpbmcgPT0gRE9fUEFDS0VEKQorCQkJbGlua19udW09cF9wYWNraC0+bGlua19udW07CisJCWVsc2UKKwkgICAgICAgICAgICAgICAgbGlua19udW09cF90aGlzX2Njdy0+aGVhZGVyLm9wY29kZSAvIDg7CisgICAgICAgICAgICAgICAgaWYgKChwX3RoaXNfY2N3LT5oZWFkZXIub3Bjb2RlICYgTU9SRV90b19DT01FX0ZMQUcpIT0wKSB7CisjaWZkZWYgREVCVUdNU0cKKyAgICAgICAgICAgICAgICAgICAgICAgIHByaW50ayhLRVJOX0lORk8gIiVzOiAlcyA+IE1vcmVfdG9fY29tZSBpcyBPTlxuIiwKKwkJCWRldi0+bmFtZSxfX0ZVTkNUSU9OX18pOworI2VuZGlmCisgICAgICAgICAgICAgICAgICAgICAgICBtdGNfdGhpc19mcm09MTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwX3RoaXNfY2N3LT5oZWFkZXIubGVuZ3RoIT0KKwkJCQlwcml2cHRyLT5wX2Vudi0+cmVhZF9zaXplICkgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcmludGsoS0VSTl9JTkZPICIgJXM6IEludmFsaWQgZnJhbWUgZGV0ZWN0ZWQgIgorCQkJCQkibGVuZ3RoIGlzICUwMnhcbiIgLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRldi0+bmFtZSwgcF90aGlzX2Njdy0+aGVhZGVyLmxlbmd0aCk7CisgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgfQorCisgICAgICAgICAgICAgICAgaWYgKHByaXZwdHItPm10Y19za2lwcGluZykgeworICAgICAgICAgICAgICAgICAgICAgICAgLyoKKyAgICAgICAgICAgICAgICAgICAgICAgICogICBXZSdyZSBpbiB0aGUgbW9kZSBvZiBza2lwcGluZyBwYXN0IGEKKwkJCSogICBtdWx0aS1mcmFtZSBtZXNzYWdlCisgICAgICAgICAgICAgICAgICAgICAgICAqICAgdGhhdCB3ZSBjYW4ndCBwcm9jZXNzIGZvciBzb21lIHJlYXNvbiBvciBvdGhlci4KKyAgICAgICAgICAgICAgICAgICAgICAgICogICBUaGUgZmlyc3QgZnJhbWUgd2l0aG91dCB0aGUgTW9yZS1Uby1Db21lIGZsYWcgaXMKKwkJCSogICB0aGUgbGFzdCBmcmFtZSBvZiB0aGUgc2tpcHBlZCBtZXNzYWdlLgorICAgICAgICAgICAgICAgICAgICAgICAgKi8KKyAgICAgICAgICAgICAgICAgICAgICAgIC8qICBpbiBjYXNlIG9mIE1vcmUtVG8tQ29tZSBub3Qgc2V0IGluIHRoaXMgZnJhbWUgKi8KKyAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtdGNfdGhpc19mcm09PTApIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJpdnB0ci0+bXRjX3NraXBwaW5nPTA7IC8qIE9rLCB0aGUgZW5kICovCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByaXZwdHItPm10Y19sb2dpY2FsX2xpbms9LTE7CisgICAgICAgICAgICAgICAgICAgICAgICB9CisjaWZkZWYgREVCVUdNU0cKKyAgICAgICAgICAgICAgICAgICAgICAgIHByaW50ayhLRVJOX0lORk8gIiVzOiVzIGdvdG8gbmV4dCAiCisJCQkJImZyYW1lIGZyb20gTW9yZXRvQ29tZVNraXAgXG4iLAorCQkJCWRldi0+bmFtZSxfX0ZVTkNUSU9OX18pOworI2VuZGlmCisgICAgICAgICAgICAgICAgICAgICAgICBnb3RvIE5leHRGcmFtZTsKKyAgICAgICAgICAgICAgICB9CisKKyAgICAgICAgICAgICAgICBpZiAobGlua19udW09PTApIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIGNsYXdfcHJvY2Vzc19jb250cm9sKGRldiwgcF90aGlzX2Njdyk7CisjaWZkZWYgREVCVUdNU0cKKyAgICAgICAgICAgICAgICAgICAgICAgIHByaW50ayhLRVJOX0lORk8gIiVzOiVzIGdvdG8gbmV4dCAiCisJCQkJImZyYW1lIGZyb20gY2xhd19wcm9jZXNzX2NvbnRyb2wgXG4iLAorCQkJCWRldi0+bmFtZSxfX0ZVTkNUSU9OX18pOworI2VuZGlmCisJCQlDTEFXX0RCRl9URVhUKDQsdHJhY2UsIlVucGtDbnRsIik7CisgICAgICAgICAgICAgICAgICAgICAgICBnb3RvIE5leHRGcmFtZTsKKyAgICAgICAgICAgICAgICB9Cit1bnBhY2tfbmV4dDoKKwkJaWYgKHBfZW52LT5wYWNraW5nID09IERPX1BBQ0tFRCkgeworCQkJaWYgKHBhY2tfb2ZmID4gcF9lbnYtPnJlYWRfc2l6ZSkKKwkJCQlnb3RvIE5leHRGcmFtZTsKKwkJCXBfcGFja2QgPSBwX3RoaXNfY2N3LT5wX2J1ZmZlcitwYWNrX29mZjsKKwkJCXBfcGFja2ggPSAoc3RydWN0IGNsYXdwaCAqKSBwX3BhY2tkOworCQkJaWYgKChwX3BhY2toLT5sZW4gPT0gMCkgfHwgLyogYWxsIGRvbmUgd2l0aCB0aGlzIGZyYW1lPyAqLworCQkJICAgIChwX3BhY2toLT5mbGFnICE9IDApKQorCQkJCWdvdG8gTmV4dEZyYW1lOworCQkJYnl0ZXNfdG9fbW92ID0gcF9wYWNraC0+bGVuOworCQkJcGFja19vZmYgKz0gYnl0ZXNfdG9fbW92K3NpemVvZihzdHJ1Y3QgY2xhd3BoKTsKKwkJCXArKzsKKwkJfSBlbHNlIHsKKyAgICAgICAgICAgICAgICAJYnl0ZXNfdG9fbW92PXBfdGhpc19jY3ctPmhlYWRlci5sZW5ndGg7CisJCX0KKyAgICAgICAgICAgICAgICBpZiAocHJpdnB0ci0+bXRjX2xvZ2ljYWxfbGluazwwKSB7CisjaWZkZWYgREVCVUdNU0cKKyAgICAgICAgICAgICAgICBwcmludGsoS0VSTl9JTkZPICIlczogJXMgbXRjX2xvZ2ljYWxfbGluayA8IDAgIFxuIiwKKwkJCWRldi0+bmFtZSxfX0ZVTkNUSU9OX18pOworI2VuZGlmCisKKyAgICAgICAgICAgICAgICAvKgorICAgICAgICAgICAgICAgICogIGlmIE1vcmUtVG8tQ29tZSBpcyBzZXQgaW4gdGhpcyBmcmFtZSB0aGVuIHdlIGRvbid0IGtub3cKKyAgICAgICAgICAgICAgICAqICBsZW5ndGggb2YgZW50aXJlIG1lc3NhZ2UsIGFuZCBoZW5jZSBoYXZlIHRvIGFsbG9jYXRlCisJCSogIGxhcmdlIGJ1ZmZlciAgICovCisKKyAgICAgICAgICAgICAgICAvKiAgICAgIFdlIGFyZSBzdGFydGluZyBhIG5ldyBlbnZlbG9wZSAgKi8KKyAgICAgICAgICAgICAgICBwcml2cHRyLT5tdGNfb2Zmc2V0PTA7CisgICAgICAgICAgICAgICAgICAgICAgICBwcml2cHRyLT5tdGNfbG9naWNhbF9saW5rPWxpbmtfbnVtOworICAgICAgICAgICAgICAgIH0KKworICAgICAgICAgICAgICAgIGlmIChieXRlc190b19tb3YgPiAoTUFYX0VOVkVMT1BFX1NJWkUtIHByaXZwdHItPm10Y19vZmZzZXQpICkgeworICAgICAgICAgICAgICAgICAgICAgICAgLyogICAgICBlcnJvciAgICAgKi8KKyNpZmRlZiBERUJVR01TRworICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnRrKEtFUk5fSU5GTyAiJXM6ICVzID4gZ290byBuZXh0ICIKKwkJCQkiZnJhbWUgZnJvbSBNb3JldG9Db21lU2tpcCBcbiIsCisJCQkJZGV2LT5uYW1lLAorCQkJCV9fRlVOQ1RJT05fXyk7CisgICAgICAgICAgICAgICAgICAgICAgICBwcmludGsoS0VSTl9JTkZPICIgICAgICBieXRlc190b19tb3YgJWQgPiAoTUFYX0VOVkVMT1BFXyIKKwkJCQkiU0laRS1wcml2cHRyLT5tdGNfb2Zmc2V0ICVkKVxuIiwKKwkJCQlieXRlc190b19tb3YsKE1BWF9FTlZFTE9QRV9TSVpFLSBwcml2cHRyLT5tdGNfb2Zmc2V0KSk7CisjZW5kaWYKKyAgICAgICAgICAgICAgICAgICAgICAgIHByaXZwdHItPnN0YXRzLnJ4X2ZyYW1lX2Vycm9ycysrOworICAgICAgICAgICAgICAgICAgICAgICAgZ290byBOZXh0RnJhbWU7CisgICAgICAgICAgICAgICAgfQorCQlpZiAocF9lbnYtPnBhY2tpbmcgPT0gRE9fUEFDS0VEKSB7CisJCQltZW1jcHkoIHByaXZwdHItPnBfbXRjX2VudmVsb3BlKyBwcml2cHRyLT5tdGNfb2Zmc2V0LAorCQkJCXBfcGFja2Qrc2l6ZW9mKHN0cnVjdCBjbGF3cGgpLCBieXRlc190b19tb3YpOworCisJCX0gZWxzZQl7CisgICAgICAgICAgICAgICAgCW1lbWNweSggcHJpdnB0ci0+cF9tdGNfZW52ZWxvcGUrIHByaXZwdHItPm10Y19vZmZzZXQsCisgICAgICAgICAgICAgICAgICAgICAgICAJcF90aGlzX2Njdy0+cF9idWZmZXIsIGJ5dGVzX3RvX21vdik7CisJCX0KKyNpZmRlZiBERUJVR01TRworICAgICAgICAgICAgICAgIHByaW50ayhLRVJOX0lORk8gIiVzOiAlcygpIHJlY2VpdmVkIGRhdGEgXG4iLAorCQkJZGV2LT5uYW1lLF9fRlVOQ1RJT05fXyk7CisJCWlmIChwX2Vudi0+cGFja2luZyA9PSBET19QQUNLRUQpCisJCQlkdW1waXQoKGNoYXIgKilwX3BhY2tkK3NpemVvZihzdHJ1Y3QgY2xhd3BoKSwzMik7CisJCWVsc2UKKwkgICAgICAgICAgICAgICAgZHVtcGl0KChjaGFyICopcF90aGlzX2Njdy0+cF9idWZmZXIsIDMyKTsKKwkJcHJpbnRrKEtFUk5fSU5GTyAiJXM6ICVzKCkgYnl0ZWxlbmd0aCAlZCBcbiIsCisJCQlkZXYtPm5hbWUsX19GVU5DVElPTl9fLGJ5dGVzX3RvX21vdik7CisjZW5kaWYKKyAgICAgICAgICAgICAgICBpZiAobXRjX3RoaXNfZnJtPT0wKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBsZW5fb2ZfZGF0YT1wcml2cHRyLT5tdGNfb2Zmc2V0K2J5dGVzX3RvX21vdjsKKyAgICAgICAgICAgICAgICAgICAgICAgIHNrYj1kZXZfYWxsb2Nfc2tiKGxlbl9vZl9kYXRhKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGlmIChza2IpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWVtY3B5KHNrYl9wdXQoc2tiLGxlbl9vZl9kYXRhKSwKKwkJCQkJcHJpdnB0ci0+cF9tdGNfZW52ZWxvcGUsCisJCQkJCWxlbl9vZl9kYXRhKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2tiLT5tYWMucmF3PXNrYi0+ZGF0YTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2tiLT5kZXY9ZGV2OworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBza2ItPnByb3RvY29sPWh0b25zKEVUSF9QX0lQKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2tiLT5pcF9zdW1tZWQ9Q0hFQ0tTVU1fVU5ORUNFU1NBUlk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByaXZwdHItPnN0YXRzLnJ4X3BhY2tldHMrKzsKKwkJCQlwcml2cHRyLT5zdGF0cy5yeF9ieXRlcys9bGVuX29mX2RhdGE7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ldGlmX3J4KHNrYik7CisjaWZkZWYgREVCVUdNU0cKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnRrKEtFUk5fSU5GTyAiJXM6ICVzKCkgbmV0aWZfIgorCQkJCQkicngoc2tiKSBjb21wbGV0ZWQgXG4iLAorCQkJCQlkZXYtPm5hbWUsX19GVU5DVElPTl9fKTsKKyNlbmRpZgorICAgICAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICAgICAgZWxzZSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByaXZwdHItPnN0YXRzLnJ4X2Ryb3BwZWQrKzsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnRrKEtFUk5fV0FSTklORyAiJXM6ICVzKCkgbG93IG9uIG1lbW9yeVxuIiwKKwkJCQlkZXYtPm5hbWUsX19GVU5DVElPTl9fKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgICAgIHByaXZwdHItPm10Y19vZmZzZXQ9MDsKKyAgICAgICAgICAgICAgICAgICAgICAgIHByaXZwdHItPm10Y19sb2dpY2FsX2xpbms9LTE7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIGVsc2UgeworICAgICAgICAgICAgICAgICAgICAgICAgcHJpdnB0ci0+bXRjX29mZnNldCs9Ynl0ZXNfdG9fbW92OworICAgICAgICAgICAgICAgIH0KKwkJaWYgKHBfZW52LT5wYWNraW5nID09IERPX1BBQ0tFRCkKKwkJCWdvdG8gdW5wYWNrX25leHQ7CitOZXh0RnJhbWU6CisgICAgICAgICAgICAgICAgLyoKKyAgICAgICAgICAgICAgICAqICAgUmVtb3ZlIFRoaXNDQ1dibG9jayBmcm9tIGFjdGl2ZSByZWFkIHF1ZXVlLCBhbmQgYWRkIGl0CisgICAgICAgICAgICAgICAgKiAgIHRvIHF1ZXVlIG9mIGZyZWUgYmxvY2tzIHRvIGJlIHJldXNlZC4KKyAgICAgICAgICAgICAgICAqLworICAgICAgICAgICAgICAgIGkrKzsKKyAgICAgICAgICAgICAgICBwX3RoaXNfY2N3LT5oZWFkZXIubGVuZ3RoPTB4ZmZmZjsKKyAgICAgICAgICAgICAgICBwX3RoaXNfY2N3LT5oZWFkZXIub3Bjb2RlPTB4ZmY7CisgICAgICAgICAgICAgICAgLyoKKyAgICAgICAgICAgICAgICAqICAgICAgIGFkZCB0aGlzIG9uZSB0byB0aGUgZnJlZSBxdWV1ZSBmb3IgbGF0ZXIgcmV1c2UKKyAgICAgICAgICAgICAgICAqLworICAgICAgICAgICAgICAgIGlmIChwX2ZpcnN0X2Njdz09TlVMTCkgeworICAgICAgICAgICAgICAgICAgICAgICAgcF9maXJzdF9jY3cgPSBwX3RoaXNfY2N3OworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBlbHNlIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIHBfbGFzdF9jY3ctPm5leHQgPSBwX3RoaXNfY2N3OworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBwX2xhc3RfY2N3ID0gcF90aGlzX2NjdzsKKyAgICAgICAgICAgICAgICAvKgorICAgICAgICAgICAgICAgICogICAgICAgY2hhaW4gdG8gbmV4dCBibG9jayBvbiBhY3RpdmUgcmVhZCBxdWV1ZQorICAgICAgICAgICAgICAgICovCisgICAgICAgICAgICAgICAgcF90aGlzX2NjdyA9IHByaXZwdHItPnBfcmVhZF9hY3RpdmVfZmlyc3Q7CisJCUNMQVdfREJGX1RFWFRfKDQsdHJhY2UsInJ4cGt0ICVkIixwKTsKKyAgICAgICAgfSAvKiBlbmQgb2Ygd2hpbGUgKi8KKworICAgICAgICAvKiAgICAgIGNoZWNrIHZhbGlkaXR5ICAgICAgICAgICAgICAgICAgKi8KKworI2lmZGVmIElPVFJBQ0UKKyAgICAgICAgcHJpbnRrKEtFUk5fSU5GTyAiJXM6JXMgcHJvY2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Gl2ZV9maXJzdDsKKyAgICAgICAgICAgICAgICBwYXJtID0gKHVuc2lnbmVkIGxvbmcpIHBfY2g7CisgICAgICAgICAgICAgICAgcmMgPSBjY3dfZGV2aWNlX3N0YXJ0IChwX2NoLT5jZGV2LCAmcF9jY3diay0+cmVhZCwgcGFybSwKKwkJCQkgICAgICAgMHhmZiwgMCk7CisgICAgICAgICAgICAgICAgaWYgKHJjICE9IDApIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIGNjd19jaGVja19yZXR1cm5fY29kZShwX2NoLT5jZGV2LCByYyk7CisgICAgICAgICAgICAgICAgfQorICAgICAgICB9CisJZWxzZSB7CisjaWZkZWYgREVCVUdNU0cKKwkJcHJpbnRrKEtFUk5fSU5GTyAiJXM6IE5vIFJFQUQgc3RhcnRlZCBieSAlcygpIEluIHByb2dyZXNzXG4iICwKKwkJCWRldi0+bmFtZSxfX0ZVTkNUSU9OX18pOworI2VuZGlmCisJCUNMQVdfREJGX1RFWFQoMix0cmFjZSwiUmVhZEFjdCIpOworCX0KKworICAgICAgICBpZiAobG9jaz09TE9DS19ZRVMpIHsKKyAgICAgICAgICAgICAgICBzcGluX3VubG9ja19pcnFyZXN0b3JlKGdldF9jY3dkZXZfbG9jayhwX2NoLT5jZGV2KSwgc2F2ZWZsYWdzKTsKKyAgICAgICAgfQorI2lmZGVmIEZVTkNUUkFDRQorICAgICAgICBwcmludGsoS0VSTl9JTkZPICIlczolcyBFeGl0IG9uIGxpbmUgJWRcbiIsCisJCWRldi0+bmFtZSxfX0ZVTkNUSU9OX18sX19MSU5FX18pOworI2VuZGlmCisJQ0xBV19EQkZfVEVYVCg0LHRyYWNlLCJTdFJkRXhpdCIpOworICAgICAgICByZXR1cm47Cit9ICAgICAgIC8qICAgIGVuZCBvZiBjbGF3X3N0cnRfcmVhZCAgICAqLworCisvKi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0qCisqICAgICAgIGNsYXdfc3RydF9vdXRfSU8gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqCisqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqCisqLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0qLworCitzdGF0aWMgdm9pZAorY2xhd19zdHJ0X291dF9JTyggc3RydWN0IG5ldF9kZXZpY2UgKmRldiApCit7CisgICAgICAgIGludCAgICAgICAgICAgICAJcmMgPSAwOworICAgICAgICB1bnNpZ25lZCBsb25nICAgCXBhcm07CisgICAgICAgIHN0cnVjdCBjbGF3X3ByaXZiayAJKnByaXZwdHI7CisgICAgICAgIHN0cnVjdCBjaGJrICAgICAJKnBfY2g7CisgICAgICAgIHN0cnVjdCBjY3diayAgIAkqcF9maXJzdF9jY3c7CisKKyNpZmRlZiBGVU5DVFJBQ0UKKyAgICAgICAgcHJpbnRrKEtFUk5fSU5GTyAiJXM6JXMgRW50ZXJcbiIsZGV2LT5uYW1lLF9fRlVOQ1RJT05fXyk7CisjZW5kaWYKKwlpZiAoIWRldikgeworCQlyZXR1cm47CisJfQorICAgICAgICBwcml2cHRyPShzdHJ1Y3QgY2xhd19wcml2YmsgKilkZXYtPnByaXY7CisgICAgICAgIHBfY2g9JnByaXZwdHItPmNoYW5uZWxbV1JJVEVdOworCisjaWZkZWYgREVCVUdNU0cKKyAgICAgICAgcHJpbnRrKEtFUk5fSU5GTyAiJXM6JXMgc3RhdGUtJTAyeFxuIiAsCisJCWRldi0+bmFtZSxfX0ZVTkNUSU9OX18scF9jaC0+Y2xhd19zdGF0ZSk7CisjZW5kaWYKKyAgICAgICAgQ0xBV19EQkZfVEVYVCg0LHRyYWNlLCJzdHJ0X2lvIik7CisgICAgICAgIHBfZmlyc3RfY2N3PXByaXZwdHItPnBfd3JpdGVfYWN0aXZlX2ZpcnN0OworCisgICAgICAgIGlmIChwX2NoLT5jbGF3X3N0YXRlID09IENMQVdfU1RPUCkKKyAgICAgICAgICAgICAgICByZXR1cm47CisgICAgICAgIGlmIChwX2ZpcnN0X2NjdyA9PSBOVUxMKSB7CisjaWZkZWYgRlVOQ1RSQUNFCisgICAgICAgICAgICAgICAgcHJpbnRrKEtFUk5fSU5GTyAiJXM6JXMgRXhpdCBvbiBsaW5lICVkXG4iLAorCQkJZGV2LT5uYW1lLF9fRlVOQ1RJT05fXyxfX0xJTkVfXyk7CisjZW5kaWYKKyAgICAgICAgICAgICAgICByZXR1cm47CisgICAgICAgIH0KKyAgICAgICAgaWYgKHRlc3RfYW5kX3NldF9iaXQoMCwgKHZvaWQgKikmcF9jaC0+SU9fYWN0aXZlKSA9PSAwKSB7CisgICAgICAgICAgICAgICAgcGFybSA9ICh1bnNpZ25lZCBsb25nKSBwX2NoOworI2lmZGVmIERFQlVHTVNHCisgICAgICAgICAgICAgICAgcHJpbnRrKEtFUk5fSU5GTyAiJXM6JXMgZG9faW8gXG4iICxkZXYtPm5hbWUsX19GVU5DVElPTl9fKTsKKyAgICAgICAgICAgICAgICBkdW1waXQoKGNoYXIgKilwX2ZpcnN0X2Njdywgc2l6ZW9mKHN0cnVjdCBjY3diaykpOworI2VuZGlmCisJCUNMQVdfREJGX1RFWFQoMix0cmFjZSwiU3RXcnRJTyIpOworICAgICAgICAgICAgICAgIHJjID0gY2N3X2RldmljZV9zdGFydCAocF9jaC0+Y2RldiwmcF9maXJzdF9jY3ctPndyaXRlLCBwYXJtLAorCQkJCSAgICAgICAweGZmLCAwKTsKKyAgICAgICAgICAgICAgICBpZiAocmMgIT0gMCkgeworICAgICAgICAgICAgICAgICAgICAgICAgY2N3X2NoZWNrX3JldHVybl9jb2RlKHBfY2gtPmNkZXYsIHJjKTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgIH0KKyAgICAgICAgZGV2LT50cmFuc19zdGFydCA9IGppZmZpZXM7CisjaWZkZWYgRlVOQ1RSQUNFCisJcHJpbnRrKEtFUk5fSU5GTyAiJXM6JXMgRXhpdCBvbiBsaW5lICVkXG4iLAorCQlkZXYtPm5hbWUsX19GVU5DVElPTl9fLF9fTElORV9fKTsKKyNlbmRpZgorCisgICAgICAgIHJldHVybjsKK30gICAgICAgLyogICAgZW5kIG9mIGNsYXdfc3RydF9vdXRfSU8gICAgKi8KKworLyotLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKgorKiAgICAgICBGcmVlIHdyaXRlIGJ1ZmZlcnMgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKgorKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKgorKi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKi8KKworc3RhdGljIHZvaWQKK2NsYXdfZnJlZV93cnRfYnVmKCBzdHJ1Y3QgbmV0X2RldmljZSAqZGV2ICkKK3sKKworICAgICAgICBzdHJ1Y3QgY2xhd19wcml2YmsgKnByaXZwdHI9KHN0cnVjdCBjbGF3X3ByaXZiayAqKWRldi0+cHJpdjsKKyAgICAgICAgc3RydWN0IGNjd2JrKnBfZmlyc3RfY2N3OworCXN0cnVjdCBjY3diaypwX2xhc3RfY2N3OworCXN0cnVjdCBjY3diaypwX3RoaXNfY2N3OworCXN0cnVjdCBjY3diaypwX25leHRfY2N3OworI2lmZGVmIElPVFJBQ0UKKyAgICAgICAgc3RydWN0IGNjd2JrKnBfYnVmOworI2VuZGlmCisjaWZkZWYgRlVOQ1RSQUNFCisgICAgICAgIHByaW50ayhLRVJOX0lORk8gIiVzOiVzIEVudGVyXG4iLGRldi0+bmFtZSxfX0ZVTkNUSU9OX18pOworICAgICAgICBwcmludGsoS0VSTl9JTkZPICIlczogZnJlZSBjb3VudCA9ICVkICB2YXJpYWJsZSBkZXYgPVxuIiwKKwkJZGV2LT5uYW1lLHByaXZwdHItPndyaXRlX2ZyZWVfY291bnQpOworI2VuZGlmCisJQ0xBV19EQkZfVEVYVCg0LHRyYWNlLCJmcmVld3J0YiIpOworICAgICAgICAvKiAgc2NhbiB0aGUgd3JpdGUgcXVldWUgdG8gZnJlZSBhbnkgY29tcGxldGVkIHdyaXRlIHBhY2tldHMgICAqLworICAgICAgICBwX2ZpcnN0X2Njdz1OVUxMOworICAgICAgICBwX2xhc3RfY2N3PU5VTEw7CisjaWZkZWYgSU9UUkFDRQorICAgICAgICBwcmludGsoS0VSTl9JTkZPICIlczogIER1bXAgY3VycmVudCBDQ1cgY2hhaW4gXG4iLGRldi0+bmFtZSAgKTsKKyAgICAgICAgcF9idWY9cHJpdnB0ci0+cF93cml0ZV9hY3RpdmVfZmlyc3Q7CisgICAgICAgIHdoaWxlIChwX2J1ZiE9TlVMTCkgeworICAgICAgICAgICAgICAgIGR1bXBpdCgoY2hhciAqKXBfYnVmLCBzaXplb2Yoc3RydWN0IGNjd2JrKSk7CisgICAgICAgICAgICAgICAgcF9idWY9cF9idWYtPm5leHQ7CisgICAgICAgIH0KKyAgICAgICAgaWYgKHBfYnVmPT1OVUxMKSB7CisgICAgICAgICAgICAgICAgcHJpbnRrKEtFUk5fSU5GTyAiJXM6IHByaXZwdHItPnBfd3JpdGVfIgorCQkJImFjdGl2ZV9maXJzdD09TlVMTFxuIixkZXYtPm5hbWUgICk7CisgICAgICAgIH0KKyAgICAgICAgcF9idWY9KHN0cnVjdCBjY3diayopcHJpdnB0ci0+cF9lbmRfY2N3OworICAgICAgICBkdW1waXQoKGNoYXIgKilwX2J1Ziwgc2l6ZW9mKHN0cnVjdCBlbmRjY3cpKTsKKyNlbmRpZgorICAgICAgICBwX3RoaXNfY2N3PXByaXZwdHItPnBfd3JpdGVfYWN0aXZlX2ZpcnN0OworICAgICAgICB3aGlsZSAoIChwX3RoaXNfY2N3IT1OVUxMKSAmJiAocF90aGlzX2Njdy0+aGVhZGVyLmZsYWchPUNMQVdfUEVORElORykpCisgICAgICAgIHsKKyAgICAgICAgICAgICAgICBwX25leHRfY2N3ID0gcF90aGlzX2Njdy0+bmV4dDsKKyAgICAgICAgICAgICAgICBpZiAoKChwX25leHRfY2N3IT1OVUxMKSAmJgorCQkgICAgIChwX25leHRfY2N3LT5oZWFkZXIuZmxhZyE9Q0xBV19QRU5ESU5HKSkgfHwKKyAgICAgICAgICAgICAgICAgICAgKChwX3RoaXNfY2N3ID09IHByaXZwdHItPnBfd3JpdGVfYWN0aXZlX2xhc3QpICYmCisgICAgICAgICAgICAgICAgICAgICAocF90aGlzX2Njdy0+aGVhZGVyLmZsYWchPUNMQVdfUEVORElORykpKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAvKiBUaGUgbmV4dCBDQ1cgaXMgT0sgb3IgdGhpcyBpcyAgKi8KKwkJCS8qIHRoZSBsYXN0IENDVy4uLmZyZWUgaXQgICBAQTFBICAqLworICAgICAgICAgICAgICAgICAgICAgICAgcHJpdnB0ci0+cF93cml0ZV9hY3RpdmVfZmlyc3Q9cF90aGlzX2Njdy0+bmV4dDsKKwkJCXBfdGhpc19jY3ctPmhlYWRlci5mbGFnPUNMQVdfUEVORElORzsKKyAgICAgICAgICAgICAgICAgICAgICAgIHBfdGhpc19jY3ctPm5leHQ9cHJpdnB0ci0+cF93cml0ZV9mcmVlX2NoYWluOworCQkJcHJpdnB0ci0+cF93cml0ZV9mcmVlX2NoYWluPXBfdGhpc19jY3c7CisgICAgICAgICAgICAgICAgICAgICAgICArK3ByaXZwdHItPndyaXRlX2ZyZWVfY291bnQ7CisJCQlwcml2cHRyLT5zdGF0cy50eF9ieXRlcys9IHBfdGhpc19jY3ctPndyaXRlLmNvdW50OworCQkJcF90aGlzX2Njdz1wcml2cHRyLT5wX3dyaXRlX2FjdGl2ZV9maXJzdDsKKyAgICAgICAgICAgICAgICAgICAgICAgIHByaXZwdHItPnN0YXRzLnR4X3BhY2tldHMrKzsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgZWxzZSB7CisJCQlicmVhazsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgIH0KKyAgICAgICAgaWYgKHByaXZwdHItPndyaXRlX2ZyZWVfY291bnQhPTApIHsKKyAgICAgICAgICAgICAgICBjbGF3X2NsZWFyYml0X2J1c3koVEJfTk9CVUZGRVIsZGV2KTsKKyAgICAgICAgfQorICAgICAgICAvKiAgIHdob2xlIGNoYWluIHJlbW92ZWQ/ICAgKi8KKyAgICAgICAgaWYgKHByaXZwdHItPnBfd3JpdGVfYWN0aXZlX2ZpcnN0PT1OVUxMKSB7CisgICAgICAgICAgICAgICAgcHJpdnB0ci0+cF93cml0ZV9hY3RpdmVfbGFzdD1OVUxMOworI2lmZGVmIERFQlVHTVNHCisgICAgICAgICAgICAgICAgcHJpbnRrKEtFUk5fSU5GTyAiJXM6JXMgcF93cml0ZV8iCisJCQkiYWN0aXZlX2ZpcnN0PT1OVUxMXG4iLGRldi0+bmFtZSxfX0ZVTkNUSU9OX18pOworI2VuZGlmCisgICAgICAgIH0KKyNpZmRlZiBJT1RSQUNFCisgICAgICAgIHByaW50ayhLRVJOX0lORk8gIiVzOiBEdW1wIGFycmFuZ2VkIENDVyBjaGFpbiBcbiIsZGV2LT5uYW1lICApOworICAgICAgICBwX2J1Zj1wcml2cHRyLT5wX3dyaXRlX2FjdGl2ZV9maXJzdDsKKyAgICAgICAgd2hpbGUgKHBfYnVmIT1OVUxMKSB7CisgICAgICAgICAgICAgICAgZHVtcGl0KChjaGFyICopcF9idWYsIHNpemVvZihzdHJ1Y3QgY2N3YmspKTsKKyAgICAgICAgICAgICAgICBwX2J1Zj1wX2J1Zi0+bmV4dDsKKyAgICAgICAgfQorICAgICAgICBpZiAocF9idWY9PU5VTEwpIHsKKyAgICAgICAgICAgICAgICBwcmludGsoS0VSTl9JTkZPICIlczogcHJpdnB0ci0+cF93cml0ZV9hY3RpdmVfIgorCQkJImZpcnN0PT1OVUxMXG4iLGRldi0+bmFtZSAgKTsKKyAgICAgICAgfQorICAgICAgICBwX2J1Zj0oc3RydWN0IGNjd2JrKilwcml2cHRyLT5wX2VuZF9jY3c7CisgICAgICAgIGR1bXBpdCgoY2hhciAqKXBfYnVmLCBzaXplb2Yoc3RydWN0IGVuZGNjdykpOworI2VuZGlmCisKKwlDTEFXX0RCRl9URVhUXyg0LHRyYWNlLCJGV0M9JWQiLHByaXZwdHItPndyaXRlX2ZyZWVfY291bnQpOworI2lmZGVmIEZVTkNUUkFDRQorICAgICAgICBwcmludGsoS0VSTl9JTkZPICIlczolcyBFeGl0IG9uIGxpbmUgJWQgZnJlZV9jb3VudCA9JWRcbiIsCisJCWRldi0+bmFtZSxfX0ZVTkNUSU9OX18sIF9fTElORV9fLHByaXZwdHItPndyaXRlX2ZyZWVfY291bnQpOworI2VuZGlmCisgICAgICAgIHJldHVybjsKK30KKworLyotLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKgorKiAgICAgICBjbGF3IGZyZWUgbmV0ZGV2aWNlICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKgorKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKgorKi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKi8KK3N0YXRpYyB2b2lkCitjbGF3X2ZyZWVfbmV0ZGV2aWNlKHN0cnVjdCBuZXRfZGV2aWNlICogZGV2LCBpbnQgZnJlZV9kZXYpCit7CisJc3RydWN0IGNsYX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nVmZl9oZWFkICpxKQoreworICAgICAgICBzdHJ1Y3Qgc2tfYnVmZiAqc2tiOworCisgICAgICAgIENMQVdfREJGX1RFWFQoNCx0cmFjZSwicHVyZ3F1ZSIpOworCisgICAgICAgIHdoaWxlICgoc2tiID0gc2tiX2RlcXVldWUocSkpKSB7CisgICAgICAgICAgICAgICAgYXRvbWljX2RlYygmc2tiLT51c2Vycyk7CisgICAgICAgICAgICAgICAgZGV2X2tmcmVlX3NrYl9pcnEoc2tiKTsKKyAgICAgICAgfQorfQorCisvKioKKyAqIFNodXRkb3duIGFuIGludGVyZmFjZS4KKyAqCisgKiBAcGFyYW0gY2dkZXYgIERldmljZSB0byBiZSBzaHV0IGRvd24uCisgKgorICogQHJldHVybnMgMCBvbiBzdWNjZXNzLCAhMCBvbiBmYWlsdXJlLgorICovCitzdGF0aWMgaW50CitjbGF3X3NodXRkb3duX2RldmljZShzdHJ1Y3QgY2N3Z3JvdXBfZGV2aWNlICpjZ2RldikKK3sKKwlzdHJ1Y3QgY2xhd19wcml2YmsgKnByaXY7CisJc3RydWN0IG5ldF9kZXZpY2UgKm5kZXY7CisJaW50CXJldDsKKworCXByX2RlYnVnKCIlcygpIGNhbGxlZFxuIiwgX19GVU5DVElPTl9fKTsKKwlDTEFXX0RCRl9URVhUXygyLHNldHVwLCIlcyIsY2dkZXYtPmRldi5idXNfaWQpOworCXByaXYgPSBjZ2Rldi0+ZGV2LmRyaXZlcl9kYXRhOworCWlmICghcHJpdikKKwkJcmV0dXJuIC1FTk9ERVY7CisJbmRldiA9IHByaXYtPmNoYW5uZWxbUkVBRF0ubmRldjsKKwlpZiAobmRldikgeworCQkvKiBDbG9zZSB0aGUgZGV2aWNlICovCisJCXByaW50ayhLRVJOX0lORk8KKwkJCSIlczogc2h1dGluZyBkb3duIFxuIixuZGV2LT5uYW1lKTsKKwkJaWYgKG5kZXYtPmZsYWdzICYgSUZGX1JVTk5JTkcpCisJCQlyZXQgPSBjbGF3X3JlbGVhc2UobmRldik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JlZ2lzdGVyIGZhaWxlZCAlZFxuIiwKKwkJCV9fRlVOQ1RJT05fXyxyZXQpOworCX0KKyNpZmRlZiBGVU5DVFJBQ0UKKyAgICAgICAgcHJpbnRrKEtFUk5fSU5GTyAiY2xhdzogJXMoKSBleGl0IFxuIixfX0ZVTkNUSU9OX18pOworI2VuZGlmCisJcmV0dXJuIHJldDsKK30KKworbW9kdWxlX2luaXQoY2xhd19pbml0KTsKK21vZHVsZV9leGl0KGNsYXdfY2xlYW51cCk7CisKKworCisvKi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKgorKiAgICBFbmQgb2YgRmlsZSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICoKKyotLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0qLworCisKZGlmZiAtLWdpdCBhL2RyaXZlcnMvczM5MC9uZXQvY2xhdy5oIGIvZHJpdmVycy9zMzkwL25ldC9jbGF3LmgKbmV3IGZpbGUgbW9kZSAxMDA2NDQKaW5kZXggMDAwMDAwMC4uM2RmNzE5NwotLS0gL2Rldi9udWxsCisrKyBiL2RyaXZlcnMvczM5MC9uZXQvY2xhdy5oCkBAIC0wLDAgKzEsMzM1IEBACisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorKiAgRGVmaW5lIGNvbnN0YW50cyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICoKKyogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqCisqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKyNkZWZpbmUgVkVSU0lPTl9DTEFX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VmaW5lIENMQVdfUkNfTkFNRV9NSVNNQVRDSCAgICAgICAxNjYgIC8qICBuYW1lcyBkbyBub3QgbWF0Y2ggKi8KKyNkZWZpbmUgQ0xBV19SQ19XUk9OR19WRVJTSU9OICAgICAgIDE2NyAgLyogIHdyb25nIENMQVcgdmVyc2lvbiBudW1iZXIgKi8KKyNkZWZpbmUgQ0xBV19SQ19IT1NUX1JDVl9UT09fU01BTEwgIDE4MCAgLyogIEhvc3QgbWF4aW11bSByZWNlaXZlIGlzICAgKi8KKwkJCQkJIC8qICBsZXNzIHRoYW4gTGludXggb24gelNlcmllcyovCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8qICB0cmFuc21pdCBzaXplICAgICAgICAgICAgICovCisKKy8qLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0qCisqICAgICAgQ0xBVyBDb25zdGFudHMgYXBwbGljYXRpb24gbmFtZSAgICAgICAgICAgICAgICAgKgorKi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSovCisKKyNkZWZpbmUgSE9TVF9BUFBMX05BTUUgICAgICAgICAgIlRDUElQICAgIgorI2RlZmluZSBXU19BUFBMX05BTUVfSVBfTElOSyAgICAiVENQSVAgICAiCisjZGVmaW5lIFdTX0FQUExfTkFNRV9JUF9OQU1FCSJJUCAgICAgICIKKyNkZWZpbmUgV1NfQVBQTF9OQU1FX0FQSV9MSU5LICAgIkFQSSAgICAgIgorI2RlZmluZSBXU19BUFBMX05BTUVfUEFDS0VEICAgICAiUEFDS0VEICAiCisjZGVmaW5lIFdTX05BTUVfTk9UX0RFRiAgICAgICAgICJOT1RfREVGICIKKyNkZWZpbmUgUEFDS0lOR19BU0sJCTEKKyNkZWZpbmUgUEFDS19TRU5ECQkyCisjZGVmaW5lIERPX1BBQ0tFRAkJMworCisjZGVmaW5lIE1BWF9FTlZFTE9QRV9TSVpFICAgICAgIDY1NTM2CisjZGVmaW5lIENMQVdfREVGQVVMVF9NVFVfU0laRSAgIDQwOTYKKyNkZWZpbmUgREVGX1BBQ0tfQlVGU0laRQkzMjc2OAorI2RlZmluZSBSRUFEICAgICAgICAgICAgICAgICAgICAwCisjZGVmaW5lIFdSSVRFICAgICAgICAgICAgICAgICAgIDEKKworI2RlZmluZSBUQl9UWCAgICAgICAgICAgICAgICAgICAwICAgICAgICAgIC8qIHNrIGJ1ZmZlciBoYW5kbGluZyBpbiBwcm9jZXNzICAqLworI2RlZmluZSBUQl9TVE9QICAgICAgICAgICAgICAgICAxICAgICAgICAgIC8qIG5ldHdvcmsgZGV2aWNlIHN0b3AgaW4gcHJvY2VzcyAqLworI2RlZmluZSBUQl9SRVRSWSAgICAgICAgICAgICAgICAyICAgICAgICAgIC8qIHJldHJ5IGluIHByb2Nlc3MgICAgICAgICAgICAgICAqLworI2RlZmluZSBUQl9OT0JVRkZFUiAgICAgICAgICAgICAzICAgICAgICAgIC8qIG5vIGJ1ZmZlciBvbiBmcmVlIHF1ZXVlICAgICAgICAqLworI2RlZmluZSBDTEFXX01BWF9MSU5LX0lEICAgICAgICAxCisjZGVmaW5lIENMQVdfTUFYX0RFViAgICAgICAgICAgIDI1NiAgICAgICAgLyogICAgICBtYXggY2xhdyBkZXZpY2VzICAgICAgICAgICovCisjZGVmaW5lIE1BWF9OQU1FX0xFTiAgICAgICAgICAgIDggICAgICAgICAgLyogaG9zdCBuYW1lLCBhZGFwdGVyIG5hbWUgbGVuZ3RoICovCisjZGVmaW5lIENMQVdfRlJBTUVfU0laRSAgICAgICAgIDQwOTYKKyNkZWZpbmUgQ0xBV19JRF9TSVpFICAgICAgICAgICAgQlVTX0lEX1NJWkUrMworCisvKiBzdGF0ZSBtYWNoaW5lIGNvZGVzIHVzZWQgaW4gY2xhd19pcnFfaGFuZGxlciAqLworCisjZGVmaW5lIENMQVdfU1RPUCAgICAgICAgICA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RFWFRfKGxldmVsLG5hbWUsdGV4dC4uLikgXAorZG8geyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKKwlzcHJpbnRmKGRlYnVnX2J1ZmZlciwgdGV4dCk7ICBcCisJCWRlYnVnX3RleHRfZXZlbnQoY2xhd19kYmZfIyNuYW1lLGxldmVsLCBkZWJ1Z19idWZmZXIpO1wKK30gd2hpbGUgKDApCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisqICBEZWZpbmUgQ29udHJvbCBCbG9ja3MgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKgorKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICoKKyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworCisvKi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSovCisvKiAgICAgQ0xBVyBoZWFkZXIgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICovCisvKi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSovCisKK3N0cnVjdCBjbGF3aCB7CisgICAgICAgIF9fdTE2ICBsZW5ndGg7ICAgICAvKiBsZW5ndGggb2YgZGF0YSByZWFkIGJ5IHByZWNlZGluZyByZWFkIENDVyAqLworICAgICAgICBfX3U4ICAgb3Bjb2RlOyAgICAgLyogZXF1aXZhbGVudCByZWFkIENDVyAqLworICAgICAgICBfX3U4ICAgZmxhZzsgICAgICAgLyogZmxhZyBvZiBGRiB0byBpbmRpY2F0ZSByZWFkIHdhcyBjb21wbGV0ZWQgKi8KK307CisKKy8qLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKi8KKy8qICAgICBDTEFXIFBhY2tpbmcgaGVhZGVyICAgNCBieXRlcyAgICAgICAgICAgICAgICAgICAgKi8KKy8qLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKi8KK3N0cnVjdCBjbGF3cGggeworICAgICAgIF9fdTE2IGxlbjsgIAkvKiBMZW5ndGggb2YgUGFja2VkIERhdGEgQXJlYSAgICovCisgICAgICAgX191OCAgZmxhZzsgIAkvKiBSZXNlcnZlZCBub3QgdXNlZCAgICAgICAgICAgICovCisgICAgICAgX191OCAgbGlua19udW07CS8qIExpbmsgSUQgICAgICAgICAgICAgICAgICAgICAgKi8KK307CisKKy8qLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKi8KKy8qICAgICBDTEFXIEVuZGluZyBzdHJ1Y3QgY2N3YmsgICAgICAgICAgICAgICAgICAgICAgICAgKi8KKy8qLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKi8KK3N0cnVjdCBlbmRjY3cgeworCV9fdTMyICAgICByZWFsOyAgICAgICAgICAgIC8qIHJlYWwgYWRkcmVzcyBvZiB0aGlzIGJsb2NrICovCisgICAgICAgX191OCAgICAgIHdyaXRlMTsgICAgICAgICAgLyogd3JpdGUgMSBpcyBhY3RpdmUgKi8KKyAgICAgICAgX191OCAgICAgIHJlYWQxOyAgICAgICAgICAgLyogcmVhZCAxIGlzIGFjdGl2ZSAgKi8KKyAgICAgICAgX191MTYgICAgIHJlc2VydmVkOyAgICAgICAgLyogcmVzZXJ2ZWQgZm9yIGZ1dHVyZSB1c2UgKi8KKyAgICAgICAgc3RydWN0IGNjdzEgICAgd3JpdGUxX25vcDE7CisgICAgICAgIHN0cnVjdCBjY3cxICAgIHdyaXRlMV9ub3AyOworICAgICAgICBzdHJ1Y3QgY2N3MSAgICB3cml0ZTJfbm9wMTsKKyAgICAgICAgc3RydWN0IGNjdzEgICAgd3JpdGUyX25vcDI7CisgICAgICAgIHN0cnVjdCBjY3cxICAgIHJlYWQxX25vcDE7CisgICAgICAgIHN0cnVjdCBjY3cxICAgIHJlYWQxX25vcDI7CisgICAgICAgIHN0cnVjdCBjY3cxICAgIHJlYWQyX25vcDE7CisgICAgICAgIHN0cnVjdCBjY3cxICAgIHJlYWQyX25vcDI7Cit9OworCisvKi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSovCisvKiAgICAgQ0xBVyBzdHJ1Y3QgY2N3YmsgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqLworLyotLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0qLworc3RydWN0IGNjd2JrIHsKKyAgICAgICAgdm9pZCAgICpuZXh0OyAgICAgICAgLyogcG9pbnRlciB0byBuZXh0IGNjdyBibG9jayAqLworICAgICAgICBfX3UzMiAgICAgcmVhbDsgICAgICAgICAvKiByZWFsIGFkZHJlc3Mgb2YgdGhpcyBjY3cgKi8KKyAgICAgICAgdm9pZCAgICAgICpwX2J1ZmZlcjsgICAgLyogdmlydHVhbCBhZGRyZXNzIG9mIGRhdGEgKi8KKyAgICAgICAgc3RydWN0IGNsYXdoICAgICBoZWFkZXI7ICAgICAgIC8qIGNsYXcgaGVhZGVyICovCisgICAgICAgIHN0cnVjdCBjY3cxICAgIHdyaXRlOyAgIC8qIHdyaXRlIENDVyAgICAqLworICAgICAgICBzdHJ1Y3QgY2N3MSAgICB3X3JlYWRfRkY7IC8qIHJlYWQgRkYgKi8KKyAgICAgICAgc3RydWN0IGNjdzEgICAgd19USUNfMTsgICAgICAgIC8qIFRJQyAqLworICAgICAgICBzdHJ1Y3QgY2N3MSAgICByZWFkOyAgICAgICAgIC8qIHJlYWQgQ0NXICAqLworICAgICAgICBzdHJ1Y3QgY2N3MSAgICByZWFkX2g7ICAgICAgICAvKiByZWFkIGhlYWRlciAqLworICAgICAgICBzdHJ1Y3QgY2N3MSAgICBzaWduYWw7ICAgICAgIC8qIHNpZ25hbCBTTU9EICAqLworICAgICAgICBzdHJ1Y3QgY2N3MSAgICByX1RJQ18xOyAgICAgICAgLyogVElDMSAqLworICAgICAgICBzdHJ1Y3QgY2N3MSAgICByX3JlYWRfRkY7ICAgICAgLyogcmVhZCBGRiAgKi8KKyAgICAgICAgc3RydWN0IGNjdzEgICAgcl9USUNfMjsgICAgICAgIC8qIFRJQzIgKi8KK307CisKKy8qLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKi8KKy8qICAgICBDTEFXIGNvbnRyb2wgYmxvY2sgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKi8KKy8qLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKi8KK3N0cnVjdCBjbGF3Y3RsIHsKKyAgICAgICAgX191OCAgICBjb21tYW5kOyAgICAgIC8qIGNvbnRyb2wgY29tbWFuZCAqLworICAgICAgICBfX3U4ICAgIHZlcnNpb247ICAgICAgLyogQ0xBVyBwcm90b2NvbCB2ZXJzaW9uICovCisgICAgICAgIF9fdTggICAgbGlua2lkOyAgICAgICAvKiBsaW5rIElEICAgKi8KKyAgICAgICAgX191OCAgICBjb3JyZWxhdG9yOyAgIC8qIGNvcnJlbGF0b3IgKi8KKyAgICAgICAgX191OCAgICByYzsgICAgICAgICAgIC8qIHJldHVybiBjb2RlICovCisgICAgICAgIF9fdTggICAgcmVzZXJ2ZWQxOyAgICAvKiByZXNlcnZlZCAqLworICAgICAgICBfX3U4ICAgIHJlc2VydmVkMjsgICAgLyogcmVzZXJ2ZWQgKi8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ICAgLyogZGF0YSBidWZmZXIgKi8KK307CisKKy8qLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKi8KKy8qICAgICBDaGFubmVsIGNvbnRyb2wgYmxvY2sgZm9yIHJlYWQgYW5kIHdyaXRlIGNoYW5uZWwgKi8KKy8qLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKi8KKworc3RydWN0IGNoYmsgeworICAgICAgICB1bnNpZ25lZCBpbnQgICAgICAgIGRldm5vOworICAgICAgICBpbnQgICAgICAgICAgICAgICAgIGlycTsKKwljaGFyIAkJICAgIGlkW0NMQVdfSURfU0laRV07CisgICAgICAgX191MzIgICAgICAgICAgICAgICBJT19hY3RpdmU7CisgICAgICAgIF9fdTggICAgICAgICAgICAgICAgY2xhd19zdGF0ZTsKKyAgICAgICAgc3RydWN0IGlyYiAgICAgICAgICAqaXJiOworICAgICAgIAlzdHJ1Y3QgY2N3X2RldmljZSAgICpjZGV2OyAgLyogcG9pbnRlciB0byB0aGUgY2hhbm5lbCBkZXZpY2UgKi8KKwlzdHJ1Y3QgbmV0X2RldmljZSAgICpuZGV2OworICAgICAgICB3YWl0X3F1ZXVlX2hlYWRfdCAgIHdhaXQ7CisgICAgICAgIHN0cnVjdCB0YXNrbGV0X3N0cnVjdCAgICB0YXNrbGV0OworICAgICAgICBzdHJ1Y3QgdGltZXJfbGlzdCAgIHRpbWVyOworICAgICAgICB1bnNpZ25lZCBsb25nICAgICAgIGZsYWdfYTsgICAgLyogYXRvbWljIGZsYWdzICovCisjZGVmaW5lIENMQVdfQkhfQUNUSVZFICAgICAgMAorICAgICAgICB1bnNpZ25lZCBsb25nICAgICAgIGZsYWdfYjsgICAgLyogYXRvbWljIGZsYWdzICovCisjZGVmaW5lIENMQVdfV1JJVEVfQUNUSVZFICAgMAorICAgICAgICBfX3U4ICAgICAgICAgICAgICAgIGxhc3RfZHN0YXQ7CisgICAgICAgIF9fdTggICAgICAgICAgICAgICAgZmxhZzsKKwlzdHJ1Y3Qgc2tfYnVmZl9oZWFkIGNvbGxlY3RfcXVldWU7CisJc3BpbmxvY2tfdCBjb2xsZWN0X2xvY2s7CisjZGVmaW5lIENMQVdfV1JJVEUgICAgICAweDAyICAgICAgLyogLSBTZXQgaWYgdGhpcyBpcyBhIHdyaXRlIGNoYW5uZWwgKi8KKyNkZWZpbmUgQ0xBV19SRUFECTB4MDEgICAgICAvKiAtIFNldCBpZiB0aGlzIGlzIGEgcmVhZCBjaGFubmVsICAqLworI2RlZmluZSBDTEFXX1RJTUVSICAgICAgMHg4MCAgICAgIC8qIC0gU2V0IGlmIHRpbWVyIG1hZGUgdGhlIHdha2VfdXAgICovCit9OworCisvKi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKgorKiAgICAgICAgICAgQ0xBVyAgZW52aXJvbm1lbnQgYmxvY2sgICAgICAgICAgICAgICAgICAgICAgICAgICAgICoKKyotLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0qLworCitzdHJ1Y3QgY2xhd19lbnYgeworICAgICAgICB1bnNpZ25lZCBpbnQgICAgICAgICAgICBkZXZub1syXTsgICAgICAgLyogZGV2aWNlIG51bWJlciAqLworICAgICAgICBjaGFyICAgICAgICAgICAgICAgICAgICBob3N0X25hbWVbOV07ICAgLyogSG9zdCBuYW1lICovCisgICAgICAgIGNoYXIgICAgICAgICAgICAgICAgICAgIGFkYXB0ZXJfbmFtZSBbOV07IC8qIGFkYXB0ZXIgbmFtZSAqLworICAgICAgICBjaGFyICAgICAgICAgICAgICAgICAgICBhcGlfdHlwZVs5XTsgICAgLyogVENQSVAsIEFQSSBvciBQQUNLRUQgKi8KKyAgICAgICAgdm9pZCAgICAgICAgICAgICAgICAgICAgKnBfcHJpdjsgICAgICAgIC8qIHByaXZwdHIgKi8KKyAgICAgICAgX191MTYgICAgICAgICAgICAgICAgICAgcmVhZF9idWZmZXJzOyAgIC8qIHJlYWQgYnVmZmVyIG51bWJlciAqLworICAgICAgICBfX3UxNiAgICAgICAgICAgICAgICAgICB3cml0ZV9idWZmZXJzOyAgLyogd3JpdGUgYnVmZmVyIG51bWJlciAqLworICAgICAgICBfX3UxNiAgICAgICAgICAgICAgICAgICByZWFkX3NpemU7ICAgICAgLyogcmVhZCBidWZmZXIgc2l6ZSAqLworICAgICAgICBfX3UxNiAgICAgICAgICAgICAgICAgICB3cml0ZV9zaXplOyAgICAgLyogd3JpdGUgYnVmZmVyIHNpemUgKi8KKyAgICAgICAgX191MTYgICAgICAgICAgICAgICAgICAgZGV2X2lkOyAgICAgICAgIC8qIGRldmljZSBpZGVudCAqLworCV9fdTgJCQlwYWNraW5nOwkvKiBhcmUgd2UgcGFja2luZz8gKi8KKwl2b2xhdGlsZSBfX3U4CQlxdWVtZV9zd2l0Y2g7ICAgLyogZ2F0ZSBmb3IgaW1lZCBwYWNraW5nICAqLworCXZvbGF0aWxlIHVuc2lnbmVkIGxvbmcJcGtfZGVsYXk7CS8qIERlbGF5IGZvciBhZGFwdGl2ZSBwYWNraW5nICovCisgICAgICAgIF9fdTggICAgICAgICAgICAgICAgICAgIGluX3VzZTsgICAgICAgICAvKiBkZXZpY2UgYWN0aXZlIGZsYWcgKi8KKyAgICAgICAgc3RydWN0IG5ldF9kZXZpY2UgICAgICAgKm5kZXY7ICAgIAkvKiBiYWNrd2FyZCBwdHIgdG8gdGhlIG5ldCBkZXYqLworfTsKKworLyotLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSoKKyogICAgICAgICAgIENMQVcgIG1haW4gY29udHJvbCBibG9jayAgICAgICAgICAgICAgICAgICAgICA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GUgbGFzdCByZWFkIGNjdyAqLworICAgICAgICBzdHJ1Y3QgZW5kY2N3ICpwX2VuZF9jY3c7ICAgICAgICAgICAgICAvKnB0ciB0byBlbmRpbmcgY2N3ICovCisgICAgICAgIHN0cnVjdCBjY3diayAqcF9jbGF3X3NpZ25hbF9ibGs7ICAgICAgLyogcHRyIHRvIHNpZ25hbCBibG9jayAqLworICAgICAgICBfX3UzMiAgICAgIHdyaXRlX2ZyZWVfY291bnQ7ICAgICAgIC8qIG51bWJlciBvZiBmcmVlIGJ1ZnMgZm9yIHdyaXRlICovCisJc3RydWN0ICAgICBuZXRfZGV2aWNlX3N0YXRzICBzdGF0czsgLyogCSBkZXZpY2Ugc3RhdHVzICAgICovCisgICAgICAgIHN0cnVjdCBjaGJrIGNoYW5uZWxbMl07ICAgICAgICAgICAgLyogQ2hhbm5lbCBjb250cm9sIGJsb2NrcyAqLworICAgICAgICBfX3U4ICAgICAgIG10Y19za2lwcGluZzsKKyAgICAgICAgaW50ICAgICAgICBtdGNfb2Zmc2V0OworICAgICAgICBpbnQgICAgICAgIG10Y19sb2dpY2FsX2xpbms7CisgICAgICAgIHZvaWQgICAgICAgKnBfbXRjX2VudmVsb3BlOworCXN0cnVjdAkgICBza19idWZmCSpwa19za2I7CS8qIHBhY2tpbmcgYnVmZmVyICAgICovCisJaW50CSAgIHBrX2NudDsKKyAgICAgICAgc3RydWN0IGNsYXdjdGwgY3RsX2JrOworICAgICAgICBzdHJ1Y3QgY2xhd19lbnYgKnBfZW52OworICAgICAgICBfX3U4ICAgICAgIHN5c3RlbV92YWxpZGF0ZV9jb21wOworICAgICAgICBfX3U4ICAgICAgIHJlbGVhc2VfcGVuZDsKKyAgICAgICAgX191OCAgICAgIGNoZWNrc3VtX3JlY2VpdmVkX2lwX3BrdHM7CisJX191OCAgICAgIGJ1ZmZzX2FsbG9jOworICAgICAgICBzdHJ1Y3QgZW5kY2N3ICBlbmRfY2N3OworICAgICAgICB1bnNpZ25lZCBsb25nICB0YnVzeTsKKworfTsKKworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworLyogZGVmaW5lIGdsb2JhbCBjb25zdGFudHMgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKi8KKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisKKyNkZWZpbmUgQ0NXQktfU0laRSBzaXplb2Yoc3RydWN0IGNjd2JrKQorCisKZGlmZiAtLWdpdCBhL2RyaXZlcnMvczM5MC9uZXQvY3RjZGJ1Zy5jIGIvZHJpdmVycy9zMzkwL25ldC9jdGNkYnVnLmMKbmV3IGZpbGUgbW9kZSAxMDA2NDQKaW5kZXggMDAwMDAwMC4uMmM4NmJmYQotLS0gL2Rldi9udWxsCisrKyBiL2RyaXZlcnMvczM5MC9uZXQvY3RjZGJ1Zy5jCkBAIC0wLDAgKzEsODMgQEAKKy8qCisgKgorICogbGludXgvZHJpdmVycy9zMzkwL25ldC9jdGNkYnVnLmMgKCRSZXZpc2lvbjogMS40ICQpCisgKgorICogQ1RDIC8gRVNDT04gbmV0d29yayBkcml2ZXIgLSBzMzkwIGRiZiBleHBsb2l0LgorICoKKyAqIENvcHlyaWdodCAyMDAwLDIwMDMgSUJNIENvcnBvcmF0aW9uCisgKgorICogICAgQXV0aG9yKHMpOiBPcmlnaW5hbCBDb2RlIHdyaXR0ZW4gYnkKKyAqCQkJICBQZXRlciBUaWVkZW1hbm4gKHB0aWVkZW1AZGUuaWJtLmNvbSkKKyAqCisgKiAgICAkUmV2aXNpb246IDEuNCAkCSAkRGF0ZTogMjAwNC8wOC8wNCAxMDoxMTo1OSAkCisgKgorICogVGhpcyBwcm9ncmFtIGlzIGZyZWUgc29mdHdhcmU7IHlvdSBjYW4gcmVkaXN0cmlidXRlIGl0IGFuZC9vciBtb2RpZnkKKyAqIGl0IHVuZGVyIHRoZSB0ZXJtcyBvZiB0aGU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4ICUwMnggICIgXAorCQkgICAiJTAyeCAlMDJ4ICUwMnggJTAyeCAgJTAyeCAlMDJ4ICUwMnggJTAyeFxuIiwgXAorCQkgICAqKCgoY2hhciopcHRyKSksKigoKGNoYXIqKXB0cikrMSksKigoKGNoYXIqKXB0cikrMiksIFwKKwkJICAgKigoKGNoYXIqKXB0cikrMyksKigoKGNoYXIqKXB0cikrNCksKigoKGNoYXIqKXB0cikrNSksIFwKKwkJICAgKigoKGNoYXIqKXB0cikrNiksKigoKGNoYXIqKXB0cikrNyksKigoKGNoYXIqKXB0cikrOCksIFwKKwkJICAgKigoKGNoYXIqKXB0cikrOSksKigoKGNoYXIqKXB0cikrMTApLCooKChjaGFyKilwdHIpKzExKSwgXAorCQkgICAqKCgoY2hhciopcHRyKSsxMiksKigoKGNoYXIqKXB0cikrMTMpLCBcCisJCSAgICooKChjaGFyKilwdHIpKzE0KSwqKCgoY2hhciopcHRyKSsxNSkpOyBcCitQUklOVF8jI2ltcG9ydGFuY2UoaGVhZGVyICIlMDJ4ICUwMnggJTAyeCAlMDJ4ICAlMDJ4ICUwMnggJTAyeCAlMDJ4ICAiIFwKKwkJICAgIiUwMnggJTAyeCAlMDJ4ICUwMnggICUwMnggJTAyeCAlMDJ4ICUwMnhcbiIsIFwKKwkJICAgKigoKGNoYXIqKXB0cikrMTYpLCooKChjaGFyKilwdHIpKzE3KSwgXAorCQkgICAqKCgoY2hhciopcHRyKSsxOCksKigoKGNoYXIqKXB0cikrMTkpLCBcCisJCSAgICooKChjaGFyKilwdHIpKzIwKSwqKCgoY2hhciopcHRyKSsyMSksIFwKKwkJICAgKigoKGNoYXIqKXB0cikrMjIpLCooKChjaGFyKilwdHIpKzIzKSwgXAorCQkgICAqKCgoY2hhciopcHRyKSsyNCksKigoKGNoYXIqKXB0cikrMjUpLCBcCisJCSAgICooKChjaGFyKilwdHIpKzI2KSwqKCgoY2hhciopcHRyKSsyNyksIFwKKwkJICAgKigoKGNoYXIqKXB0cikrMjgpLCoo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ys7CisJCQkJcHJpdnB0ci0+c3RhdHMudHhfYnl0ZXMgKz0KKwkJCQkgICAgc2tiLT5sZW4gLSBMTF9IRUFERVJfTEVOR1RIOworCQkJfQorCQl9CisJfQorCisJcmV0dXJuIHJjOworfQorDAorLyoqCisgKiBJbnRlcmZhY2UgQVBJIGZvciB1cHBlciBuZXR3b3JrIGxheWVycworICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworCisvKioKKyAqIE9wZW4gYW4gaW50ZXJmYWNlLgorICogQ2FsbGVkIGZyb20gZ2VuZXJpYyBuZXR3b3JrIGxheWVyIHdoZW4gaWZjb25maWcgdXAgaXMgcnVuLgorICoKKyAqIEBwYXJhbSBkZXYgUG9pbnRlciB0byBpbnRlcmZhY2Ugc3RydWN0LgorICoKKyAqIEByZXR1cm4gMCBvbiBzdWNjZXNzLCAtRVJSTk8gb24gZmFpbHVyZS4gKE5ldmVyIGZhaWxzLikKKyAqLworc3RhdGljIGludAorY3RjX29wZW4oc3RydWN0IG5ldF9kZXZpY2UgKiBkZXYpCit7CisJREJGX1RFWFQodHJhY2UsIDUsIF9fRlVOQ1RJT05fXyk7CisJZnNtX2V2ZW50KCgoc3RydWN0IGN0Y19wcml2ICopIGRldi0+cHJpdiktPmZzbSwgREVWX0VWRU5UX1NUQVJULCBkZXYpOworCXJldHVybiAwOworfQorCisvKioKKyAqIENsb3NlIGFuIGludGVyZmFjZS4KKyAqIENhbGxlZCBmcm9tIGdlbmVyaWMgbmV0d29yayBsYXllciB3aGVuIGlmY29uZmlnIGRvd24gaXMgcnVuLgorICoKKyAqIEBwYXJhbSBkZXYgUG9pbnRlciB0byBpbnRlcmZhY2Ugc3RydWN0LgorICoKKyAqIEByZXR1cm4gMCBvbiBzdWNjZXNzLCAtRVJSTk8gb24gZmFpbHVyZS4gKE5ldmVyIGZhaWxzLikKKyAqLworc3RhdGljIGludAorY3RjX2Nsb3N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AgICAweDAwMDIgLyogVW5kZXJseWluZyBuZXRkZXYgaXMgb3BlbiAgICAqLworI2RlZmluZSBDVENfQVNZTkNfVFhfTElORVNUQVQgICAgICAgIDB4MDAwNCAvKiBNdXN0IHNlbmQgbGluZSBzdGF0dXMgICAgICAgICovCisjZGVmaW5lIENUQ19BU1lOQ19TUExJVF9URVJNSU9TICAgICAgMHgwMDA4IC8qIFNlcC4gdGVybWlvcyBmb3IgZGlhbGluL291dCAgKi8KKyNkZWZpbmUgQ1RDX1RUWV9YTUlUX1NJWkUgICAgICAgICAgICAgIDEwMjQgLyogRGVmYXVsdCBidWZzaXplIGZvciB3cml0ZSAgICAqLworI2RlZmluZSBDVENfU0VSSUFMX1hNSVRfTUFYICAgICAgICAgICAgNDAwMCAvKiBNYXhpbXVtIGJ1ZnNpemUgZm9yIHdyaXRlICAgICovCisKKy8qIFByaXZhdGUgZGF0YSAoc2ltaWxhciB0byBhc3luY19zdHJ1Y3QgaW4gPGxpbnV4L3NlcmlhbC5oPikgKi8KK3R5cGVkZWYgc3RydWN0IHsKKyAgaW50CQkJbWFnaWM7CisgIGludAkJCWZsYWdzOwkJIC8qIGRlZmluZWQgaW4gdHR5LmggICAgICAgICAgICAgICAqLworICBpbnQJCQltY3I7CQkgLyogTW9kZW0gY29udHJvbCByZWdpc3RlciAgICAgICAgICovCisgIGludCAgICAgICAgICAgICAgICAgICBtc3I7ICAgICAgICAgICAgIC8qIE1vZGVtIHN0YXR1cyByZWdpc3RlciAgICAgICAgICAqLworICBpbnQgICAgICAgICAgICAgICAgICAgbHNyOyAgICAgICAgICAgICAvKiBMaW5lIHN0YXR1cyByZWdpc3RlciAgICAgICAgICAgKi8KKyAgaW50CQkJbGluZTsKKyAgaW50CQkJY291bnQ7CQkgLyogIyBvZiBmZCBvbiBkZXZpY2UgICAgICAgICAgICAgICovCisgIGludAkJCWJsb2NrZWRfb3BlbjsJIC8qICMgb2YgYmxvY2tlZCBvcGVucyAgICAgICAgICAgICAqLworICBzd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U1BJTkxPQ0soaXVjdl9pcnFfcXVldWVfbG9jayk7CisKKy8qCisgKkludGVybmFsIGZ1bmN0aW9uIHByb3RvdHlwZXMKKyAqLworc3RhdGljIHZvaWQgaXVjdl90YXNrbGV0X2hhbmRsZXIodW5zaWduZWQgbG9uZyk7CitzdGF0aWMgdm9pZCBpdWN2X2lycV9oYW5kbGVyKHN0cnVjdCBwdF9yZWdzICosIF9fdTE2KTsKKworc3RhdGljIERFQ0xBUkVfVEFTS0xFVChpdWN2X3Rhc2tsZXQsaXVjdl90YXNrbGV0X2hhbmRsZXIsMCk7CisKKy8qKioqKioqKioqKiogRlVOQ1RJT04gSUQnUyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworCisjZGVmaW5lIEFDQ0VQVCAgICAgICAgICAxMAorI2RlZmluZSBDT05ORUNUICAgICAgICAgMTEKKyNkZWZpbmUgREVDTEFSRV9CVUZGRVIgIDEyCisjZGVmaW5lIFBVUkdFICAgICAgICAgICA5CisjZGVmaW5lIFFVRVJZICAgICAgICAgICAwCisjZGVmaW5lIFFVSUVTQ0UgICAgICAgICAxMworI2RlZmluZSBSRUNFSVZFICAgICAgICAgNQorI2RlZmluZSBSRUpFQ1QgICAgICAgICAgOAorI2RlZmluZSBSRVBMWSAgICAgICAgICAgNgorI2RlZmluZSBSRVNVTUUgICAgICAgICAgMTQKKyNkZWZpbmUgUkVUUklFVkVfQlVGRkVSIDIKKyNkZWZpbmUgU0VORCAgICAgICAgICAgIDQKKyNkZWZpbmUgU0VUTUFTSyAgICAgICAgIDE2CisjZGVmaW5lIFNFVkVSICAgICAgICAgICAxNQorCisvKioKKyAqIFN0cnVjdHVyZTogaGFuZGxlcgorICogbWVtYmVyczogbGlzdCAtIGxpc3QgbWFuYWdlbWVudC4KKyAqICAgICAgICAgIHN0cnVjdHVyZTogaWQKKyAqICAgICAgICAgICAgIHVzZXJpZCAtIDggY2hhciBhcnJheSBvZiBtYWNoaW5lIGlkZW50aWZpY2F0aW9uCisgKiA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ayAoIlxuICAiKTsKKwkJZWxzZSBpZiAoIShpICUgNCkgJiYgaSAhPSAwKQorCQkJcHJpbnRrKCIgIik7CisJCXByaW50aygiJTAyWCIsICpwKyspOworCX0KKwlpZiAobGVuICUgMTYpCisJCXByaW50ayAoIlxuIik7CisJcmV0dXJuOworfQorI2RlZmluZSBpdWN2X2RlYnVnKGx2bCwgZm10LCBhcmdzLi4uKSBcCitkbyB7IFwKKwlpZiAoZGVidWdsZXZlbCA+PSBsdmwpIFwKKwkJcHJpbnRrKEtFUk5fREVCVUcgIiVzOiAiIGZtdCAiXG4iLCBfX0ZVTkNUSU9OX18gLCAjIyBhcmdzKTsgXAorfSB3aGlsZSAoMCkKKworI2Vsc2UKKworI2RlZmluZSBpdWN2X2RlYnVnKGx2bCwgZm10LCBhcmdzLi4uKQorI2RlZmluZSBpdWN2X2R1bXBpdCh0aXRsZSwgYnVmLCBsZW4pCisKKyNlbmRpZgorCisvKgorICogSW50ZXJuYWwgZnVuY3Rpb25zCisgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKwwKKy8qKgorICogcHJpbnQgc3RhcnQgYmFubmVyCisgKi8KK3N0YXRpYyB2b2lkCitpdWN2X2Jhbm5lcih2b2lkKQoreworCWNoYXIgdmJ1ZltdID0gIiRSZXZpc2lvbjogMS40MyAkIjsKKwljaGFyICp2ZXJzaW9uID0gdmJ1ZjsKKworCWlmICgodmVyc2lvbiA9IHN0cmNocih2ZXJzaW9uLCAnOicpKSkgeworCQljaGFyICpwID0gc3RyY2hyKHZlcnNpb24gKyAxLCAnJCcpOworCQlpZiAocCkKKwkJCSpwID0gJ1wwJzsKKwl9IGVsc2UKKwkJdmVyc2lvbiA9ICIgPz8/ICI7CisJcHJpbnRrKEtFUk5fSU5GTworCSAgICAgICAiSVVDViBsb3dsZXZlbCBkcml2ZXIgVmVyc2lvbiVzIGluaXRpYWxpemVkXG4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wZWNpZmllcyB3aGV0aGVyIHlvdXIgcHJvZ3JhbSBjYW4gaGFuZGxlIGEgbWVzc2FnZQorICogICAgICAgICAgICAgICAgICAgICAgIGluICB0aGUgcGFyYW1ldGVyIGxpc3QuCisgKiAgICAgLSBJUFFVU0NFICgweDQwKSAgU3BlY2lmaWVzIHdoZXRoZXIgeW91IHdhbnQgdG8gcXVpZXNjZSB0aGUgcGF0aCBiZWluZworICogICAgICAgICAgICAgICAgICAgICAgIGVzdGFibGlzaGVkLgorICogICAgIC0gSVBMT0NBTCAoMHgwMSkgIEFsbG93cyBhbiBhcHBsaWNhdGlvbiB0byBmb3JjZSB0aGUgcGFydG5lciB0byBiZSBvbiB0aGUKKyAqICAgICAgICAgICAgICAgICAgICAgICBsb2NhbCBzeXN0ZW0uIElmIGxvY2FsIGlzIHNwZWNpZmllZCB0aGVuIHRhcmdldCBjbGFzcworICogICAgICAgICAgICAgICAgICAgICAgIGNhbm5vdCBiZSBzcGVjaWZpZWQuCisgKiBAZmxhZ3MxX291dDogICAgUG9pbnRlciB0byBhbiBpbnQuIElmIG5vdCBOVUxMLCBvbiByZXR1cm4gdGhlIG9wdGlvbnMgZm9yCisgKiAgICAgICAgICAgICAgICAgdGhlIHBhdGggYXJlIHN0b3JlZCBhdCB0aGUgZ2l2ZW4gbG9jYXRpb246CisgKiAgICAgLSBJUFBSVFkgKDB4MjApICAgSW5kaWNhdGVzIHlvdSBtYXkgc2VuZCBhIHByaW9yaXR5IG1lc3NhZ2UuCisgKiBAbXNnbGltOiAgICAgICAgUG9pbnRlciB0byBhbiBfX3UxNi4gSWYgbm90IE5VTEwsIG9uIHJldHVybiB0aGUgbWF4aW11bQorICogICAgICAgICAgICAgICAgIG51bWJlciBvZiBvdXRzdGFuZGluZyBtZXNzYWdlcyBpcyBzdG9yZWQgYXQgdGhlIGdpdmVuCisgKiAgICAgICAgICAgICAgICAgbG9jYXRpb24uCisgKiBAaGFuZGxlOiAgICAgICAgQWRkcmVzcyBvZiBoY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BzZW5kIHByaW9yaXR5IG1lc3NhZ2UKKyAqICAgICAgICBidWZmZXIgLSBhZGRyZXNzIG9mIHJlcGx5IGJ1ZmZlcgorICogICAgICAgIGJ1ZmxlbiAtIGxlbmd0aCBvZiByZXBseSBidWZmZXIKKyAqIE91dHB1dDogaXBiZmFkcjIgLSBBZGRyZXNzIG9mIGJ1ZmZlciB1cGRhdGVkIGJ5IHRoZSBudW1iZXIKKyAqICAgICAgICAgICAgICAgICAgICBvZiBieXRlcyB5b3UgaGF2ZSBtb3ZlZC4KKyAqICAgICAgICAgaXBiZmxuMmYgLSBDb250YWlucyBvbmUgb2YgdGhlIGZvbGxvd2luZyB2YWx1ZXM6CisgKiAgICAgICAgICAgICAgSWYgdGhlIGFuc3dlciBidWZmZXIgaXMgdGhlIHNhbWUgbGVuZ3RoIGFzIHRoZSByZXBseSwgdGhpcyBmaWVsZAorICogICAgICAgICAgICAgICBjb250YWlucyB6ZXJvLgorICogICAgICAgICAgICAgIElmIHRoZSBhbnN3ZXIgYnVmZmVyIGlzIGxvbmdlciB0aGFuIHRoZSByZXBseSwgdGhpcyBmaWVsZCBjb250YWlucworICogICAgICAgICAgICAgICB0aGUgbnVtYmVyIG9mIGJ5dGVzIHJlbWFpbmluZyBpbiB0aGUgYnVmZmVyLgorICogICAgICAgICAgICAgIElmIHRoZSBhbnN3ZXIgYnVmZmVyIGlzIHNob3J0ZXIgdGhhbiB0aGUgcmVwbHksIHRoaXMgZmllbGQgY29udGFpbnMKKyAqICAgICAgICAgICAgICAgYSByZXNpZHVhbCBjb3VudCAodGhhdCBpcywgdGhlIG51bWJlciBvZiBieXRlcyByZW1pYW5pbmcgaW4gdGhlCisgKiAgICAgICAgICAgICAgIHJlcGx5IHRoYXQgZG9lcyBub3QgZml0IGludG8gdGhlIGJ1ZmZlci4gSW4gdGhpcworICogICAgICAgICAgICAgICAgY2FzZSBiMmYwX3Jlc3VsdCA9IDUuCisgKiBSZXR1cm46IGIyZjBfcmVzdWx0IC0gc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ZiBidWZmZXIgd2hpY2ggSVVDViBpcyBjdXJyZW50bHkgd29ya2luZyBvbi4KKyAqICAgICAgICAgaXBiZmxuMmYgLSBDb250YWlucyBvbmUgb2YgdGhlIGZvbGxvd2luZyB2YWx1ZXM6CisgKiAgICAgICAgICAgICAgSWYgdGhlIGFuc3dlciBidWZmZXIgaXMgdGhlIHNhbWUgbGVuZ3RoIGFzIHRoZSByZXBseSwgdGhpcyBmaWVsZAorICogICAgICAgICAgICAgICBjb250YWlucyB6ZXJvLgorICogICAgICAgICAgICAgIElmIHRoZSBhbnN3ZXIgYnVmZmVyIGlzIGxvbmdlciB0aGFuIHRoZSByZXBseSwgdGhpcyBmaWVsZCBjb250YWlucworICogICAgICAgICAgICAgICB0aGUgbnVtYmVyIG9mIGJ5dGVzIHJlbWFpbmluZyBpbiB0aGUgYnVmZmVyLgorICogICAgICAgICAgICAgIElmIHRoZSBhbnN3ZXIgYnVmZmVyIGlzIHNob3J0ZXIgdGhhbiB0aGUgcmVwbHksIHRoaXMgZmllbGQgY29udGFpbnMKKyAqICAgICAgICAgICAgICAgYSByZXNpZHVhbCBjb3VudCAodGhhdCBpcywgdGhlIG51bWJlciBvZiBieXRlcyByZW1pYW5pbmcgaW4gdGhlCisgKiAgICAgICAgICAgICAgIHJlcGx5IHRoYXQgZG9lcyBub3QgZml0IGludG8gdGhlIGJ1ZmZlci4gSW4gdGhpcworICogICAgICAgICAgICAgICBjYXNlIGIyZjBfcmVzdWx0ID0gNS4KKyAqIFJldHVybjogYjJmMF9yZXN1bHQgLSByZXR1cm4gY29kZSBmcm9tIENQCisgKiAgICAgICAgICAgICAoLUVJTlZBTCkgLSBidWZmZXIgYWRkcmVzcyBpcyBOVUxMCisqLworaW50CitpdWN2X3JlcGx5X2FycmF5IChfX3UxNiBwYXRoaWQsCisJCSAgX191MzIgbXNnaWQsIF9fdTMyIHRyZ2NscywKKwkJICBpbnQgZmxhZ3MxLAorCQkgIGl1Y3ZfYXJyYXlfdCAqIGJ1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0IHsKKwl1MTYgaXBwYXRoaWQ7CisJdWNoYXIgaXBmbGFnczE7CisJdWNoYXIgaXB0eXBlOworCXUzMiBpcG1zZ2lkOworCXUzMiBpcGF1ZGl0OworCXVjaGFyIGlwcm1tc2dbOF07CisJdTMyIGlwc3JjY2xzOworCXUzMiBpcG1zZ3RhZzsKKwl1MzIgcmVzOworCXUzMiBpcGJmbG4yZjsKKwl1Y2hhciBpcHBvbGxmZzsKKwl1Y2hhciByZXMyWzNdOworfSBpdWN2X01lc3NhZ2VDb21wbGV0ZTsKKworLyogCisgKiBpdWN2X2ludGVycnVwdF9vcHNfdDogSXMgYSB2ZWN0b3Igb2YgZnVuY3Rpb25zIHRoYXQgaGFuZGxlIAorICogSVVDViBpbnRlcnJ1cHRzLiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAorICogUGFyYW1ldGVyIGxpc3Q6ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAorICogICAgICAgICBlaWIgLSBpcyBhIHBvaW50ZXIgdG8gYSA0MC1ieXRlIGFyZWEgZGVzY3JpYmVkICAgIAorICogICAgICAgICAgICAgICB3aXRoIG9uZSBvZiB0aGUgc3RydWN0dXJlcyBhYm92ZS4gICAgICAgICAgIAorICogICAgICAgICBwZ21fZGF0YSAtIHRoaXMgZGF0YSBpcyBzdHJpY3RseSBmb3IgdGhlICAgICAgICAgIAorICogICAgICAgICAgICAgICAgICAgIGludGVycnVwdCBoYW5kbGVyIHRoYXQgaXMgcGFzc2VkIGJ5ICAgIAorICogICAgICAgICAgICAgICAgICAgIHRoZSBhcHBsaWNhdGlvbi4gVGhpcyBtYXkgYmUgYW4gYWRkcmVzcyAKKyAqICAgICAgICAgICAgICAgICAgICBvciB0b2tlbi4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKKyovCit0eXBlZGVmIHN0cnVjdCB7CisJdm9pZCAoKkNvbm5lY3Rpb25QZW5kaW5nKSAoaXVjdl9Db25uZ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3ZfYnVzOworZXh0ZXJuIHN0cnVjdCBkZXZpY2UgKml1Y3Zfcm9vdDsKKworLyogICAtcHJvdG90eXBlcy0gICAgKi8KKy8qICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAorICogTmFtZTogaXVjdl9yZWdpc3Rlcl9wcm9ncmFtICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCisgKiBQdXJwb3NlOiBSZWdpc3RlcnMgYW4gYXBwbGljYXRpb24gd2l0aCBJVUNWICAgICAgICAgICAgICAgICAgICAKKyAqIElucHV0OiBwcm1uYW1lIC0gdXNlciBpZGVudGlmaWNhdGlvbiAgICAgICAgICAgICAgICAgICAgICAgICAgIAorICogICAgICAgIHVzZXJpZCAgLSBtYWNoaW5lIGlkZW50aWZpY2F0aW9uCisgKiAgICAgICAgcGdtbWFzayAtIGluZGljYXRlcyB3aGljaCBiaXRzIGluIHRoZSBwcm1uYW1lIGFuZCB1c2VyaWQgY29tYmluZWQgd2lsbCBiZQorICogIAkJICAgIHVzZWQgdG8gZGV0ZXJtaW5lIHdobyBpcyBnaXZlbiBjb250cm9sCisgKiAgICAgICAgb3BzICAgICAtIGFkZHJlc3Mgb2YgdmVjdG9yIG9mIGludGVycnVwdCBoYW5kbGVycyAgICAgICAKKyAqICAgICAgICBwZ21fZGF0YS0gYXBwbGljYXRpb24gZGF0YSBwYXNzZWQgdG8gaW50ZXJydXB0IGhhbmRsZXJzIAorICogT3V0cHV0OiBOQSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCisgKiBSZXR1cm46IGFkZHJlc3Mgb2YgaGFuZGxlciAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKKyAqICAgICAgICAgKDApIC0gRXJyb3Igb2NjdXJyZWQsIHJlZ2lzdHJhdGlvbiBub3QgY29tcGxldGVkLgorICogTk9URTogRXhhY3QgY2F1c2Ugb2YgZmFpbHVyZSB3aWxsIGJlIHJlY29yZGVkIGluIHN5c2xvZy4gICAgICAgICAgICAgICAgICAgICAgICAKKyovCitpdWN2X2hhbmRsZV90IGl1Y3ZfcmVnaXN0ZXJfcHJvZ3JhbSAodWNoYXIgcGdtbmFtZVsxNl0sCisJCQkJICAgICB1Y2hhciB1c2VyaWRbOF0sCisJCQkJICAgICB1Y2hhciBwZ21tYXNrWzI0XSwKKwkJCQkgICAgIGl1Y3ZfaW50ZXJydXB0X29wc190ICogb3BzLAorCQkJCSAgICAgdm9pZCAqcGdtX2RhdGEpOworCisvKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAorICogTmFtZTogaXVjdl91bnJlZ2lzdGVyX3Byb2dyYW0gICAgICAgICAgICAgICAgICAKKyAqIFB1cnBvc2U6IFVucmVnaXN0ZXIgYXBwbGljYXRpb24gd2l0aCBJVUNWICAgICAgCisgKiBJbnB1dDogYWRkcmVzcyBvZiBoYW5kbGVyICAgICAgICAgICAgICAgICAgICAgIAorICogT3V0cHV0OiBOQSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKKyAqIFJldHVybjogKDApIC0gTm9ybWFsIHJldHVybiAgICAgICAgICAgICAgICAgICAgCisgKiAgICAgICAgICgtRUlOVkFMKSAtIEludGVybmFsIGVycm9yLCB3aWxkIHBvaW50ZXIgICAgIAorKi8KK2ludCBpdWN2X3VucmVnaXN0ZXJfcHJvZ3JhbSAoaXVjdl9oYW5kbGVfdCBoYW5kbGUpOworCisvKgorICogTmFtZTogaXVjdl9hY2NlcHQKKyAqIFB1cnBvc2U6IFRoaXMgZnVuY3Rpb24gaXMgaXNzdWVkIGFmdGVyIHRoZSB1c2VyIHJlY2VpdmVzIGEgQ29ubmVjdGlvbiBQZW5kaW5nIGV4dGVybmFsCisgKiAgICAgICAgICBpbnRlcnJ1cHQgYW5kIG5vdyB3aXNoZXMgdG8gY29tcGxldGUgdGhlIElVQ1YgY29t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ZfcHVyZ2UgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCisgKiBQdXJwb3NlOiBUaGlzIGZ1bmN0aW9uIGNhbmNlbHMgYSBtZXNzYWdlIHRoYXQgeW91IGhhdmUgc2VudC4gICAgICAgIAorICogSW5wdXQ6IHBhdGhpZCAtIFBhdGggaWRlbnRpZmljYXRpb24gbnVtYmVyLiAgICAgICAgICAgICAgICAgICAgICAgICAgCisgKiAgICAgICAgbXNnaWQgLSBTcGVjaWZpZXMgdGhlIG1lc3NhZ2UgSUQgb2YgdGhlIG1lc3NhZ2UgdG8gYmUgcHVyZ2VkLgorICogICAgICAgIHNyY2NscyAtIFNwZWNpZmllcyB0aGUgc291cmNlIG1lc3NhZ2UgY2xhc3MuICAgICAgICAgICAgICAgICAgCisgKiBPdXRwdXQ6IGF1ZGl0IC0gQ29udGFpbnMgaW5mb3JtYXRpb24gYWJvdXQgYXN5bmNocm9ub3VzIGVycm9yICAgICAgIAorICogICAgICAgICAgICAgICAgIHRoYXQgbWF5IGhhdmUgYWZmZWN0ZWQgdGhlIG5vcm1hbCBjb21wbGV0aW9uICAgICAgICAKKyAqICAgICAgICAgICAgICAgICBvZiB0aGlzIG1lc3NhZ2UuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCisgKiBSZXR1cm46IFJldHVybiBjb2RlIGZyb20gQ1AgSVVDViBjYWxsLiAgICAgICAgICAgICAgICAgICAgICAgICAgIAorKi8KK2ludCBpdWN2X3B1cmdlICh1MTYgcGF0aGlkLCB1MzIgbXNnaWQsIHUzMiBzcmNjbHMsIF9fdTMyICphdWRpdCk7CisvKgorICogTmFtZTogaXVjdl9xdWVyeV9tYXhjb25uCisgKiBQdXJwb3NlOiBUaGlzIGZ1bmN0aW9uIGRldGVybWluZXMgdGhlIG1heGltdW0gbnVtYmVyIG9mIGNvbW11bmljYXRpb24gcGF0aHMgeW91CisgKgkgICAgbWF5IGVzdGFibGlzaC4KKyAqIFJldHVybjogIG1heGNvbm4gLSB1bG9uZywgTWF4aW11bSBudW1iZXIgb2YgY29ubmVjdGlvbiB0aGUgdmlydHVhbCBtYWNoaW5lIG1heQorICogICAgICAgICAgZXN0YWJsaXNoLgorKi8KK3Vsb25nIGl1Y3ZfcXVlcnlfbWF4Y29ubiAodm9pZCk7CisKKy8qCisgKiBOYW1lOiBpdWN2X3F1ZXJ5X2J1ZnNpemUKKyAqIFB1cnBvc2U6IFRoaXMgZnVuY3Rpb24gZGV0ZXJtaW5lcyBob3cgbGFyZ2UgYW4gZXh0ZXJuYWwgaW50ZXJydXB0CisgKiAgICAgICAgICBidWZmZXIgSVVDViByZXF1aXJlcyB0byBzdG9yZSBpbmZvcm1hdGlvbi4KKyAqIFJldHVybjogIGJ1ZnNpemUgLSB1bG9uZywgU2l6ZSBvZiBleHRlcm5hbCBpbnRlcnJ1cHQgYnVmZmVyLgorICovCit1bG9uZyBpdWN2X3F1ZXJ5X2J1ZnNpemUgKHZvaWQpOworCisvKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAorICogTmFtZTogaXVjdl9xdWllc2NlICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKKyAqIFB1cnBvc2U6IFRoaXMgZnVuY3Rpb24gdGVtcG9yYXJpbHkgc3VzcGVuZHMgaW5jb21pbmcgbWVzc2FnZXMgb24gYW4gCisgKiAgICAgICAgICBJVUNWIHBhdGguIFlvdSBjYW4gbGF0ZXIgcmVhY3RpdmF0ZSB0aGUgcGF0aCBieSBpbnZva2luZyAgIAorICogICAgICAgICAgdGhlIGl1Y3ZfcmVzdW1lIGZ1bmN0aW9uLiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKKyAqIElucHV0OiBwYXRoaWQgLSBQYXRoIGlkZW50aWZpY2F0aW9uIG51bWJlciAgICAgICAgICAgICAgICAgICAgICAgICAgCisgKiAgICAgICAgdXNlcl9kYXRhICAtIDE2LWJ5dGVzIG9mIHVzZXIgZGF0YSAgICAgICAgICAgICAgICAgICAgICAgICAgIAorICogT3V0cHV0OiBOQSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKKyAqIFJldHVybjogUmV0dXJuIGNvZGUgZnJvbSBDUCBJVUNWIGNhbGwuICAgICAgICAgICAgICAgICAgICAgICAgICAgCisqLworaW50IGl1Y3ZfcXVpZXNjZSAodTE2IHBhdGhpZCwgdWNoYXIgdXNlcl9kYXRhWzE2XSk7CisKKy8qICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCisgKiBOYW1lOiBpdWN2X3JlY2VpdmUgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAorICogUHVycG9zZTogVGhpcyBmdW5jdGlvbiByZWNlaXZlcyBtZXNzYWdlcyB0aGF0IGFyZSBiZWluZyBzZW50IHRvIHlvdSAKKyAqICAgICAgICAgIG92ZXIgZXN0YWJsaXNoZWQgcGF0aHMuIERhdGEgd2lsbCBiZSByZXR1cm5lZCBpbiBidWZmZXIgZm9yIGxlbmd0aCBvZgorICogICAgICAgICAgYnVmbGVuLgorICogSW5wdXQ6IAorICogICAgICAgcGF0aGlkIC0gUGF0aCBpZGVudGlmaWNhdGlvbiBudW1iZXIuICAgICAgICAgICAgICAgICAgICAgICAgICAKKyAqICAgICAgIGJ1ZmZlciAtIEFkZHJlc3Mgb2YgYnVmZmVyIHRvIHJlY2VpdmUuICAgICAgICAgICAgICAgICAgICAgICAgCisgKiAgICAgICBidWZsZW4gLSBMZW5ndGggb2YgYnVmZmVyIHRvIHJlY2VpdmUuICAgICAgICAgICAgICAgICAgICAgICAgIAorICogICAgICAgbXNnaWQgLSBTcGVjaWZpZXMgdGhlIG1lc3NhZ2UgSUQuICAgICAgICAgIAorICogIC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mVyLgorICogICAgICAgICAgICAgICBTaG9ydGVyIHRoYW4gdGhlIG1lc3NhZ2UsIHRoaXMgZmllbGQgY29udGFpbnMgdGhlIHJlc2lkdWFsCisgKiAgICAgICAgICAgICAgICBjb3VudCAodGhhdCBpcywgdGhlIG51bWJlciBvZiBieXRlcyByZW1haW5pbmcgaW4gdGhlCisgKiAgICAgICAgICAgICAgICBtZXNzYWdlIHRoYXQgZG9lcyBub3QgZml0IGludG8gdGhlIGJ1ZmZlci4gSW4gdGhpcworICogICAgICAgICAgICAgICAgY2FzZSBiMmYwX3Jlc3VsdCA9IDUuCisgKiBSZXR1cm46IFJldHVybiBjb2RlIGZyb20gQ1AgSVVDViBjYWxsLiAgICAgICAgICAgICAgICAgICAgICAgICAgIAorICogICAgICAgICAoLUVJTlZBTCkgLSBidWZmZXIgYWRkcmVzcyBpcyBwb2ludGluZyB0byBOVUxMICAgICAgICAgICAgICAgICAgIAorKi8KK2ludCBpdWN2X3JlY2VpdmUgKHUxNiBwYXRoaWQsCisJCSAgdTMyIG1zZ2lkLAorCQkgIHUzMiB0cmdjbHMsCisJCSAgdm9pZCAqYnVmZmVyLAorCQkgIHVsb25nIGJ1ZmxlbiwKKwkJICBpbnQgKmZsYWdzMV9vdXQsCisJCSAgdWxvbmcgKiByZXNpZHVhbF9idWZmZXIsIHVsb25nICogcmVzaWR1YWxfbGVuZ3RoKTsKKworIC8qICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCisgICogTmFtZTogaXVjdl9yZWNlaXZlX2FycmF5ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKKyAgKiBQdXJwb3NlOiBUaGlzIGZ1bmN0aW9uIHJlY2VpdmVzIG1lc3NhZ2VzIHRoYXQgYXJlIGJlaW5nIHNlbnQgdG8geW91IAorICAqICAgICAgICAgIG92ZXIgZXN0YWJsaXNoZWQgcGF0aHMuIERhdGEgd2lsbCBiZSByZXR1cm5lZCBpbiBmaXJzdCBidWZmZXIgZm9yCisgICogICAgICAgICAgbGVuZ3RoIG9mIGZpcnN0IGJ1ZmZlci4KKyAgKiBJbnB1dDogcGF0aGlkIC0gUGF0aCBpZGVudGlmaWNhdGlvbiBudW1iZXIuICAgICAgICAgICAgICAgICAgICAgICAgICAKKyAgKiAgICAgICAgbXNnaWQgLSBzcGVjaWZpZXMgdGhlIG1lc3NhZ2UgSUQuCisgICogICAgICAgIHRyZ2NscyAtIFNwZWNpZmllcyB0YXJnZXQgY2xhc3MuCisgICogICAgICAgIGJ1ZmZlciAtIEFkZHJlc3Mgb2YgYXJyYXkgb2YgYnVmZmVycy4gICAgICAgICAgICAgICAgICAgICAgICAgCisgICogICAgICAgIGJ1ZmxlbiAtIFRvdGFsIGxlbmd0aCBvZiBidWZmZXJzLiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCisgICogT3V0cHV0OgorICAqICAgICAgICBmbGFnczFfb3V0OiBpbnQgKiwgQ29udGFpbnMgaW5mb3JtYXRpb24gYWJvdXQgdGhpcyBwYXRoLgorICAqICAgICAgICAgIElQTk9SUFkgLSAweDEwIFNwZWNpZmllcyB0aGlzIGlzIGEgb25lLXdheSBtZXNzYWdlIGFuZCBubyByZXBseSBpcworICAqICAgICAgICAgIGV4cGVjdGVkLgorICAqICAgICAgICAgIElQUFJUWSAgLSAweDIwIFNwZWNpZmllcyBpZiB5b3Ugd2FudCB0byBzZW5kIHByaW9yaXR5IG1lc3NhZ2UuCisgICogICAgICAgICAgSVBSTURBVEEgLSAweDgwIHNwZWNpZmllcyB0aGUgZGF0YSBpcyBjb250YWluZWQgaW4gdGhlIHBhcmFtZXRlciBsaXN0CisgICogICAgICAgcmVzaWR1YWxfYnVmZmVyIC0gYWRkcmVzcyBwb2ludHMgdG8gdGhlIGN1cnJlbnQgbGlzdCBlbnRyeSBJVUNWCisgICogICAgICAgICAgICAgICAgICAgICAgICAgaXMgd29ya2luZyBvbi4KKyAg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xvbmcgKiByZXNpZHVhbF9idWZmZXIsIHVsb25nICogcmVzaWR1YWxfbGVuZ3RoKTsKKworLyogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAorICogTmFtZTogaXVjdl9yZWplY3QgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAorICogUHVycG9zZTogVGhlIHJlamVjdCBmdW5jdGlvbiByZWZ1c2VzIGEgc3BlY2lmaWVkIG1lc3NhZ2UuIEJldHdlZW4gdGhlIAorICogICAgICAgICAgdGltZSB5b3UgYXJlIG5vdGlmaWVkIG9mIGEgbWVzc2FnZSBhbmQgdGhlIHRpbWUgdGhhdCB5b3UgICAgIAorICogICAgICAgICAgY29tcGxldGUgdGhlIG1lc3NhZ2UsIHRoZSBtZXNzYWdlIG1heSBiZSByZWplY3RlZC4gICAgICAgICAgIAorICogSW5wdXQ6IHBhdGhpZCAtIFBhdGggaWRlbnRpZmljYXRpb24gbnVtYmVyLiAgICAgICAgICAgICAgICAgICAgICAgICAgICAKKyAqICAgICAgICBtc2dpZCAtIFNwZWNpZmllcyB0aGUgbWVzc2FnZSBJRC4gICAgICAgICAgICAgICAgICAgCisgKiAgICAgICAgdHJnY2xzIC0gU3BlY2lmaWVzIHRhcmdldCBjbGFzcy4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAorICogT3V0cHV0OiBOQSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAorICogUmV0dXJuOiBSZXR1cm4gY29kZSBmcm9tIENQIElVQ1YgY2FsbC4gICAgICAgICAgICAgICAgICAgICAgICAgICAgIAorKi8KK2ludCBpdWN2X3JlamVjdCAodTE2IHBhdGhpZCwgdTMyIG1zZ2lkLCB1MzIgdHJnY2xzKTsKKworLyogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKKyAqIE5hbWU6IGl1Y3ZfcmVwbHkgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCisgKiBQdXJwb3NlOiBUaGlzIGZ1bmN0aW9uIHJlc3BvbmRzIHRvIHRoZSB0d28td2F5IG1lc3NhZ2VzIHRoYXQgeW91ICAgIAorICogICAgICAgICAgcmVjZWl2ZS4gWW91IG11c3QgaWRlbnRpZnkgY29tcGxldGVseSB0aGUgbWVzc2FnZSB0byAgICAgICAKKyAqICAgICAgICAgIHdoaWNoIHlvdSB3aXNoIHRvIHJlcGx5LiBpZSwgcGF0aGlkLCBtc2dpZCwgYW5kIHRyZ2Nscy4gICAgCisgKiBJbnB1dDogcGF0aGlkIC0gUGF0aCBpZGVudGlmaWNhdGlvbiBudW1iZXIuICAgICAgICAgICAgICAgICAgICAgICAgICAKKyAqICAgICAgICBtc2dpZCAtIFNwZWNpZmllcyB0aGUgbWVzc2FnZSBJRC4gICAgICAgICAgICAgICAgCisgKiAgICAgICAgdHJnY2xzIC0gU3BlY2lmaWVzIHRhcmdldCBjbGFzcy4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKKyAqICAgICAgICBmbGFnczEgLSBPcHRpb24gZm9yIHBhdGguCisgKiAgICAgICAgICBJUFBSVFktIDB4MjAsIFNwZWNpZmllcyBpZiB5b3Ugd2FudCB0byBzZW5kIHByaW9yaXR5IG1lc3NhZ2UuICAgICAgICAKKyAqICAgICAgICBidWZmZXIgLSBBZGRyZXNzIG9mIHJlcGx5IGJ1ZmZlci4gICAgICAgICAgICAgICAgICAgICAgICAgICAgIAorICogICAgICAgIGJ1ZmxlbiAtIExlbmd0aCBvZiByZXBseSBidWZmZXIuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCisgKiBPdXRwdXQ6IHJlc2lkdWFsX2J1ZmZlciAtIEFkZHJlc3Mgb2YgYnVmZmVyIHVwZGF0ZWQgYnkgdGhlIG51b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yBidWZsZW4sIHVsb25nICogcmVzaWR1YWxfYnVmZmVyLAorCQl1bG9uZyAqIHJlc2lkdWFsX2xlbmd0aCk7CisKKy8qICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKKyAqIE5hbWU6IGl1Y3ZfcmVwbHlfYXJyYXkgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKKyAqIFB1cnBvc2U6IFRoaXMgZnVuY3Rpb24gcmVzcG9uZHMgdG8gdGhlIHR3by13YXkgbWVzc2FnZXMgdGhhdCB5b3UgICAgICAKKyAqICAgICAgICAgIHJlY2VpdmUuIFlvdSBtdXN0IGlkZW50aWZ5IGNvbXBsZXRlbHkgdGhlIG1lc3NhZ2UgdG8gICAgICAgICAKKyAqICAgICAgICAgIHdoaWNoIHlvdSB3aXNoIHRvIHJlcGx5LiBpZSwgcGF0aGlkLCBtc2dpZCwgYW5kIHRyZ2Nscy4gICAgICAKKyAqICAgICAgICAgIFRoZSBhcnJheSBpZGVudGlmaWVzIGEgbGlzdCBvZiBhZGRyZXNzZXMgYW5kIGxlbmd0aHMgb2YgICAgICAKKyAqICAgICAgICAgIGRpc2NvbnRpZ3VvdXMgYnVmZmVycyB0aGF0IGNvbnRhaW5zIHRoZSByZXBseSBkYXRhLiAgICAgICAgICAKKyAqIElucHV0OiBwYXRoaWQgLSBQYXRoIGlkZW50aWZpY2F0aW9uIG51bWJlciAgICAgICAgICAgICAgICAgICAgICAgICAgICAKKyAqICAgICAgICBtc2dpZCAtIFNwZWNpZmllcyB0aGUgbWVzc2FnZSBJRC4gCisgKiAgICAgICAgdHJnY2xzIC0gU3BlY2lmaWVzIHRhcmdldCBjbGFzcy4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAorICogICAgICAgIGZsYWdzMSAtIE9wdGlvbiBmb3IgcGF0aC4KKyAqICAgICAgICAgIElQUFJUWS0gMHgyMCwgU3BlY2lmaWVzIGlmIHlvdSB3YW50IHRvIHNlbmQgcHJpb3JpdHkgbWVzc2FnZS4KKyAqICAgICAgICBidWZmZXIgLSBBZGRyZXNzIG9mIGFycmF5IG9mIHJlcGx5IGJ1ZmZlcnMuICAgICAgICAgICAgICAgICAgICAgCisgKiAgICAgICAgYnVmbGVuIC0gVG90YWwgbGVuZ3RoIG9mIHJlcGx5IGJ1ZmZlcnMuICAgICAgICAgICAgICAgICAgICAgICAgIAorICogT3V0cHV0OiByZXNpZHVhbF9idWZmZXIgLSBBZGRyZXNzIG9mIGJ1ZmZlciB3aGljaCBJVUNWIGlzIGN1cnJlbnRseSB3b3JraW5nIG9uLgorICogICAgICAgICByZXNpZHVhbF9sZW5ndGggLSBDb250YWlucyBvbmUgb2YgdGhlIGZvbGxvd2luZyB2YWx1ZXM6CisgKiAgICAgICAgICAgICAgSWYgdGhlIGFuc3dlciBidWZmZXIgaXMgdGhlIHNhbWUgbGVuZ3RoIGFzIHRoZSByZXBseSwgdGhpcyBmaWVsZAorICogICAgICAgICAgICAgICBjb250YWlucyB6ZXJvLgorICogICAgICAgICAgICAgIElmIHRoZSBhbnN3ZXIgYnVmZmVyIGlzIGxvbmdlciB0aGFuIHRoZSByZXBseSwgdGhpcyBmaWVsZCBjb250YWlucworICogICAgICAgICAgICAgICB0aGUgbnVtYmVyIG9mIGJ5dGVzIHJlbWFpbmluZyBpbiB0aGUgYnVmZmVyLgorICogICAgICAgICAgICAgIElmIHRoZSBhbnN3ZXIgYnVmZmVyIGlzIHNob3J0ZXIgdGhhbiB0aGUgcmVwbHksIHRoaXMgZmllbGQgY29udGFpbnMKKyAqICAgICAgICAgICAgICAgYSByZXNpZHVhbCBjb3VudCAodGhhdCBpcywgdGhlIG51bWJlciBvZiBieXRlcyByZW1pYW5pbmcgaW4gdGhlCisgKiAgICAgICAgICAgICAgIHJlcGx5IHRoYXQgZG9lcyBub3QgZml0IGludG8gdGhlIGJ1ZmZlci4gSW4gdGhpcworICogICAgICAgICAgICAgICBjYXNlIGIyZjBfcmVzdWx0ID0gNS4KKyAqIFJldHVybjogUmV0dXJuIGNvZGUgZnJvbSBDUCBJVUNWIGNhbGwuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKKyAqICAgICAgICAgKC1FSU5WQUwpIC0gQnVmZmVyIGFkZHJlc3MgaXMgTlVMTC4gICAgICAgICAgICAgIAorKi8KK2ludCBpdWN2X3JlcGx5X2FycmF5ICh1MTYgcGF0aGlkLAorCQkgICAgICB1MzIgbXNnaWQsCisJCSAgICAgIHUzMiB0cmdjbHMsCisJCSAgICAgIGludCBmbGFnczEsCisJCSAgICAgIGl1Y3ZfYXJyYXlfdCAqIGJ1ZmZlciwKKwkJICAgICAgdWxvbmcgYnVmbGVuLCB1bG9uZyAqIHJlc2lkdWFsX2FkZHJlc3MsCisJCSAgICAgIHVsb25nICogcmVzaWR1YWxfbGVuZ3RoKTsKKworLyogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKKyAqIE5hbWU6IGl1Y3ZfcmVwbHlfcHJtbXNnICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCisgKiBQdXJwb3NlOiBUaGlzIGZ1bmN0aW9uIHJlc3BvbmRzIHRvIHRoZSB0d28td2F5IG1lc3NhZ2VzIHRoYXQgeW91IAorICogICAgICAgICAgcmVjZWl2ZS4gWW91IG11c3QgaWRlbnRpZnkgY29tcGxldGVseSB0aGUgbWVzc2FnZSB0byAgICAKKyAqICAgICAgICAgIHdoaWNoIHlvdSB3aXNoIHRvIHJlcGx5LiBpZSwgcGF0aGlkLCBtc2dpZCwgYW5kIHRyZ2Nscy4gCisgKiAgICAgICAgICBQcm1tc2cgc2lnbmlmaWVzIHRoZSBkYXRhIGlzIG1vdmVkIGludG8gdGhlICAgICAgICAgICAgIAorICogICAgICAgICAgcGFyYW1ldGVyIGxpc3QuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKKyAqIElucHV0OiBwYXRoaWQgLSBQYXRoIGlkZW50aWZpY2F0aW9uIG51bWJlci4gICAgICAgICAgICAgICAgICAgICAgIAorICogICAgICAgIG1zZ2lkIC0gU3BlY2lmaWVzIHRoZSBtZXNzYWdlIElELiAgICAgICAgICAgICAgCisgKiAgICAgICAgdHJnY2xzIC0gU3BlY2lmaWVzIHRhcmdldCBjbGFzcy4gICAgICAgICAgICAgICAgICAgICAgICAgICAKKyAqICAgICAgICBmbGFnczEgLSBPcHRpb24gZm9yIHBhdGguCisgKiAgICAgICAgICBJUFBSVFktIDB4MjAgU3BlY2lmaWVzIGlmIHlvdSB3YW50IHRvIHNlbmQgcHJpb3JpdHkgbWVzc2FnZS4KKyAqICAgICAgICBwcm1tc2cgLSA4LWJ5dGVzIG9mIGRhdGEgdG8gYmUgcGxhY2VkIGludG8gdGhlIHBhcmFtZXRlci4gIAorICogICAgICAgICAgICAgICAgIGxpc3QuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKKyAqIE91dHB1dDogTkEgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCisgKiBSZXR1cm46IFJldHVybiBjb2RlIGZyb20gQ1AgSVVDViBjYWxsLiAgICAgICAgICAgICAgICAgICAgICAgIAorKi8KK2ludCBpdWN2X3JlcGx5X3BybW1zZyAodTE2IHBhdGhpZCwKKwkJICAgICAgIHUzMiBtc2dpZCwgdTMyIHRyZ2NscywgaW50IGZsYWdzMSwgdWNoYXIgcHJtbXNnWzhdKTsKKworLyogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKKyAqIE5hbWU6IGl1Y3ZfcmVzdW1lICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCisgKiBQdXJwb3NlOiBUaGlzIGZ1bmN0aW9uIHJlc3RvcmVzIGNvbW11bmljYXRpb25zIG92ZXIgYSBxdWllc2NlZCBwYXRoIAorICogSW5wdXQ6IHBhdGhpZCAtIFBhdGggaWRlbnRpZmljYXRpb24gbnVtYmVyLiAgICAgICAgICAgICAgICAgICAgICAgICAgCisgKiAgICAgICAgdXNlcl9kYXRhICAtIDE2LWJ5dGVzIG9mIHVzZXIgZGF0YS4gICAgICAgICAgICAgICAgICAgICAgICAgICAKKyAqIE91dHB1dDogTkEgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCisgKiBSZXR1cm46IFJldHVybiBjb2RlIGZyb20gQ1AgSVVDViBjYWxsLiAgICAgICAgICAgICAgICAgICAgICAgICAgIAorKi8KK2ludCBpdWN2X3Jlc3VtZSAodTE2IHBhdGhpZCwgdWNoYXIgdXNlcl9kYXRhWzE2XSk7CisKKy8qICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAorICogTmFtZTogaXVjdl9zZW5kICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCisgKiBQdXJwb3NlOiBUaGlzIGZ1bmN0aW9uIHRyYW5zbWl0cyBkYXRhIHRvIGFub3RoZXIgYXBwbGljYXRpb24uICAgICAKKyAqICAgICAgICAgIERhdGEgdG8gYmUgdHJhbnNtaXR0ZWQgaXMgaW4gYSBidWZmZXIgYW5kIHRoaXMgaXMgYSAgICAgIAorICogICAgICAgICAgb25lLXdheSBtZXNzYWdlIGFuZCB0aGUgcmVjZWl2ZXIgd2lsbCBub3QgcmVwbHkgdG8gdGhlICAgCisgKiAgICAgICAgICBtZXNzYWdlLiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKKyAqIElucHV0OiBwYXRoaWQgLSBQYXRoIGlkZW50aWZpY2F0aW9uIG51bWJlci4gICAgICAgICAgICAgICAgICAgICAgICAKKyAqICAgICAgICB0cmdjbHMgLSBTcGVjaWZpZXMgdGFyZ2V0IGNsYXNzLiAgICAgICAgICAgICAgICAgICAgICAgICAgICAKKyAqICAgICAgICBzcmNjbHMgLSBTcGVjaWZpZXMgdGhlIHNvdXJjZSBtZXNzYWdlIGNsYXNzLiAgICAgICAgICAgICAgICAKKyAqICAgICAgICBtc2d0YWcgLSBTcGVjaWZpZXMgYSB0YWcgdG8gYmUgYXNzb2NpYXRlZCB3aXRoIHRoZSBtZXNzYWdlLiAKKyAqICAgICAgICBmbGFnczEgLSBPcHRpb24gZm9yIHBhdGguCisgKiAgICAgICAgICBJUFBSVFktIDB4MjAgU3BlY2lmaWVzIGlmIHlvdSB3YW50IHRvIHNlbmQgcHJpb3JpdHkgbWVzc2FnZS4KKyAqICAgICAgICBidWZmZXIgLSBBZGRyZXNzIG9mIHNlbmQgYnVmZmVyLiAgICAgICAgICAgICAgICAgICAgICAgICAgICAKKyAqICAgICAgICBidWZsZW4gLSBMZW5ndGggb2Ygc2VuZCBidWZmZXIuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKKyAqIE91dHB1dDogbXNnaWQgLSBTcGVjaWZpZXMgdGhlIG1lc3NhZ2UgSUQuICAgICAgICAgICAgICAgICAgICAgICAgIAorICogUmV0dXJuOiBSZXR1cm4gY29kZSBmcm9tIENQIElVQ1YgY2FsbC4gICAgICAgICAgICAgICAgICAgICAgICAgCisgKiAgICAgICAgICgtRUlOVkFMKSAtIEJ1ZmZlciBhZGRyZXNzIGlzIE5VTEwuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKKyovCitpbnQgaXVjdl9zZW5kICh1MTYgcGF0aGlkLAorCSAgICAgICB1MzIgKiBtc2dpZCwKKwkgICAgICAgdTMyIHRyZ2NscywKKwkgICAgICAgdTMyIHNyY2NscywgdTMyIG1zZ3RhZywgaW50IGZsYWdzMSwgdm9pZCAqYnVmZmVyLCB1bG9uZyBidWZsZW4pOworCisvKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKKyAqIE5hbWU6IGl1Y3Zfc2VuZF9hcnJheSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAorICogUHVycG9zZTogVGhpcyBmdW5jdGlvbiB0cmFuc21pdHMgZGF0YSB0byBhbm90aGVyIGFwcGxpY2F0aW9uLiAgICAgCisgKiAgICAgICAgICBUaGUgY29udGVudHMgb2YgYnVmZmVyIGlzIHRoZSBhZGRyZXNzIG9mIHRoZSBhcnJheSBvZiAgICAKKyAqICAgICAgICAgIGFkZHJlc3NlcyBhbmQgbGVuZ3RocyBvZiBkaXNjb250aWd1b3VzIGJ1ZmZlcnMgdGhhdCBob2xkIAorICogICAgICAgICAgdGhlIG1lc3NhZ2UgdGV4dC4gVGhpcyBpcyBhIG9uZS13YXkgbWVzc2FnZSBhbmQgdGhlICAgICAgCisgKiAgICAgICAgICByZWNlaXZlciB3aWxsIG5vdCByZXBseSB0byB0aGUgbWVzc2FnZS4gICAgICAgICAgICAgICAgICAKKyAqIElucHV0OiBwYXRoaWQgLSBQYXRoIGlkZW50aWZpY2F0aW9uIG51bWJlci4gICAgICAgICAgICAgICAgICAgICAgICAKKyAqICAgICAgICB0cmdjbHMgLSBTcGVjaWZpZXMgdGFyZ2V0IGNsYXNzLiAgICAgICAgICAgICAgICAgICAgICAgICAgICAKKyAqICAgICAgICBzcmNjbHMgLSBTcGVjaWZpZXMgdGhlIHNvdXJjZSBtZXNzYWdlIGNsYXNzLiAgICAgICAgICAgICAgICAKKyAqICAgICAgICBtc2d0YWcgLSBTcGVjaWZpZXMgYSB0YWcgdG8gYmUgYXNzb2NpYXRlZCB3aXRodCB0aGUgbWVzc2FnZS4KKyAqICAgICAgICBmbGFnczEgLSBPcHRpb24gZm9yIHBhdGguCisgKiAgICAgICAgICBJUFBSVFktIHNwZWNpZmllcyBpZiB5b3Ugd2FudCB0byBzZW5kIHByaW9yaXR5IG1lc3NhZ2UuIAorICogICAgICAgIGJ1ZmZlciAtIEFkZHJlc3Mgb2YgYXJyYXkgb2Ygc2VuZCBidWZmZXJzLiAgICAgICAgICAgICAgICAgIAorICogICAgICAgIGJ1ZmxlbiAtIFRvdGFsIGxlbmd0aCBvZiBzZW5kIGJ1ZmZlcnMuICAgICAgICAgICAgICAgICAgICAgIAorICogT3V0cHV0OiBtc2dpZCAtIFNwZWNpZmllcyB0aGUgbWVzc2FnZSBJRC4gICAgICAgICAgICAgICAgICAgICAgICAgCisgKiBSZXR1cm46IFJldHVybiBjb2RlIGZyb20gQ1AgSVVDViBjYWxsLiAgICAgICAgICAgICAgICAgICAgICAgICAKKyAqICAgICAgICAgKC1FSU5WQUwpIC0gQnVmZmVyIGFkZHJlc3MgaXMgTlVMTC4gICAgICAgICAgICAgICAgICAgICAgICAgICAgIAorKi8KK2ludCBpdWN2X3NlbmRfYXJyYXkgKHUxNiBwYXRoaWQsCisJCSAgICAgdTMyICogbXNnaWQsCisJCSAgICAgdTMyIHRyZ2NscywKKwkJICAgICB1MzIgc3JjY2xzLAorCQkgICAgIHUzMiBtc2d0YWcsCisJCSAgICAgaW50IGZsYWdzMSwgaXVjdl9hcnJheV90ICogYnVmZmVyLCB1bG9uZyBidWZsZW4pOworCisvKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAorICogTmFtZTogaXVjdl9zZW5kX3BybW1zZyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKKyAqIFB1cnBvc2U6IFRoaXMgZnVuY3Rpb24gdHJhbnNtaXRzIGRhdGEgdG8gYW5vdGhlciBhcHBsaWNhdGlvbi4gICAgICAgCisgKiAgICAgICAgICBQcm1tc2cgc3BlY2lmaWVzIHRoYXQgdGhlIDgtYnl0ZXMgb2YgZGF0YSBhcmUgdG8gYmUgbW92ZWQgIAorICogICAgICAgICAgaW50byB0aGUgcGFyYW1ldGVyIGxpc3QuIFRoaXMgaXMgYSBvbmUtd2F5IG1lc3NhZ2UgYW5kIHRoZSAKKyAqICAgICAgICAgIHJlY2VpdmVyIHdpbGwgbm90IHJlcGx5IHRvIHRoZSBtZXNzYWdlLiAgICAgICAgICAgICAgICAgICAgCisgKiBJbnB1dDogcGF0aGlkIC0gUGF0aCBpZGVudGlmaWNhdGlvbiBudW1iZXIuICAgICAgICAgICAgICAgICAgICAgICAgICAKKyAqICAgICAgICB0cmdjbHMgLSBTcGVjaWZpZXMgdGFyZ2V0IGNsYXNzLiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAorICogICAgICAgIHNyY2NscyAtIFNwZWNpZmllcyB0aGUgc291cmNlIG1lc3NhZ2UgY2xhc3MuICAgICAgICAgICAgICAgICAgCisgKiAgICAgICAgbXNndGFnIC0gU3BlY2lmaWVzIGEgdGFnIHRvIGJlIGFzc29jaWF0ZWQgd2l0aCB0aGUgbWVzc2FnZS4gICAKKyAqICAgICAgICBmbGFnczEgLSBPcHRpb24gZm9yIHBhdGguCisgKiAgICAgICAgICBJUFBSVFktIDB4MjAgc3BlY2lmaWVzIGlmIHlvdSB3YW50IHRvIHNlbmQgcHJpb3JpdHkgbWVzc2FnZS4KKyAqICAgICAgICBwcm1tc2cgLSA4LWJ5dGVzIG9mIGRhdGEgdG8gYmUgcGxhY2VkIGludG8gcGFyYW1ldGVyIGxpc3QuICAgIAorICogT3V0cHV0OiBtc2dpZCAtIFNwZWNpZmllcyB0aGUgbWVzc2FnZSBJRC4gICAgICAgICAgICAgICAgICAgICAgICAgICAKKyAqIFJldHVybjogUmV0dXJuIGNvZGUgZnJvbSBDUCBJVUNWIGNhbGwuICAgICAgICAgICAgICAgICAgICAgICAgICAgCisqLworaW50IGl1Y3Zfc2VuZF9wcm1tc2cgKHUxNiBwYXRoaWQsCisJCSAgICAgIHUzMiAqIG1zZ2lkLAorCQkgICAgICB1MzIgdHJnY2xzLAorCQkgICAgICB1MzIgc3JjY2xzLCB1MzIgbXNndGFnLCBpbnQgZmxhZ3MxLCB1Y2hhciBwcm1tc2dbOF0pOworCisvKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKKyAqIE5hbWU6IGl1Y3Zfc2VuZDJ3YXkgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAorICogUHVycG9zZTogVGhpcyBmdW5jdGlvbiB0cmFuc21pdHMgZGF0YSB0byBhbm90aGVyIGFwcGxpY2F0aW9uLiAgCisgKiAgICAgICAgICBEYXRhIHRvIGJlIHRyYW5zbWl0dGVkIGlzIGluIGEgYnVmZmVyLiBUaGUgcmVjZWl2ZXIgICAKKyAqICAgICAgICAgIG9mIHRoZSBzZW5kIGlzIGV4cGVjdGVkIHRvIHJlcGx5IHRvIHRoZSBtZXNzYWdlIGFuZCAgIAorICogICAgICAgICAgYSBidWZmZXIgaXMgcHJvdmlkZWQgaW50byB3aGljaCBJVUNWIG1vdmVzIHRoZSByZXBseSAgCisgKiAgICAgICAgICB0byB0aGlzIG1lc3NhZ2UuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKKyAqIElucHV0OiBwYXRoaWQgLSBQYXRoIGlkZW50aWZpY2F0aW9uIG51bWJlci4gICAgICAgICAgICAgICAgICAgICAKKyAqICAgICAgICB0cmdjbHMgLSBTcGVjaWZpZXMgdGFyZ2V0IGNsYXNzLiAgICAgICAgICAgICAgICAgICAgICAgICAKKyAqICAgICAgICBzcmNjbHMgLSBTcGVjaWZpZXMgdGhlIHNvdXJjZSBtZXNzYWdlIGNsYXNzLiAgICAgICAgICAgICAKKyAqICAgICAgICBtc2d0YWcgLSBTcGVjaWZpZXMgYSB0YWcgYXNzb2NpYXRlZCB3aXRoIHRoZSBtZXNzYWdlLiAgICAKKyAqICAgICAgICBmbGFnczEgLSBPcHRpb24gZm9yIHBhdGguCisgKiAgICAgICAgICBJUFBSVFktIDB4MjAgU3BlY2lmaWVzIGlmIHlvdSB3YW50IHRvIHNlbmQgcHJpb3JpdHkgbWVzc2FnZS4KKyAqICAgICAgICBidWZmZXIgLSBBZGRyZXNzIG9mIHNlbmQgYnVmZmVyLiAgICAgICAgICAgICAgICAgICAgICAgICAKKyAqICAgICAgICBidWZsZW4gLSBMZW5ndGggb2Ygc2VuZCBidWZmZXIuICAgICAgICAgICAgICAgICAgICAgICAgICAKKyAqICAgICAgICBhbnNidWYgLSBBZGRyZXNzIG9mIGJ1ZmZlciBpbnRvIHdoaWNoIElVQ1YgbW92ZXMgdGhlIHJlcGx5IG9mIAorICogICAgICAgICAgICAgICAgIHRoaXMgbWVzc2FnZS4gICAgICAgIAorICogICAgICAgIGFuc2xlbiAtIEFkZHJlc3Mgb2YgbGVuZ3RoIG9mIGJ1ZmZlci4gICAgICAgICAgCisgKiBPdXRwdXQ6IG1zZ2lkIC0gU3BlY2lmaWVzIHRoZSBtZXNzYWdlIElELiAgICAgICAgICAgICAgICAgICAgICAKKyAqIFJldHVybjogUmV0dXJuIGNvZGUgZnJvbSBDUCBJVUNWIGNhbGwuICAgICAgICAgICAgICAgICAgICAgIAorICogICAgICAgICAoLUVJTlZBTCkgLSBCdWZmZXIgb3IgYW5zYnVmIGFkZHJlc3MgaXMgTlVMTC4gICAgCisqLworaW50IGl1Y3Zfc2VuZDJ3YXkgKHUxNiBwYXRoaWQsCisJCSAgIHUzMiAqIG1zZ2lkLAorCQkgICB1MzIgdHJnY2xzLAorCQkgICB1MzIgc3JjY2xzLAorCQkgICB1MzIgbXNndGFnLAorCQkgICBpbnQgZmxhZ3MxLAorCQkgICB2b2lkICpidWZmZXIsIHVsb25nIGJ1Zmxlbiwgdm9pZCAqYW5zYnVmLCB1bG9uZyBhbnNsZW4pOworCisvKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCisgKiBOYW1lOiBpdWN2X3NlbmQyd2F5X2FycmF5ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCisgKiBQdXJwb3NlOiBUaGlzIGZ1bmN0aW9uIHRyYW5zbWl0cyBkYXRhIHRvIGFub3RoZXIgYXBwbGljYXRpb24uICAgICAgCisgKiAgICAgICAgICBUaGUgY29udGVudHMgb2YgYnVmZmVyIGlzIHRoZSBhZGRyZXNzIG9mIHRoZSBhcnJheSBvZiAgICAgCisgKiAgICAgICAgICBhZGRyZXNzZXMgYW5kIGxlbmd0aHMgb2YgZGlzY29udGlndW91cyBidWZmZXJzIHRoYXQgaG9sZCAgCisgKiAgICAgICAgICB0aGUgbWVzc2FnZSB0ZXh0LiBUaGUgcmVjZWl2ZXIgb2YgdGhlIHNlbmQgaXMgZXhwZWN0ZWQgdG8gCisgKiAgICAgICAgICByZXBseSB0byB0aGUgbWVzc2FnZSBhbmQgYSBidWZmZXIgaXMgcHJvdmlkZWQgaW50byB3aGljaCAgCisgKiAgICAgICAgICBJVUNWIG1vdmVzIHRoZSByZXBseSB0byB0aGlzIG1lc3NhZ2UuICAgICAgICAgICAgICAgICAgICAgCisgKiBJbnB1dDogcGF0aGlkIC0gUGF0aCBpZGVudGlmaWNhdGlvbiBudW1iZXIuICAgICAgICAgICAgICAgICAgICAgICAgIAorICogICAgICAgIHRyZ2NscyAtIFNwZWNpZmllcyB0YXJnZXQgY2xhc3MuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKKyAqICAgICAgICBzcmNjbHMgLSBTcGVjaWZpZXMgdGhlIHNvdXJjZSBtZXNzYWdlIGNsYXNzLiAgICAgICAgICAgICAgICAgCisgKiAgICAgICAgbXNndGFnIC0gU3BlY2lmaWVzIGEgdGFnIHRvIGJlIGFzc29jaWF0ZWQgd2l0aCB0aGUgbWVzc2FnZS4gICAKKyAqICAgICAgICBmbGFnczEgLSBPcHRpb24gZm9yIHBhdGguCisgKiAgICAgICAgICBJUFBSVFktIDB4MjAgU3BlY2lmaWVzIGlmIHlvdSB3YW50I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ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKKyAqIE5hbWU6IGl1Y3Zfc2VuZDJ3YXlfcHJtbXNnICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCisgKiBQdXJwb3NlOiBUaGlzIGZ1bmN0aW9uIHRyYW5zbWl0cyBkYXRhIHRvIGFub3RoZXIgYXBwbGljYXRpb24uICAgICAgIAorICogICAgICAgICAgUHJtbXNnIHNwZWNpZmllcyB0aGF0IHRoZSA4LWJ5dGVzIG9mIGRhdGEgYXJlIHRvIGJlIG1vdmVkICAKKyAqICAgICAgICAgIGludG8gdGhlIHBhcmFtZXRlciBsaXN0LiBUaGlzIGlzIGEgdHdvLXdheSBtZXNzYWdlIGFuZCB0aGUgCisgKiAgICAgICAgICByZWNlaXZlciBvZiB0aGUgbWVzc2FnZSBpcyBleHBlY3RlZCB0byByZXBseS4gQSBidWZmZXIgICAgIAorICogICAgICAgICAgaXMgcHJvdmlkZWQgaW50byB3aGljaCBJVUNWIG1vdmVzIHRoZSByZXBseSB0byB0aGlzICAgICAgICAKKyAqICAgICAgICAgIG1lc3NhZ2UuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCisgKiBJbnB1dDogcGF0aGlkIC0gUmF0aCBpZGVudGlmaWNhdGlvbiBudW1iZXIuICAgICAgICAgICAgICAgICAgICAgICAgICAKKyAqICAgICAgICB0cmdjbHMgLSBTcGVjaWZpZXMgdGFyZ2V0IGNsYXNzLiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAorICogICAgICAgIHNyY2NscyAtIFNwZWNpZmllcyB0aGUgc291cmNlIG1lc3NhZ2UgY2xhc3MuICAgICAgICAgICAgICAgICAgCisgKiAgICAgICAgbXNndGFnIC0gU3BlY2lmaWVzIGEgdGFnIHRvIGJlIGFzc29jaWF0ZWQgd2l0aCB0aGUgbWVzc2FnZS4gICAKKyAqICAgICAgICBmbGFnczEgLSBPcHRpb24gZm9yIHBhdGguCisgKiAgICAgICAgICBJUFBSVFktIDB4MjAgU3BlY2lmaWVzIGlmIHlvdSB3YW50IHRvIHNlbmQgcHJpb3JpdHkgbWVzc2FnZS4KKyAqICAgICAgICBwcm1tc2cgLSA4LWJ5dGVzIG9mIGRhdGEgdG8gYmUgcGxhY2VkIGluIHBhcmFtZXRlciBsaXN0LiAgICAgIAorICogICAgICAgIGFuc2J1ZiAtIEFkZHJlc3Mgb2YgYnVmZmVyIGludG8gd2hpY2ggSVVDViBtb3ZlcyB0aGUgcmVwbHkgb2YgICAgCisgKiAgICAgICAgICAgICAgICAgdGhpcyBtZXNzYWdlLgorICogICAgICAgIGFuc2xlbiAtIEFkZHJlc3Mgb2YgbGVuZ3RoIG9mIGJ1ZmZlci4gICAgICAgICAgICAgICAKKyAqIE91dHB1dDogbXNnaWQgLSBTcGVjaWZpZXMgdGhlIG1lc3NhZ2UgSUQuICAgICAgICAgICAgICAgICAgICAgICAgICAgCisgKiBSZXR1cm46IFJldHVybiBjb2RlIGZyb20gQ1AgSVVDViBjYWxsLiAgICAgICAgICAgICAgICAgICAgICAgICAgIAorICogICAgICAgICAoLUVJTlZBTCkgLSBCdWZmZXIgYWRkcmVzcyBpcyBOVUxMLiAgICAgICAgIAorKi8KK2ludCBpdWN2X3NlbmQyd2F5X3BybW1zZyAodTE2IHBhdGhpZCwKKwkJCSAgdTMyICogbXNnaWQsCisJCQkgIHUzMiB0cmdjbHMsCisJCQkgIHUzMiBzcmNjbHMsCisJCQkgIHUzMiBtc2d0YWcsCisJCQkgIHVsb25nIGZsYWdzMSwKKwkJCSAgdWNoYXIgcHJtbXNnWzhdLCB2b2lkICphbnNidWYsIHVsb25nIGFuc2xlbik7CisKKy8qICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAorICogTmFtZTogaXVjdl9zZW5kMndheV9wcm1tc2dfYXJyYXkgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCisgKiBQdXJwb3NlOiBUaGlzIGZ1bmN0aW9uIHRyYW5zbWl0cyBkYXRhIHRvIGFub3RoZXIgYXBwbGljYXRpb24uICAgICAgICAKKyAqICAgICAgICAgIFBybW1zZyBzcGVjaWZpZXMgdGhhdCB0aGUgOC1ieXRlcyBvZiBkYXRhIGFyZSB0byBiZSBtb3ZlZCAgIAorICogICAgICAgICAgaW50byB0aGUgcGFyYW1ldGVyIGxpc3QuIFRoaXMgaXMgYSB0d28td2F5IG1lc3NhZ2UgYW5kIHRoZSAgCisgKiAgICAgICAgICByZWNlaXZlciBvZiB0aGUgbWVzc2FnZSBpcyBleHBlY3RlZCB0byByZXBseS4gQSBidWZmZXIgICAgICAKKyAqICAgICAgICAgIGlzIHByb3ZpZGVkIGludG8gd2hpY2ggSVVDViBtb3ZlcyB0aGUgcmVwbHkgdG8gdGhpcyAgICAgICAgIAorICogICAgICAgICAgbWVzc2FnZS4gVGhlIGNvbnRlbnRzIG9mIGFuc2J1ZiBpcyB0aGUgYWRkcmVzcyBvZiB0aGUgICAgICAgCisgKiAgICAgICAgICBhcnJheSBvZiBhZGRyZXNzZXMgYW5kIGxlbmd0aHMgb2YgZGlzY29udGlndW91cyBidWZmZXJzICAgICAKKyAqICAgICAgICAgIHRoYXQgY29udGFpbiB0aGUgcmVwbHkuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAorICogSW5wdXQ6IHBhdGhpZCAtIFBhdGggaWRlbnRpZmljYXRpb24gbnVtYmVyLiAgICAgICAgICAgICAgICAgICAgICAgICAgIAorICogICAgICAgIHRyZ2NscyAtIFNwZWNpZmllcyB0YXJnZXQgY2xhc3MuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAorICogICAgICAgIHNyY2NscyAtIFNwZWNpZmllcyB0aGUgc291cmNlIG1lc3NhZ2UgY2xhc3MuICAgICAgICAgICAgICAgICAgIAorICogICAgICAgIG1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gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKKyAqIE5hbWU6IGl1Y3Zfc2V0bWFzayAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAorICogUHVycG9zZTogVGhpcyBmdW5jdGlvbiBlbmFibGVzIG9yIGRpc2FibGVzIHRoZSBmb2xsb3dpbmcgSVVDViAgICAgCisgKiAgICAgICAgICBleHRlcm5hbCBpbnRlcnJ1cHRpb25zOiBOb25wcmlvcml0eSBhbmQgcHJpb3JpdHkgbWVzc2FnZSAKKyAqICAgICAgICAgIGludGVycnVwdHMsIG5vbnByaW9yaXR5IGFuZCBwcmlvcml0eSByZXBseSBpbnRlcnJ1cHRzLiAgIAorICogSW5wdXQ6IFNldE1hc2tGbGFnIC0gb3B0aW9ucyBmb3IgaW50ZXJydXB0cworICogICAgICAgICAgIDB4ODAgLSBOb25wcmlvcml0eV9NZXNzYWdlUGVuZGluZ0ludGVycnVwdHNGbGFnICAgICAgICAgCisgKiAgICAgICAgICAgMHg0MCAtIFByaW9yaXR5X01lc3NhZ2VQZW5kaW5nSW50ZXJydXB0c0ZsYWcgICAgICAgICAgICAKKyAqICAgICAgICAgICAweDIwIC0gTm9ucHJpb3JpdHlfTWVzc2FnZUNvbXBsZXRpb25JbnRlcnJ1cHRzRmxhZyAgICAgIAorICogICAgICAgICAgIDB4MTAgLSBQcmlvcml0eV9NZXNzYWdlQ29tcGxldGlvbkludGVycnVwdHNGbGFnICAgICAgICAgCisgKiAgICAgICAgICAgMHgwOCAtIElVQ1ZDb250cm9sSW50ZXJydXB0c0ZsYWcKKyAqIE91dHB1dDogTkEgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAorICogUmV0dXJuOiBSZXR1cm4gY29kZSBmcm9tIENQIElVQ1YgY2FsbC4gICAgICAgICAgICAgICAgICAgICAgICAgCisqLworaW50IGl1Y3Zfc2V0bWFzayAoaW50IFNldE1hc2tGbGFnKTsKKworLyogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAorICogTmFtZTogaXVjdl9zZXZlciAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAorICogUHVycG9zZTogVGhpcyBmdW5jdGlvbiB0ZXJtaW5hdGVzIGFuIElVQ1YgcGF0aC4gIAorICogSW5wdXQ6IHBhdGhpZCAtIFBhdGggaWRlbnRpZmljYXRpb24gbnVtYmVyLiAgICAgICAKKyAqICAgICAgICB1c2VyX2RhdGEgLSAxNi1ieXRlcyBvZiB1c2VyIGRhdGEuICAgICAgICAgCisgKiBPdXRwdXQ6IE5BICAgICAgIAorICogUmV0dXJuOiBSZXR1cm4gY29kZSBmcm9tIENQIElVQ1YgY2FsbC4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAorICogICAgICAgICAoLUVJTlZBTCkgLSBJbnRlcmFsIGVycm9yLCB3aWxkIHBvaW50ZXIuICAgICAgIAorKi8KK2ludCBpdWN2X3NldmVyICh1MTYgcGF0aGlkLCB1Y2hhciB1c2VyX2RhdGFbMTZdKTsKZGlmZiAtLWdpdCBhL2RyaXZlcnMvczM5MC9uZXQvbGNzLmMgYi9kcml2ZXJzL3MzOTAvbmV0L2xjcy5jCm5ldyBmaWxlIG1vZGUgMTAwNjQ0CmluZGV4IDAwMDAwMDAuLjBmNzZlOTQKLS0tIC9kZXYvbnVsbAorKysgYi9kcml2ZXJzL3MzOTAvbmV0L2xjcy5jCkBAIC0wLDAgKzEsMjM0NyBAQAorLyoKKyAqICBsaW51eC9kcml2ZXJzL3MzOTAvbmV0L2xjcy5jCisgKgorICogIExpbnV4IGZvciBTLzM5MCBMYW4gQ2hhbm5lbCBTdGF0aW9uIE5ldHdvcmsgRHJpdmVyCisgKgorICogIENvcHlyaWdodCAoQykgIDE5OTktMjAwMSBJQk0gRGV1dHNjaGxhbmQgRW50d2lja2x1bmcgR21iSCwKKyAqCQkJICAgICBJQk0gQ29ycG9yYXRp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G9jaywgZmxhZ3MpOworICAgICAgICByZXR1cm4gMDsKK30KKworc3RhdGljIHZvaWQKK2xjc19jbGVhcl90aHJlYWRfcnVubmluZ19iaXQoc3RydWN0IGxjc19jYXJkICpjYXJkLCB1bnNpZ25lZCBsb25nIHRocmVhZCkKK3sKKyAgICAgICAgdW5zaWduZWQgbG9uZyBmbGFnczsKKworCXNwaW5fbG9ja19pcnFzYXZlKCZjYXJkLT5tYXNrX2xvY2ssIGZsYWdzKTsKKyAgICAgICAgY2FyZC0+dGhyZWFkX3J1bm5pbmdfbWFzayAmPSB+dGhyZWFkOworCXNwaW5fdW5sb2NrX2lycXJlc3RvcmUoJmNhcmQtPm1hc2tfbG9jaywgZmxhZ3MpOworICAgICAgICB3YWtlX3VwKCZjYXJkLT53YWl0X3EpOworfQorCitzdGF0aWMgaW5saW5lIGludAorX19sY3NfZG9fcnVuX3RocmVhZChzdHJ1Y3QgbGNzX2NhcmQgKmNhcmQsIHVuc2lnbmVkIGxvbmcgdGhyZWFkKQoreworICAgICAgICB1bnNpZ25lZCBsb25nIGZsYWdzOworICAgICAgICBpbnQgcmMgPSAwOworCisJc3Bpbl9sb2NrX2lycXNhdmUoJmNhcmQtPm1hc2tfbG9jaywgZmxhZ3MpOworICAgICAgICBpZiAoY2FyZC0+dGhyZWFkX3N0YXJ0X21hc2sgJiB0aHJlYWQpeworICAgICAgICAgICAgICAgIGlmICgoY2FyZC0+dGhyZWFkX2FsbG93ZWRfbWFzayAmIHRocmVhZCkgJiYKKyAgICAgICAgICAgICAgICAgICAgIShjYXJkLT50aHJlYWRfcnVubmluZ19tYXNrICYgdGhyZWFkKSl7CisgICAgICAgICAgICAgICAgICAgICAgICByYyA9IDE7CisgICAgICAgICAgICAgICAgICAgICAgICBjYXJkLT50aHJlYWRfc3RhcnRfbWFzayAmPSB+dGhyZWFkOworICAgICAgICAgICAgICAgICAgICAgICAgY2FyZC0+dGhyZWFkX3J1bm5pbmdfbWFzayB8PSB0aHJlYWQ7CisgICAgICAgICAgICAgICAgfSBlbHNlCisgICAgICAgICAgICAgICAgICAgICAgICByYyA9IC1FUEVSTTsKKyAgICAgICAgfQorCXNwaW5fdW5sb2NrX2lycXJlc3RvcmUoJmNhcmQtPm1hc2tfbG9jaywgZmxhZ3MpOworICAgICAgICByZXR1cm4gcmM7Cit9CisKK3N0YXRpYyBpbnQKK2xjc19kb19ydW5fdGhyZWFkKHN0cnVjdCBsY3NfY2FyZCAqY2FyZCwgdW5zaWduZWQgbG9uZyB0aHJlYWQpCit7CisgICAgICAgIGludCByYyA9IDA7CisgICAgICAgIHdhaXRfZXZlbnQoY2FyZC0+d2FpdF9xLAorICAgICAgICAgICAgICAgICAgIChyYyA9IF9fbGNzX2RvX3J1bl90aHJlYWQoY2FyZCwgdGhyZWFkKSkgPj0gMCk7CisgICAgICAgIHJldHVybiByYzsKK30KKworc3RhdGljIGludAorbGNzX2RvX3N0YXJ0X3RocmVhZChzdHJ1Y3QgbGNzX2NhcmQgKmNhcmQsIHVuc2lnbmVkIGxvbmcgdGhyZWFkKQoreworICAgICAgICB1bnNpZ25lZCBsb25nIGZsYWdzOworICAgICAgICBpbnQgcmMgPSAwOworCisJc3Bpbl9sb2NrX2lycXNhdmUoJmNhcmQtPm1hc2tfbG9jaywgZmxhZ3MpOworICAgICAgICBMQ1NfREJGX1RFWFRfKDQsIHRyYWNlLCAiICAlMDJ4JTAyeCUwMngiLAorICAgICAgICAgICAgICAgICAgICAgICAgKHU4KSBjYXJkLT50aHJlYWRfc3RhcnRfbWFzaywKKyAgICAgICAgICAgICAgICAgICAgICAgICh1OCkgY2FyZC0+dGhyZWFkX2FsbG93ZWRfbWFzaywKKyAgICAgICAgICAgICAgICAgICAgICAgICh1OCkgY2FyZC0+dGhyZWFkX3J1bm5pbmdfbWFzayk7CisgICAgICAgIHJjID0gKGNhcmQtPnRocmVhZF9zdGFydF9tYXNrICYgdGhyZWFkKTsKKwlzcGluX3VubG9ja19pcnFyZXN0b3JlKCZjYXJkLT5tY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NfSU5JVElBVE9SX1RDUElQKTsKKwlpZiAocmMgPT0gMCkKKwkJcmV0dXJuIDA7CisjZW5kaWYKKyNpZmRlZiBDT05GSUdfRkRESQorCWNhcmQtPmxhbl90eXBlID0gTENTX0ZSQU1FX1RZUEVfRkRESTsKKwlyYyA9IGxjc19zZW5kX3N0YXJ0bGFuKGNhcmQsIExDU19JTklUSUFUT1JfVENQSVApOworCWlmIChyYyA9PSAwKQorCQlyZXR1cm4gMDsKKyNlbmRpZgorCXJldHVybiAtRUlPOworfQorCitzdGF0aWMgaW50CitsY3Nfc3RhcnRsYW4oc3RydWN0IGxjc19jYXJkICpjYXJkKQoreworCWludCByYywgaTsKKworCUxDU19EQkZfVEVYVCgyLCB0cmFjZSwgInN0YXJ0bGFuIik7CisJcmMgPSAwOworCWlmIChjYXJkLT5wb3J0bm8gIT0gTENTX0lOVkFMSURfUE9SVF9OTykgeworCQlpZiAoY2FyZC0+bGFuX3R5cGUgPT0gTENTX0ZSQU1FX1RZUEVfQVVUTykKKwkJCXJjID0gbGNzX3N0YXJ0bGFuX2F1dG8oY2FyZCk7CisJCWVsc2UKKwkJCXJjID0gbGNzX3NlbmRfc3RhcnRsYW4oY2FyZCwgTENTX0lOSVRJQVRPUl9UQ1BJUCk7CisJfSBlbHNlIHsKKyAgICAgICAgICAgICAgICBmb3IgKGkgPSAwOyBpIDw9IDE2OyBpKyspIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIGNhcmQtPnBvcnRubyA9IGk7CisgICAgICAgICAgICAgICAgICAgICAgICBpZiAoY2FyZC0+bGFuX3R5cGUgIT0gTENTX0ZSQU1FX1RZUEVfQVVUTykKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmMgPSBsY3Nfc2VuZF9zdGFydGxhbihjYXJkLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIExDU19JTklUSUFUT1JfVENQSVApOworICAgICAgICAgICAgICAgICAgICAgICAgZWxzZQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvKiBhdXRvZGV0ZWN0aW5nIGxhbiB0eXBlICovCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJjID0gbGNzX3N0YXJ0bGFuX2F1dG8oY2FyZCk7CisgICAgICAgICAgICAgICAgICAgICAgICBpZiAocmMgPT0gMCkKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgICAgfQorICAgICAgICB9CisJaWYgKHJjID09IDApCisJCXJldHVybiBsY3Nfc2VuZF9sYW5zdGF0KGNhcmQpOworCXJldHVybiByYzsKK30KKworLyoqCisgKiBMQ1MgZGV0ZWN0IGZ1bmN0aW9uCisgKiBzZXR1cCBjaGFubmVscyBhbmQgbWFrZSB0aGVtIEkvTyByZWFkeQorICovCitzdGF0aWMgaW50CitsY3NfZGV0ZWN0KHN0cnVjdCBsY3NfY2FyZCAqY2FyZCkKK3sKKwlpbnQgcmMgPSAwOworCisJTENTX0RCRl9URVhUKDIsIHNldHVwLCAibGNzZGV0Y3QiKTsKKwkvKiBzdGFydC9yZXNldCBjYXJkICovCisJaWYgKGNhcmQtPmRldikKKwkJbmV0aWZfc3RvcF9xdWV1ZShjYXJkLT5kZXYpOworCXJjID0gbGNzX3N0b3BfY2hhbm5lbHMoY2FyZCk7CisJaWYgKHJjID09IDApIHsKKwkJcmMgPSBsY3Nfc3RhcnRfY2hhbm5lbHMoY2FyZCk7CisJCWlmIChyYyA9PSAwKSB7CisJCQlyYyA9IGxjc19zZW5kX3N0YXJ0dXAoY2FyZCwgTENTX0lOSVRJQVRPUl9UQ1BJUCk7CisJCQlpZiAocmMgPT0gMCkKKwkJCQlyYyA9IGxjc19zdGFydGxhbihjYXJkKTsKKwkJfQorCX0KKwlpZiAocmMgPT0gMCkgeworCQljYXJkLT5zdGF0ZSA9IERFVl9TVEFURV9VUDsKKwl9IGVsc2UgeworCQljYXJkLT5zdGF0ZSA9IERFVl9T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1Ziwgc2l6ZV90IGNvdW50KQoreworICAgICAgICBzdHJ1Y3QgbGNzX2NhcmQgKmNhcmQ7CisgICAgICAgIGludCB2YWx1ZTsKKworCWNhcmQgPSAoc3RydWN0IGxjc19jYXJkICopZGV2LT5kcml2ZXJfZGF0YTsKKworICAgICAgICBpZiAoIWNhcmQpCisgICAgICAgICAgICAgICAgcmV0dXJuIDA7CisKKyAgICAgICAgc3NjYW5mKGJ1ZiwgIiV1IiwgJnZhbHVlKTsKKyAgICAgICAgLyogVE9ETzogc2FuaXR5IGNoZWNrcyAqLworICAgICAgICBjYXJkLT5wb3J0bm8gPSB2YWx1ZTsKKworICAgICAgICByZXR1cm4gY291bnQ7CisKK30KKworc3RhdGljIERFVklDRV9BVFRSKHBvcnRubywgMDY0NCwgbGNzX3BvcnRub19zaG93LCBsY3NfcG9ydG5vX3N0b3JlKTsKKworc3RhdGljIHNzaXplX3QKK2xjc190eXBlX3Nob3coc3RydWN0IGRldmljZSAqZGV2LCBjaGFyICpidWYpCit7CisJc3RydWN0IGNjd2dyb3VwX2RldmljZSAqY2dkZXY7CisKKwljZ2RldiA9IHRvX2Njd2dyb3VwZGV2KGRldik7CisJaWYgKCFjZ2RldikKKwkJcmV0dXJuIC1FTk9ERVY7CisKKwlyZXR1cm4gc3ByaW50ZihidWYsICIlc1xuIiwgY3UzMDg4X3R5cGVbY2dkZXYtPmNkZXZbMF0tPmlkLmRyaXZlcl9pbmZvXSk7Cit9CisKK3N0YXRpYyBERVZJQ0VfQVRUUih0eXBlLCAwNDQ0LCBsY3NfdHlwZV9zaG93LCBOVUxMKTsKKworc3RhdGljIHNzaXplX3QKK2xjc190aW1lb3V0X3Nob3coc3RydWN0IGRldmljZSAqZGV2LCBjaGFyICpidWYpCit7CisJc3RydWN0IGxjc19jYXJkICpjYXJkOworCisJY2FyZCA9IChzdHJ1Y3QgbGNzX2NhcmQgKilkZXYtPmRyaXZlcl9kYXRhOworCisJcmV0dXJuIGNhcmQgPyBzcHJpbnRmKGJ1ZiwgIiV1XG4iLCBjYXJkLT5sYW5jbWRfdGltZW91dCkgOiAwOworfQorCitzdGF0aWMgc3NpemVfdAorbGNzX3RpbWVvdXRfc3RvcmUgKHN0cnVjdCBkZXZpY2UgKmRldiwgY29uc3QgY2hhciAqYnVmLCBzaXplX3QgY291bnQpCit7CisgICAgICAgIHN0cnVjdCBsY3NfY2FyZCAqY2FyZDsKKyAgICAgICAgaW50IHZhbHVlOworCisJY2FyZCA9IChzdHJ1Y3QgbGNzX2NhcmQgKilkZXYtPmRyaXZlcl9kYXRhOworCisgICAgICAgIGlmICghY2FyZCkKKyAgICAgICAgICAgICAgICByZXR1cm4gMDsKKworICAgICAgICBzc2NhbmYoYnVmLCAiJXUiLCAmdmFsdWUpOworICAgICAgICAvKiBUT0RPOiBzYW5pdHkgY2hlY2tzICovCisgICAgICAgIGNhcmQtPmxhbmNtZF90aW1lb3V0ID0gdmFsdWU7CisKKyAgICAgICAgcmV0dXJuIGNvdW50OworCit9CisKK0RFVklDRV9BVFRSKGxhbmNtZF90aW1lb3V0LCAwNjQ0LCBsY3NfdGltZW91dF9zaG93LCBsY3NfdGltZW91dF9zdG9yZSk7CisKK3N0YXRpYyBzdHJ1Y3QgYXR0cmlidXRlICogbGNzX2F0dHJzW10gPSB7CisJJmRldl9hdHRyX3BvcnRuby5hdHRyLAorCSZkZXZfYXR0cl90eXBlLmF0dHIsCisJJmRldl9hdHRyX2xhbmNtZF90aW1lb3V0LmF0dHIsCisJTlVMTCwKK307CisKK3N0YXRpYyBzdHJ1Y3QgYXR0cmlidXRlX2dyb3VwIGxjc19hdHRyX2dyb3VwID0geworCS5hdHRycyA9IGxjc19hdHRycywKK307CisKKy8qKgorICogbGNzX3Byb2JlX2RldmljZSBpcyBjYWxsZWQgb24gZXN0YWJsaXNoaW5nIGEgbmV3IGNjd2dyb3VwX2RldmljZS4KKyAqLworc3RhdGljIGludAorbGNzX3Byb2JlX2RldmljZShzdHJ1Y3QgY2N3Z3JvdXB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vbGxlY3RfbG9jazsKKwlpbnQgICAgICAgICAgICAgICAgICAgICAgIGNvbGxlY3RfbGVuOworCWludCAgICAgICAgICAgICAgICAgICAgICAgbWF4X2J1ZmZzaXplOworCWZzbV90aW1lciAgICAgICAgICAgICAgICAgdGltZXI7CisJZnNtX2luc3RhbmNlICAgICAgICAgICAgICAqZnNtOworCXN0cnVjdCBuZXRfZGV2aWNlICAgICAgICAgKm5ldGRldjsKKwlzdHJ1Y3QgY29ubmVjdGlvbl9wcm9maWxlIHByb2Y7CisJY2hhciAgICAgICAgICAgICAgICAgICAgICB1c2VyaWRbOV07Cit9OworCisvKioKKyAqIExpbmtlZCBsaXN0IG9mIGFsbCBjb25uZWN0aW9uIHN0cnVjdHMuCisgKi8KK3N0YXRpYyBzdHJ1Y3QgaXVjdl9jb25uZWN0aW9uICppdWN2X2Nvbm5lY3Rpb25zOworCisvKioKKyAqIFJlcHJlc2VudGF0aW9uIG9mIGV2ZW50LWRhdGEgZm9yIHRoZQorICogY29ubmVjdGlvbiBzdGF0ZSBtYWNoaW5lLgorICovCitzdHJ1Y3QgaXVjdl9ldmVudCB7CisJc3RydWN0IGl1Y3ZfY29ubmVjdGlvbiAqY29ubjsKKwl2b2lkICAgICAgICAgICAgICAgICAgICpkYXRhOworfTsKKworLyoqCisgKiBQcml2YXRlIHBhcnQgb2YgdGhlIG5ldHdvcmsgZGV2aWNlIHN0cnVjdHVyZQorICovCitzdHJ1Y3QgbmV0aXVjdl9wcml2IHsKKwlzdHJ1Y3QgbmV0X2RldmljZV9zdGF0cyBzdGF0czsKKwl1bnNpZ25lZCBsb25nICAgICAgICAgICB0YnVzeTsKKwlmc21faW5zdGFuY2UgICAgICAgICAgICAqZnNtOworICAgICAgICBzdHJ1Y3QgaXVjdl9jb25uZWN0aW9uICAqY29ubjsKKwlzdHJ1Y3QgZGV2aWNlICAgICAgICAgICAqZGV2OworfTsKKworLyoqCisgKiBMaW5rIGxldmVsIGhlYWRlciBmb3IgYSBwYWNrZX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CWlmIChjb3BpZWQpCisJCQkJZGV2X2tmcmVlX3NrYihuc2tiKTsKKwkJCWVsc2UgeworCQkJCS8qKgorCQkJCSAqIFJlbW92ZSBvdXIgaGVhZGVycy4gVGhleSBnZXQgYWRkZWQKKwkJCQkgKiBhZ2FpbiBvbiByZXRyYW5zbWl0LgorCQkJCSAqLworCQkJCXNrYl9wdWxsKHNrYiwgTkVUSVVDVl9IRFJMRU4pOworCQkJCXNrYl90cmltKHNrYiwgc2tiLT5sZW4gLSBORVRJVUNWX0hEUkxFTik7CisJCQl9CisJCQlQUklOVF9XQVJOKCJpdWN2X3NlbmQgcmV0dXJuZWQgJTA4eFxuIiwJcmMpOworCQkJSVVDVl9EQkZfVEVYVF8oZGF0YSwgMiwgInJjICVkIGZyb20gaXVjdl9zZW5kXG4iLCByYyk7CisJCX0gZWxzZSB7CisJCQlpZiAoY29waWVkKQorCQkJCWRldl9rZnJlZV9za2Ioc2tiKTsKKwkJCWF0b21pY19pbmMoJm5za2ItPnVzZXJzKTsKKwkJCXNrYl9xdWV1ZV90YWlsKCZjb25uLT5jb21taXRfcXVldWUsIG5za2IpOworCQl9CisJfQorCisJcmV0dXJuIHJjOworfQorDAorLyoqCisgKiBJbnRlcmZhY2UgQVBJIGZvciB1cHBlciBuZXR3b3JrIGxheWVycworICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworCisvKioKKyAqIE9wZW4gYW4gaW50ZXJmYWNlLgorICogQ2FsbGVkIGZyb20gZ2VuZXJpYyBuZXR3b3JrIGxheWVyIHdoZW4gaWZjb25maWcgdXAgaXMgcnVuLgorICoKKyAqIEBwYXJhbSBkZXYgUG9pbnRlciB0byBpbnRlcmZhY2Ugc3RydWN0LgorICoKKyAqIEByZXR1cm4gMCBvbiBzdWNjZXNzLCAtRVJSTk8gb24gZmFpbHVyZS4gKE5ldmVyIGZhaWxzLikKKyAqLworc3RhdGljIGlud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itvdXRfZnJlZV9uZGV2OgorCVBSSU5UX1dBUk4oIm5ldGl1Y3Y6IENvdWxkIG5vdCByZWdpc3RlciAnJXMnXG4iLCBkZXYtPm5hbWUpOworCUlVQ1ZfREJGX1RFWFQoc2V0dXAsIDIsICJjb25uX3dyaXRlOiBjb3VsZCBub3QgcmVnaXN0ZXJcbiIpOworCW5ldGl1Y3ZfZnJlZV9uZXRkZXZpY2UoZGV2KTsKKwlyZXR1cm4gcmV0OworfQorCitEUklWRVJfQVRUUihjb25uZWN0aW9uLCAwMjAwLCBOVUxMLCBjb25uX3dyaXRlKTsKKworc3RhdGljIHNzaXplX3QKK3JlbW92ZV93cml0ZSAoc3RydWN0IGRldmljZV9kcml2ZXIgKmRydiwgY29uc3QgY2hhciAqYnVmLCBzaXplX3QgY291bnQpCit7CisJc3RydWN0IGl1Y3ZfY29ubmVjdGlvbiAqKmNsaXN0ID0gJml1Y3ZfY29ubmVjdGlvbnM7CisgICAgICAgIHN0cnVjdCBuZXRfZGV2aWNlICpuZGV2OworICAgICAgICBzdHJ1Y3QgbmV0aXVjdl9wcml2ICpwcml2OworICAgICAgICBzdHJ1Y3QgZGV2aWNlICpkZXY7CisgICAgICAgIGNoYXIgbmFtZVtJRk5BTVNJWl07CisgICAgICAgIGNoYXIgKnA7CisgICAgICAgIGludCBpOworCisgICAgICAgIElVQ1ZfREJGX1RFWFQodHJhY2UsIDMsIF9fRlVOQ1RJT05fXyk7CisKKyAgICAgICAgaWYgKGNvdW50ID49IElGTkFNU0laKQorICAgICAgICAgICAgICAgIGNvdW50ID0gSUZOQU1TSVotMTsKKworICAgICAgICBmb3IgKGk9MCwgcD0oY2hhciAqKWJ1ZjsgaTxjb3VudCAmJiAqcDsgaSsrLCBwKyspIHsKKyAgICAgICAgICAgICAgICBpZiAoKCpwID09ICdcbicpIHwgKCpwID09ICcgJykpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIC8qIHRyYWlsaW5nIGxmLCBncnIgKi8KKyAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAgICAgICAgICAgICBuYW1lW2ldPSpwOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgfQorICAgICAgICBuYW1lW2ldID0gJ1wwJzsKKworICAgICAgICB3aGlsZSAoKmNsaXN0KSB7CisgICAgICAgICAgICAgICAgbmRldiA9ICgqY2xpc3QpLT5uZXRkZXY7CisgICAgICAgICAgICAgICAgcHJpdiA9IChzdHJ1Y3QgbmV0aXVjdl9wcml2KiluZGV2LT5wcml2OworICAgICAgICAgICAgICAgIGRldiA9IHByaXYtPmRldjsKKworICAgICAgICAgICAgICAgIGlmIChzdHJuY21wKG5hbWUsIG5kZXYtPm5hbWUsIGNvdW50KSkgeworICAgICAgICAgICAgICAgICAgICAgICAgY2xpc3QgPSAmKCgqY2xpc3QpLT5uZXh0KTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBpZiAobmRldi0+ZmxhZ3MgJiAoSUZGX1VQIHwgSUZGX1JVTk5JTkcpKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBQUklOVF9XQVJOKAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAibmV0aXVjdjogbmV0IGRldmljZSAlcyBhY3RpdmUgd2l0aCBwZWVyICVzXG4iLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZGV2LT5uYW1lLCBwcml2LT5jb25uLT51c2VyaWQpOworICAgICAgICAgICAgICAgICAgICAgICAgUFJJTlRfV0FSTigibmV0aXVjdjogJXMgY2Fubm90IGJlIHJlbW92ZWRcbiIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5kZXYtPm5hbWUpOworCQkJSVVDVl9EQkZfVEVYVChkYXRhLCAyLCAicmVtb3ZlX3dyaXRlOiBzdGlsbCBhY3RpdmVcbiIpOworICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIC1FQlVTWTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgdW5yZWdpc3Rlcl9uZXRkZXYobmRldik7CisgICAgICAgICAgICAgICAgbmV0aXVjdl91bnJlZ2lzdGVyX2RldmljZShkZXYpOworICAgICAgICAgICAgICAgIHJldHVybiBjb3VudDsKKyAgICAgICAgfQorICAgICAgICBQUklOVF9XQVJOKCJuZXRpdWN2OiBuZXQgZGV2aWNlICVzIHVua25vd25cbiIsIG5hbWUpOworCUlVQ1ZfREJGX1RFWFQoZGF0YSwgMiwgInJlbW92ZV93cml0ZTogdW5rbm93biBkZXZpY2VcbiIpOworICAgICAgICByZXR1cm4gLUVJTlZBTDsKK30KKworRFJJVkVSX0FUVFIocmVtb3ZlLCAwMjAwLCBOVUxMLCByZW1vdmVfd3JpdGUpOworCitzdGF0aWMgdm9pZAorbmV0aXVjdl9iYW5uZXIodm9pZCkKK3sKKwljaGFyIHZidWZbXSA9ICIkUmV2aXNpb246IDEuNjMgJCI7CisJY2hhciAqdmVyc2lvbiA9IHZidWY7CisKKwlpZiAoKHZlcnNpb24gPSBzdHJjaHIodmVyc2lvbiwgJzonKSkpIHsKKwkJY2hhciAqcCA9IHN0cmNocih2ZXJzaW9uICsgMSwgJyQnKTsKKwkJaWYgKHApCisJCQkqcCA9ICdcMCc7CisJfSBlbHNlCisJCXZlcnNpb24gPSAiID8/PyAiOworCVBSSU5UX0lORk8oIk5FVElVQ1YgZHJpdmVyIFZlcnNpb24lcyBpbml0aWFsaXplZFxuIiwgdmVyc2lvbik7Cit9CisKK3N0YXRpYyB2b2lkIF9fZXhpdAorbmV0aXVjdl9leGl0KHZvaWQpCit7CisJSVVDVl9EQkZfVEVYVCh0cmFjZSwgMywgX19GVU5DVElPTl9fKTsKKwl3aGlsZSAoaXVjdl9jb25uZWN0aW9ucykgeworCQlzdHJ1Y3QgbmV0X2RldmljZSAqbmRldiA9IGl1Y3ZfY29ubmVjdGlvbn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yKilwdHIpKzExKSwgXAorCQkgICAqKCgoY2hhciopcHRyKSsxMiksKigoKGNoYXIqKXB0cikrMTMpLCBcCisJCSAgICooKChjaGFyKilwdHIpKzE0KSwqKCgoY2hhciopcHRyKSsxNSkpOyBcCitQUklOVF8jI2ltcG9ydGFuY2UoaGVhZGVyICIlMDJ4ICUwMnggJTAyeCAlMDJ4ICAlMDJ4ICUwMnggJTAyeCAlMDJ4ICAiIFwKKwkJICAgIiUwMnggJTAyeCAlMDJ4ICUwMnggICUwMnggJTAyeCAlMDJ4ICUwMnhcbiIsIFwKKwkJICAgKigoKGNoYXIqKXB0cikrMTYpLCooKChjaGFyKilwdHIpKzE3KSwgXAorCQkgICAqKCgoY2hhciopcHRyKSsxOCksKigoKGNoYXIqKXB0cikrMTkpLCBcCisJCSAgICooKChjaGFyKilwdHIpKzIwKSwqKCgoY2hhciopcHRyKSsyMSksIFwKKwkJICAgKigoKGNoYXIqKXB0cikrMjIpLCooKChjaGFyKilwdHIpKzIzKSwgXAorCQkgICAqKCgoY2hhciopcHRyKSsyNCksKigoKGNoYXIqKXB0cikrMjUpLCBcCisJCSAgICooKChjaGFyKilwdHIpKzI2KSwqKCgoY2hhciopcHRyKSsyNyksIFwKKwkJICAgKigoKGNoYXIqKXB0cikrMjgpLCooKChjaGFyKilwdHIpKzI5KSwgXAorCQkgICAqKCgoY2hhciopcHRyKSszMCksKigoKGNoYXIqKXB0cikrMzEpKTsKKworc3RhdGljIGlubGluZSB2b2lkCitxZXRoX2hleF9kdW1wKHVuc2lnbmVkIGNoYXIgKmJ1Ziwgc2l6ZV90IGxlbikKK3sKKwlzaXplX3QgaTsKKworCWZvciAoaSA9IDA7IGkgPCBsZW47IGkrKykgeworCQlpZiAoaSAmJiAhKGkgJSAxNikpCisJCQlwcmludGsoIlxuIik7CisJCXByaW50aygiJTAyeCAiLCAqKGJ1ZiArIGkpKTsKKwl9CisJcHJpbnRrKCJcbiIpOworfQorCisjZGVmaW5lIFNFTlNFX0NPTU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VRVMsMHgxMDN9LCBcCisJezAsMCwwLDAsMCwwLDAsMCwwfX0KKworI2RlZmluZSBRRVRIX1JFQUxfQ0FSRAkJMQorI2RlZmluZSBRRVRIX1ZMQU5fQ0FSRAkJMgorI2RlZmluZSBRRVRIX0JVRlNJWkUJIAk0MDk2CisKKy8qKgorICogc29tZSBtb3JlIGRlZnMKKyAqLworI2RlZmluZSBJRl9OQU1FX0xFTgkgCTE2CisjZGVmaW5lIFFFVEhfVFhfVElNRU9VVAkJMTAwICogSFoKKyNkZWZpbmUgUUVUSF9IRUFERVJfU0laRQkzMgorI2RlZmluZSBNQVhfUE9SVE5PIAkJMTUKKyNkZWZpbmUgUUVUSF9GQUtFX0xMX0xFTiAJRVRIX0hMRU4KKyNkZWZpbmUgUUVUSF9GQUtFX0xMX1Y2X0FERFJfUE9TIDI0CisKKy8qSVB2NiBhZGRyZXNzIGF1dG9jb25maWd1cmF0aW9uIHN0dWZmKi8KKyNkZWZpbmUgVU5JUVVFX0lEX0lGX0NSRUFURV9BRERSX0ZBSUxFRCAweGZmZmUKKyNkZWZpbmUgVU5JUVVFX0lEX05PVF9CWV9DQVJEIAkJMHgxMDAwMAorCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisvKiBRRElPIHF1ZXVlIGFuZCBidWZmZXIgaGFuZGxpbmcgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICovCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisjZGVmaW5lIFFFVEhfTUFYX1FVRVVFUyA0CisjZGVmaW5lIFFFVEhfSU5fQlVGX1NJWkVfREVGQVVMVCA2NTUzNgorI2RlZmluZSBRRVRIX0lOX0JVRl9DT1VOVF9ERUZBVUxUIDE2CisjZGVmaW5lIFFFVEhfSU5fQlVGX0NPVU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XBhcmVfc2tiOiBjb3VsZCAiCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIm5vdCByZWFsbG9jIGhlYWRyb29tIGZvciBxZXRoX2hkciAiCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIm9uIGludGVyZmFjZSAlcyIsIFFFVEhfQ0FSRF9JRk5BTUUoY2FyZCkpOworICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIC1FTk9NRU07CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICpza2IgPSBuZXdfc2tiOworCX0KKwlyZXR1cm4gMDsKK30KK3N0YXRpYyBpbmxpbmUgc3RydWN0IHNrX2J1ZmYgKgorcWV0aF9wc2tiX3Vuc2hhcmUoc3RydWN0IHNrX2J1ZmYgKnNrYiwgaW50IHByaSkKK3sKKyAgICAgICAgc3RydWN0IHNrX2J1ZmYgKm5za2I7CisgICAgICAgIGlmICghc2tiX2Nsb25lZChza2IpKQorICAgICAgICAgICAgICAgIHJldHVybiBza2I7CisgICAgICAgIG5za2IgPSBza2JfY29weShza2IsIHByaSk7CisgICAgICAgIGtmcmVlX3NrYihza2IpOyAvKiBmcmVlIG91ciBzaGFyZWQgY29weSAqLworICAgICAgICByZXR1cm4gbnNrYjsKK30KKworCitpbmxpbmUgc3RhdGljIHZvaWQgKgorcWV0aF9wdXNoX3NrYihzdHJ1Y3QgcWV0aF9jYXJkICpjYXJkLCBzdHJ1Y3Qgc2tfYnVmZiAqKnNrYiwgaW50IHNpemUpCit7CisgICAgICAgIHZvaWQgKmhkcjsKKworCWhkciA9ICh2b2lkICopIHNrYl9wdXNoKCpza2IsIHNpemUpOworICAgICAgICAvKgorICAgICAgICAgKiBzYW5pdHkgY2hlY2ssIHRoZSBMaW51eCBtZW1vcnkgYWxsb2NhdGlvbiBzY2hlbWUgc2hvdWxkCisgICAgICAgICAqIG5ldmVyIHByZXNlbnQgdXMgY2FzZXMgbGlrZSB0aGlzIG9uZSAodGhlIHFkaW8gaGVhZGVyIHNpemUgcGx1cworICAgICAgICAgKiB0aGUgZmlyc3QgNDAgYnl0ZXMgb2YgdGhlIHBha2V0IGNyb3NzIGEgNGsgYm91bmRhcnkpCisgICAgICAgICAqLworICAgICAgICBpZiAoKCgodW5zaWduZWQgbG9uZykgaGRyKSAmICh+KFBBR0VfU0laRSAtIDEpKSkgIT0KKyAgICAgICAgICAgICgoKHVuc2lnbmVkIGxvbmcpIGhkciArIHNpemUgKworICAgICAgICAgICAgICBRRVRIX0lQX0hFQURFUl9TSVpFKSAmICh+KFBBR0VfU0laRSAtIDEpKSkpIHsKKyAgICAgICAgICAgICAgICBQUklOVF9FUlIoInFldGhfcHJlcGFyZV9za2I6IG1pc2FsaWduZWQgIgorICAgICAgICAgICAgICAgICAgICAgICAgICAicGFja2V0IG9uIGludGVyZmFjZSAlcy4gRGlzY2FyZGVkLiIsCisgICAgICAgICAgICAgICAgICAgICAgICAgIFFFVEhfQ0FSRF9JRk5BTUUoY2FyZCkpOworICAgICAgICAgICAgICAgIHJldHVybiBOVUxMOworICAgICAgICB9CisgICAgICAgIHJldHVybiBoZHI7Cit9CisKK2lubGluZSBzdGF0aWMgaW50CitxZXRoX2dldF9obGVuKF9fdTggbGlua190eXBlKQoreworI2lmZGVmIENPTkZJR19RRVRIX0lQVjYKKwlzd2l0Y2ggKGxpbmtfdHlwZSkgeworCWNhc2UgUUVUSF9MSU5LX1RZUEVfSFNUUjoKKwljYXNlIFFFVEhfTElOS19UWVBFX0xBTkVfVFI6CisJCXJldHVybiBzaXplb2Yoc3RydWN0IHFldGhfaGRyKSArIFRSX0hMRU47CisJZGVmYXVsdDoKKyNpZmRlZiBDT05GSUdfUUVUSF9WTEFOCisJCXJldHVybiBzaXplb2Yoc3RydWN0IHFldGhfaGRyKSArIFZMQU5fRVRIX0hMRU47CisjZWxzZQorCQlyZXR1cm4gc2l6ZW9mKHN0cnVjdCBxZXRoX2hkcikgKyBFVEhfSExFTjsKKyNlbmRpZgorCX0KKyNl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zdCwgZW50cnkpIHsKKwkJaWYgKCh0bXAtPnByb3RvICAgICA9PSBRRVRIX1BST1RfSVBWNCkgICAgICAgICAgICAmJgorCQkgICAgKGFkZHItPnByb3RvICAgID09IFFFVEhfUFJPVF9JUFY0KSAgICAgICAgICAgICYmCisJCSAgICAoKHNhbWVfdHlwZSAmJiAodG1wLT50eXBlID09IGFkZHItPnR5cGUpKSB8fAorCQkgICAgICghc2FtZV90eXBlICYmICh0bXAtPnR5cGUgIT0gYWRkci0+dHlwZSkpICApICYmCisJCSAgICAodG1wLT51LmE0LmFkZHIgPT0gYWRkci0+dS5hNC5hZGRyKSAgICAgICAgICAgICApeworCQkJcmV0dXJuIDE7CisJCX0KKwkJaWYgKCh0bXAtPnByb3RvICA9PSBRRVRIX1BST1RfSVBWNikgICAgICAgICAgICAgICAmJgorCQkgICAgKGFkZHItPnByb3RvID09IFFFVEhfUFJPVF9JUFY2KSAgICAgICAgICAgICAgICYmCisJCSAgICAoKHNhbWVfdHlwZSAmJiAodG1wLT50eXBlID09IGFkZHItPnR5cGUpKSB8fAorCQkgICAgICghc2FtZV90eXBlICYmICh0bXAtPnR5cGUgIT0gYWRkci0+dHlwZSkpICApICYmCisJCSAgICAobWVtY21wKCZ0bXAtPnUuYTYuYWRkciwgJmFkZHItPnUuYTYuYWRkciwKKwkJCSAgICBzaXplb2Yoc3RydWN0IGluNl9hZGRyKSkgPT0gMCkgICAgICAgICAgKSB7CisJCQlyZXR1cm4gMTsKKwkJfQorCX0KKwlyZXR1cm4gMDsKK30KKworLyoKKyAqIEFkZCBJUCB0byBiZSBhZGRlZCB0byB0b2RvIGxpc3QuIElmIHRoZXJlIGlzIGFscmVhZHkgYW4gImFkZCB0b2RvIgorICogaW4gdGhpcyBsaXN0IHdlIGp1c3QgaW5jcmVtZW5lbnQgdGhlIHJlZmVyZW5jZSBjb3VudC4KKyAqIFJldHVybnMgMCBpZiB3ZSAganVzdCBpbmNyZW1lbnRlZCByZWZlcmVuY2UgY291bnQuCisgKi8KK3N0YXRpYyBpbnQKK19fcWV0aF9pbnNlcnRfaXBfdG9kbyhzdHJ1Y3QgcWV0aF9jYXJkICpjYXJkLCBzdHJ1Y3QgcWV0aF9pcGFkZHIgKmFkZHIsIGludCBhZGQpCit7CisJc3RydWN0IHFldGhfaXBhZGRyICp0bXAsICp0OworCWludCBmb3VuZCA9IDA7CisKKwlsaXN0X2Zvcl9lYWNoX2VudHJ5X3NhZmUodG1wLCB0LCBjYXJkLT5pcF90YmRfbGlzdCwgZW50cnkpIHsKKwkJaWYgKChhZGRyLT50eXBlID09IFFFVEhfSVBfVFlQRV9ERUxfQUxMX01DKSAmJgorCQkgICAgKHRtcC0+dHlwZSA9PSBRRVRIX0lQX1RZUEVfREVMX0FMTF9NQykpCisJCQlyZXR1cm4gMDsKKwkJaWYgKCh0bXAtPnByb3RvICAgICAgICA9PSBRRVRIX1BST1RfSVBWNCkgICAgICYmCisJCSAgICAoYWRkci0+cHJvdG8gICAgICAgPT0gUUVUSF9QUk9UX0lQVjQpICAgICAmJgorCQkgICAgKHRtcC0+dHlwZSAgICAgICAgID09IGFkZHItPnR5cGUpICAgICAgICAgJiYKKwkJICAgICh0bXAtPmlzX211bHRpY2FzdCA9PSBhZGRyLT5pc19tdWx0aWNhc3QpICYmCisJCSAgICAodG1wLT51LmE0LmFkZHIgICAgPT0gYWRkci0+dS5hNC5hZGRyKSAgICAmJgorCQkgICAgKHRtcC0+dS5hNC5tYXNrICAgID09IGFkZHItPnUuYTQubWFzaykgICAgICApeworCQkJZm91bmQgPSAxOworCQkJYnJlYWs7CisJCX0KKwkJaWYgKCh0bXAtPnByb3RvICAgICAgICA9PSBRRVRIX1BST1RfSVBWNikgICAgICAmJgorCQkgICAgKGFkZHItPnByb3RvICAgICAgID09IFFFVEhfUFJPVF9JUFY2KSAgICAgICYmCisJCSAgICAodG1wLT50eXBlICAgICAgICAgPT0gYWRkci0+dHlwZSkgICAgICAgICAgJiYKKwkJICAgICh0bXAtPmlzX211bHR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gICAgICAgICAgICAgICAgIFBSSU5UX0VSUigiRGV2aWNlICVzIGRvZXMgbm90IHN1cHBvcnQgIiBcCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgImxheWVyIDIgZnVuY3Rpb25hbGl0eS4gIiAgXAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICJJZ25vcmluZyBsYXllcjIgb3B0aW9uLlxuIixDQVJEX0JVU19JRChjYXJkKSk7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIElHTk9SRV9QQVJBTV9ORVEocm91dGU0LnR5cGUsIE5PX1JPVVRFUiwgTk9fUk9VVEVSLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIlJvdXRpbmcgb3B0aW9ucyBhcmUiKTsKKyNpZmRlZiBDT05GSUdfUUVUSF9JUFY2CisgICAgICAgICAgICAgICAgSUdOT1JFX1BBUkFNX05FUShyb3V0ZTYudHlwZSwgTk9fUk9VVEVSLCBOT19ST1VURVIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAiUm91dGluZyBvcHRpb25zIGFyZSIpOworI2VuZGlmCisgICAgICAgICAgICAgICAgSUdOT1JFX1BBUkFNX0VRKGNoZWNrc3VtX3R5cGUsIEhXX0NIRUNLU1VNTUlORywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgUUVUSF9DSEVDS1NVTV9ERUZBVUxULAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAiQ2hlY2tzdW1taW5nIG9wdGlvbnMgYXJlIik7CisgICAgICAgICAgICAgICAgSUdOT1JFX1BBUkFNX05FUShicm9hZGNhc3RfbW9kZSwgUUVUSF9UUl9CUk9BRENBU1RfQUxMUklOR1MsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBRRVRIX1RSX0JST0FEQ0FTVF9BTExSSU5HUywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICJCcm9hZGNhc3QgbW9kZSBvcHRpb25zIGFyZSIpOworICAgICAgICAgICAgICAgIElHTk9SRV9QQVJBTV9ORVEobWFjYWRkcl9tb2RlLCBRRVRIX1RSX01BQ0FERFJfTk9OQ0FOT05JQ0FMLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgUUVUSF9UUl9NQUNBRERSX05PTkNBTk9OSUNBTCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICJDYW5vbmljYWwgTUFDIGFkZHIgb3B0aW9ucyBhcmUiKTsKKyAgICAgICAgICAgICAgICBJR05PUkVfUEFSQU1fTkVRKGZha2VfYnJvYWRjYXN0LCAwLCAwLAorCQkJCSAiQnJvYWRjYXN0IGZha2luZyBvcHRpb25zIGFyZSIpOworICAgICAgICAgICAgICAgIElHTk9SRV9QQVJBTV9ORVEoYWRkX2hobGVuLCBERUZBVUxUX0FERF9ISExFTiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIERFRkFVTFRfQUREX0hITEVOLCJPcHRpb24gYWRkX2hobGVuIGlzIik7CisgICAgICAgICAgICAgICAgSUdOT1JFX1BBUkFNX05FUShmYWtlX2xsLCAwLCAwLCJPcHRpb24gZmFrZV9sbCBpcyIpOworICAgICAgICB9Cit9CisKKworc3RhdGljIGludAorcWV0aF9zZXRfb25saW5lKHN0cnVjdCBjY3dncm91cF9kZXZpY2UgKmdkZXYpCit7CisJc3RydWN0IHFldGhfY2FyZCAqY2FyZCA9IGdkZXYtPmRldi5kcml2ZXJfZGF0YTsKKwlpbnQgcmMgPSAwOworCWVudW0gcWV0aF9jYXJkX3N0YXRlcyByZWNvdmVyX2ZsYWc7CisKKwlCVUdfT04oIWNhcmQpOworCVFFVEhfREJGX1RFWFQoc2V0dXAgLDIsICJzZXRvbmxpbiIpOworCVFFVEhfREJGX0hFWChzZXR1cCwgMiwgJmNhcmQsIHNpemVvZih2b2lkICopKTsKKworCXFldGhfc2V0X2FsbG93ZWRfdGhyZWFkcyhjYXJkLCBRRVRIX1JFQ09WRVJ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2lnbmVkIGNoYXIgSVBBX1BEVV9IRUFERVJbXTsKKyNkZWZpbmUgUUVUSF9JUEFfQ01EX0RFU1RfQUREUihidWZmZXIpIChidWZmZXIrMHgyYykKKworI2RlZmluZSBJUEFfQ01EX0xFTkdUSAkoSVBBX1BEVV9IRUFERVJfU0laRSArIHNpemVvZihzdHJ1Y3QgcWV0aF9pcGFfY21kKSkKKworI2RlZmluZSBRRVRIX1NFUV9OT19MRU5HVEggCTQKKyNkZWZpbmUgUUVUSF9NUENfVE9LRU5fTEVOR1RIIAk0CisjZGVmaW5lIFFFVEhfTUNMX0xFTkdUSAkJNAorI2RlZmluZSBPU0FfQUREUl9MRU4JCTYKKworI2RlZmluZSBRRVRIX1RJTUVPVVQgCQkoMTAgKiBIWikKKyNkZWZpbmUgUUVUSF9JUEFfVElNRU9VVCAJKDQ1ICogSFopCisjZGVmaW5lIFFFVEhfSURYX0NPTU1BTkRfU0VRTk8gCTB4ZmZmZjAwMDAKKyNkZWZpbmUgU1JfSU5GT19MRU4JCTE2CisKKyNkZWZpbmUgUUVUSF9DTEVBUl9DSEFOTkVMX1BBUk0JLTEwCisjZGVmaW5lIFFFVEhfSEFMVF9DSEFOTkVMX1BBUk0JLTExCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKy8qIElQIEFzc2lzdCByZWxhdGVkIGRlZmluaXRpb25zICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKi8KKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKyNkZWZpbmUgSVBBX0NNRF9JTklUSUFUT1JfSE9TVCAgMHgwMAorI2RlZmluZSBJUEFfQ01EX0lOSVRJQVRPUl9IWURSQSAweDAxCisjZGVmaW5lIElQQV9DTURfUFJJTV9WRVJTSU9OX05PIDB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ID0gMHgyMywKKwlJUEFfQ01EX0RFTEdNQUMgCSAgICAgID0gMHgyNCwKKwlJUEFfQ01EX1NFVFZMQU4gCSAgICAgID0gMHgyNSwKKwlJUEFfQ01EX0RFTFZMQU4gCSAgICAgID0gMHgyNiwKKwlJUEFfQ01EX1NFVElQICAgICAgICAgICAgICAgICA9IDB4YjEsCisJSVBBX0NNRF9ERUxJUCAgICAgICAgICAgICAgICAgPSAweGI3LAorCUlQQV9DTURfUUlQQVNTSVNUICAgICAgICAgICAgID0gMHhiMiwKKwlJUEFfQ01EX1NFVEFTU1BBUk1TICAgICAgICAgICA9IDB4YjMsCisJSVBBX0NNRF9TRVRJUE0gICAgICAgICAgICAgICAgPSAweGI0LAorCUlQQV9DTURfREVMSVBNICAgICAgICAgICAgICAgID0gMHhiNSwKKwlJUEFfQ01EX1NFVFJURyAgICAgICAgICAgICAgICA9IDB4YjYsCisJSVBBX0NNRF9TRVRBREFQVEVSUEFSTVMgICAgICAgPSAweGI4LAorCUlQQV9DTURfSVBGUkFNRSAgICAgICAgICAgICAgID0gMHhiOSwKKwlJUEFfQ01EX0FERF9BRERSX0VOVFJZICAgICAgICA9IDB4YzEsCisJSVBBX0NNRF9ERUxFVEVfQUREUl9FTlRSWSAgICAgPSAweGMyLAorCUlQQV9DTURfQ1JFQVRFX0FERFIgICAgICAgICAgID0gMHhjMywKKwlJUEFfQ01EX0RFU1RST1lfQUREUiAgICAgICAgICA9IDB4YzQsCisJSVBBX0NNRF9SRUdJU1RFUl9MT0NBTF9BRERSICAgPSAweGQxLAorCUlQQV9DTURfVU5SRUdJU1RFUl9MT0NBTF9BRERSID0gMHhkMiwKK307CisKK2VudW0gcWV0aF9pcF9hc3NfY21kcyB7CisJSVBBX0NNRF9BU1NfU1RBUlQJPSAweDAwMDEsCisJSVBBX0NNRF9BU1NfU1RPUAk9IDB4MDAwMiwKKwlJUEFfQ01EX0FTU19DT05GSUdVUkUgCT0gMHgwMDAzLAorCUlQQV9DTURfQVNTX0VO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VTExfVkxBTiAgICAgICAgICAgPSAweDAwMDA0MDAwTCwKKwlJUEFfU09VUkNFX01BQyAgICAgICAgICA9IDB4MDAwMTAwMDBMLAorCUlQQV9PU0FfTUNfUk9VVEVSICAgICAgID0gMHgwMDAyMDAwMEwsCisJSVBBX1FVRVJZX0FSUF9BU1NJU1QJPSAweDAwMDQwMDAwTCwKKwlJUEFfSU5CT1VORF9UU08gICAgICAgICA9IDB4MDAwODAwMDBMLAorCUlQQV9PVVRCT1VORF9UU08gICAgICAgID0gMHgwMDEwMDAwMEwsCit9OworCisvKiBTRVRJUC9ERUxJUCBJUEEgQ29tbWFuZDogKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworZW51bSBxZXRoX2lwYV9zZXRkZWxpcF9mbGFncyB7CisJUUVUSF9JUEFfU0VUREVMSVBfREVGQVVMVCAgICAgICAgICA9IDB4MDBMLCAvKiBkZWZhdWx0ICovCisJUUVUSF9JUEFfU0VUSVBfVklQQV9GTEFHICAgICAgICAgICA9IDB4MDFMLCAvKiBubyBncmF0LiBBUlAgKi8KKwlRRVRIX0lQQV9TRVRJUF9UQUtFT1ZFUl9GTEFHICAgICAgID0gMHgwMkwsIC8qIG5vZmFpbCBvbiBncmF0LiBBUlAgKi8KKwlRRVRIX0lQQV9ERUxJUF9BRERSXzJfQl9UQUtFTl9PVkVSID0gMHgyMEwsCisJUUVUSF9JUEFfREVMSVBfVklQQV9GTEFHICAgICAgICAgICA9IDB4NDBMLAorCVFFVEhfSVBBX0RFTElQX0FERFJfTkVFRFNfU0VUSVAgICAgPSAweDgwTCwKK307CisKKy8qIFNFVEFEQVBURVIgSVBBIENvbW1hbmQ6ICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCitlbnVtIHFldGhfaXBhX3NldGFkcF9jbWQgeworCUlQQV9TRVRBRFBfUVVFUllfQ09NTUFORFNfU1VQUE9SVEVECT0gMHgwMSwKKw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dTggc2VxX25vOworfSBfX2F0dHJpYnV0ZV9fKChwYWNrZWQpKTsKKworc3RydWN0IHFldGhfYXJwX3F1ZXJ5X2RhdGEgeworCV9fdTE2IHJlcXVlc3RfYml0czsKKwlfX3UxNiByZXBseV9iaXRzOworCV9fdTMyIG5vX2VudHJpZXM7CisJY2hhciBkYXRhOworfSBfX2F0dHJpYnV0ZV9fKChwYWNrZWQpKTsKKworLyogdXNlZCBhcyBwYXJhbWV0ZXIgZm9yIGFycF9xdWVyeSByZXBseSAqLworc3RydWN0IHFldGhfYXJwX3F1ZXJ5X2luZm8geworCV9fdTMyIHVkYXRhX2xlbjsKKwlfX3UxNiBtYXNrX2JpdHM7CisJX191MzIgdWRhdGFfb2Zmc2V0OworCV9fdTMyIG5vX2VudHJpZXM7CisJY2hhciAqdWRhdGE7Cit9OworCisvKiBTRVRBU1NQQVJNUyBJUEEgQ29tbWFuZDogKi8KK3N0cnVjdCBxZXRoX2lwYWNtZF9zZXRhc3NwYXJtcyB7CisJc3RydWN0IHFldGhfaXBhY21kX3NldGFzc3Bhcm1zX2hkciBoZHI7CisJdW5pb24geworCQlfX3UzMiBmbGFnc18zMmJpdDsKKwkJc3RydWN0IHFldGhfYXJwX2NhY2hlX2VudHJ5IGFkZF9hcnBfZW50cnk7CisJCXN0cnVjdCBxZXRoX2FycF9xdWVyeV9kYXRhIHF1ZXJ5X2FycDsKKwkJX191OCBpcFsxNl07CisJfSBkYXRhOworfSBfX2F0dHJpYnV0ZV9fICgocGFja2VkKSk7CisKKworLyogU0VUUlRHIElQQSBDb21tYW5kOiAgICAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworc3RydWN0IHFldGhfc2V0X3JvdXRpbmcgeworCV9fdTggdHlwZTsKK307CisKKy8qIFNFVEFEQVBURVJQQVJNUyBJUEEgQ29tbWFuZDogICAgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KK3N0cnVjdCB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FuZDogICAgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCitzdHJ1Y3QgcWV0aF9jcmVhdGVfZGVzdHJveV9hZGRyZXNzIHsKKwlfX3U4IHVuaXF1ZV9pZFs4XTsKK30gX19hdHRyaWJ1dGVfXyAoKHBhY2tlZCkpOworCisvKiBSRUdJU1RFUl9MT0NBTF9BRERSIElQQSBDb21tYW5kOiAgICAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisvKiBUT0RPOiBkZWZpbmUgaW4gYW5hbG9neSB0byBjb21tYW5kcyBkZWZpbmUgYWJvdmUgKi8KKworLyogVU5SRUdJU1RFUl9MT0NBTF9BRERSIElQQSBDb21tYW5kOiAgICAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworLyogVE9ETzogZGVmaW5lIGluIGFuYWxvZ3kgdG8gY29tbWFuZHMgZGVmaW5lIGFib3ZlICovCisKKy8qIEhlYWRlciBmb3IgZWFjaCBJUEEgY29tbWFuZCAqLworc3RydWN0IHFldGhfaXBhY21kX2hkciB7CisJX191OCAgIGNvbW1hbmQ7CisJX191OCAgIGluaXRpYXRvcjsKKwlfX3UxNiAgc2Vxbm87CisJX191MTYgIHJldHVybl9jb2RlOworCV9fdTggICBhZGFwdGVyX3R5cGU7CisJX191OCAgIHJlbF9hZGFwdGVyX25vOworCV9fdTggICBwcmltX3ZlcnNpb25fbm87CisJX191OCAgIHBhcmFtX2NvdW50OworCV9fdTE2ICBwcm90X3ZlcnNpb247CisJX191MzIgIGlwYV9zdXBwb3J0ZWQ7CisJX191MzIgIGlwYV9lbmFibGVkOworfSBfX2F0dHJpYnV0ZV9fICgocGFja2VkKSk7CisKKy8qIFRoZSBJUEEgY29tbWFuZCBpdHNlbGYgKi8KK3N0cnVjdCBxZXRoX2lwYV9jbWQgeworCXN0cnVjdCBxZXRoX2lwYWNtZF9oZHIgaGRyOworCXVuaW9uIHsKKwkJc3RydWN0IHFld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m91bmQgZG9fUURJTyBjb3VudCAgICAgICAgICAgICAgICAgIDogJWlcblxuIgorCQkgICAgICAiICBPdXRib3VuZCBoYW5kbGVyIHRpbWUgKGluIHVzKSAgICAgICAgICA6ICVpXG4iCisJCSAgICAgICIgIE91dGJvdW5kIGhhbmRsZXIgY291bnQgICAgICAgICAgICAgICAgIDogJWlcblxuIgorCQkgICAgICAiICBPdXRib3VuZCB0aW1lIChpbiB1cywgaW5jbCBRRElPKSAgICAgICA6ICVpXG4iCisJCSAgICAgICIgIE91dGJvdW5kIGNvdW50ICAgICAgICAgICAgICAgICAgICAgICAgIDogJWlcbiIKKwkJICAgICAgIiAgT3V0Ym91bmQgZG9fUURJTyB0aW1lIChpbiB1cykgICAgICAgICAgOiAlaVxuIgorCQkgICAgICAiICBPdXRib3VuZCBkb19RRElPIGNvdW50ICAgICAgICAgICAgICAgICA6ICVpXG5cbiIsCisJCSAgICAgICAgY2FyZC0+cGVyZl9zdGF0cy5pbmJvdW5kX3RpbWUsCisJCQljYXJkLT5wZXJmX3N0YXRzLmluYm91bmRfY250LAorCQkgICAgICAgIGNhcmQtPnBlcmZfc3RhdHMuaW5ib3VuZF9kb19xZGlvX3RpbWUsCisJCQljYXJkLT5wZXJmX3N0YXRzLmluYm91bmRfZG9fcWRpb19jbnQsCisJCQljYXJkLT5wZXJmX3N0YXRzLm91dGJvdW5kX2hhbmRsZXJfdGltZSwKKwkJCWNhcmQtPnBlcmZfc3RhdHMub3V0Ym91bmRfaGFuZGxlcl9jbnQsCisJCQljYXJkLT5wZXJmX3N0YXRzLm91dGJvdW5kX3RpbWUsCisJCQljYXJkLT5wZXJmX3N0YXRzLm91dGJvdW5kX2NudCwKKwkJICAgICAgICBjYXJkLT5wZXJmX3N0YXRzLm91dGJvdW5kX2RvX3FkaW9fdGltZSwKKwkJCWNhcmQtPnBlcmZfc3RhdHMub3V0Ym91bmRfZG9fcWRpb19jbnQKKwkJICApOworCXJldHVybiAwOworfQorCitzdGF0aWMgc3Ryd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vbGlzdC5oPgorI2luY2x1ZGUgPGxpbnV4L3J3c2VtLmg+CisKKyNpbmNsdWRlIDxhc20vZWJjZGljLmg+CisKKyNpbmNsdWRlICJxZXRoLmgiCisjaW5jbHVkZSAicWV0aF9tcGMuaCIKKyNpbmNsdWRlICJxZXRoX2ZzLmgiCisKK2NvbnN0IGNoYXIgKlZFUlNJT05fUUVUSF9TWVNfQyA9ICIkUmV2aXNpb246IDEuNTEgJCI7CisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKy8qICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKi8KKy8qICAgICAgICAgIC9zeXMtZnMgc3R1ZmYgVU5ERVIgREVWRUxPUE1FTlQgISEhICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKi8KKy8qICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKi8KKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKy8vbG93L2hpZ2ggd2F0ZXJtYXJrCisKK3N0YXRpYyBzc2l6ZV90CitxZXRoX2Rldl9zdGF0ZV9zaG93KHN0cnVjdCBkZXZpY2UgKmRldiwgY2hhciAqYnVmKQoreworCXN0cnVjdCBxZXRoX2NhcmQgKmNhcmQgPSBkZXYtPmRyaXZlcl9kYXRhOworCWlmICghY2FyZCkKKwkJcmV0dXJuIC1FSU5WQUw7CisKKwlzd2l0Y2ggKGNhcmQtPnN0YXRlKSB7CisJY2FzZSBDQVJEX1NUQVRFX0RPV046CisJCXJldHVybiBzcHJpbnRmKGJ1ZiwgIkRPV05cbiIpOworCWNhc2UgQ0FSRF9TVEFURV9IQVJEU0VUVVA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ICAgIHNrYl9xdWV1ZV90YWlsKCZidWYtPnNrYl9saXN0LCBza2IpOworCisJLyppbml0aWFsaXplIGFsbCB2YXJpYWJsZXMuLi4qLworICAgICAgICBidWZmZXIgPSBidWYtPmJ1ZmZlcjsKKwloZHIgPSAoc3RydWN0IHFldGhfaGRyX3RzbyAqKXNrYi0+ZGF0YTsKKwloZHJfbGVuID0gc2l6ZW9mKHN0cnVjdCBxZXRoX2hkcl90c28pICsgaGRyLT5leHQuZGdfaGRyX2xlbjsKKwlkYXRhID0gc2tiLT5kYXRhICsgaGRyX2xlbjsKKwlsZW5ndGggPSBza2ItPmxlbiAtIGhkcl9sZW47CisgICAgICAgIGVsZW1lbnQgPSBidWYtPm5leHRfZWxlbWVudF90b19maWxsOworCS8qZmlsbCBmaXJzdCBidWZmZXIgZW50cnkgb25seSB3aXRoIGhlYWRlciBpbmZvcm1hdGlvbiAqLworCWJ1ZmZlci0+ZWxlbWVudFtlbGVtZW50XS5hZGRyID0gc2tiLT5kYXRhOworCWJ1ZmZlci0+ZWxlbWVudFtlbGVtZW50XS5sZW5ndGggPSBoZHJfbGVuOworCWJ1ZmZlci0+ZWxlbWVudFtlbGVtZW50XS5mbGFncyA9IFNCQUxfRkxBR1NfRklSU1RfRlJBRzsKKwlidWYtPm5leHRfZWxlbWVudF90b19maWxsKys7CisKKwlpZiAoc2tiX3NoaW5mbyhza2IpLT5ucl9mcmFncyA+IDApIHsKKyAgICAgICAgICAgICAgICAgX19xZXRoX3Rzb19maWxsX2J1ZmZlcl9mcmFnKGJ1Ziwgc2tiKTsKKyAgICAgICAgICAgICAgICAgZ290byBvdXQ7CisgICAgICAgIH0KKworICAgICAgIC8qc3RhcnQgZmlsbGluZyBidWZmZXIgZW50cmllcyAuLi4qLworICAgICAgICBlbGVtZW50Kys7CisgICAgICAgIHdoaWxlIChsZW5ndGggPiAwKSB7CisgICAgICAgICAgICAgICAgLyogbGVuZ3RoX2hlcmUgaXMgdGhlIHJlbWFpbmluZyBhbW91bnQgb2YgZGF0YSBpbiB0aGlzIHBhZ2UgKi8KKwkJbGVuZ3RoX2hlcmUgPSBQQUdFX1NJWkUgLSAoKHVuc2lnbmVkIGxvbmcpIGRhdGEgJSBQQUdFX1NJWkUpOworCQlpZiAobGVuZ3RoIDwgbGVuZ3RoX2hlcmUpCisgICAgICAgICAgICAgICAgICAgICAgICBsZW5ndGhfaGVyZSA9IGxlbmd0aDsKKyAgICAgICAgICAgICAgICBidWZmZXItPmVsZW1lbnRbZWxlbWVudF0uYWRkciA9IGRhdGE7CisgICAgICAgICAgICAgICAgYnVmZmVyLT5lbGVtZW50W2VsZW1lbnRdLmxlbmd0aCA9IGxlbmd0aF9oZXJlOworICAgICAgICAgICAgICAgIGxlbmd0aCAtPSBsZW5ndGhfaGVyZTsKKyAgICAgICAgICAgICAgICBpZiAoIWxlbmd0aCkKKyAgICAgICAgICAgICAgICAgICAgICAgIGJ1ZmZlci0+ZWxlbWVudFtlbGVtZW50XS5mbGFncyA9CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFNCQUxfRkxBR1NfTEFTVF9GUkFHOworICAgICAgICAgICAgICAgICBlbHNlCisgICAgICAgICAgICAgICAgICAgICAgICAgYnVmZmVyLT5lbGVtZW50W2VsZW1lbnRdLmZsYWdzID0KKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFNCQUxfRkxBR1NfTUlERExFX0ZSQUc7CisgICAgICAgICAgICAgICAgZGF0YSArPSBsZW5ndGhfaGVyZTsKKyAgICAgICAgICAgICAgICBlbGVtZW50Kys7CisgICAgICAgIH0KKyAgICAgICAgLypzZXQgdGhlIGJ1ZmZlciB0byBwcmltZWQgIC4uLiovCisgICAgICAgIGJ1Zi0+bmV4dF9lbGVtZW50X3RvX2ZpbGwgPSBlbGVtZW50Oworb3V0OgorCWF0b21pY19zZXQoJmJ1Zi0+c3RhdGUsIFFFVEhfUURJT19CVUZfUFJJTUVEKTsKKyAgICAgICAgcmV0dXJuIDE7Cit9CisKK2ludAorcWV0aF90c29fc2VuZF9wYWNrZXQoc3RydWN0IHFldGhfY2FyZCAqY2FyZCwgc3RydWN0IHNrX2J1ZmYgKnNrYiwKKwkJICAgICBzdHJ1Y3QgcWV0aF9xZGlvX291dF9xICpxdWV1ZSwgaW50IGlwdiwgaW50IGNhc3RfdHlwZSkKK3sKKwlpbnQgZmx1c2hfY250ID0gMDsKKwlzdHJ1Y3QgcWV0aF9oZHJfdHNvICpoZHI7CisJc3RydWN0IHFldGhfcWRpb19vdXRfYnVmZmVyICpidWZmZXI7CisgICAgICAgIGludCBzdGFydF9pbmRleDsKKworCVFFVEhfREJGX1RFWFQodHJhY2UsIDMsICJ0c29zZW5kIik7CisKKwlpZiAoIShoZHIgPSBxZXRoX3Rzb19wcmVwYXJlX3BhY2tldChjYXJkLCBza2IsIGlwdiwgY2FzdF90eXBlKSkpCisJICAgICAJcmV0dXJuIC1FTk9NRU07CisJLypjaGVjayBpZiBza2IgZml0cyBpbiBvbmUgU0JBTCAuLi4qLworCWlmICghKHFldGhfZ2V0X2VsZW1lbnRzX25vKGNhcmQsICh2b2lkKiloZHIsIHNrYikpKQorCQlyZXR1cm4gLUVJTlZBTDsKKwkvKmxvY2sgcXVldWUsIGZvcmNlIHN3aXRjaGluZyB0byBub24tcGFja2luZyBhbmQgc2VuZCBpdCAuLi4qLworCXdoaWxlIChhdG9taWNfY29tcGFyZV9hbmRfc3dhcChRRVRIX09VVF9RX1VOTE9DS0VELAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgUUVUSF9PVVRfUV9MT0NLRUQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAmcXVldWUtPnN0YXRlKSk7CisgICAgICAgIHN0YXJ0X2luZGV4ID0gcXVldWUtPm5leHRfYnVmX3RvX2ZpbGw7CisgICAgICAgIGJ1ZmZlciA9ICZxdWV1ZS0+YnVmc1txdWV1ZS0+bmV4dF9idWZfdG9fZmlsbF07CisJLypjaGVjayB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