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9uKSBhbnkgbGF0ZXIgdmVyc2lvbi4KKyAqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIEphbiAyMCwgMTk5OCAgICAgICAgQmVuIEdyZWVhciAgICAgSW5pdGlhbCBWZXJzaW9uCisgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisKKyNpbmNsdWRlIDxsaW51eC9jb25maWcuaD4KKyNpbmNsdWRlIDxsaW51eC9tb2R1bGUuaD4KKyNpbmNsdWRlIDxsaW51eC9zdGRkZWYuaD4JLyogb2Zmc2V0b2YoKSwgZXRjLiAqLworI2luY2x1ZGUgPGxpbnV4L2Vycm5vLmg+CS8qIHJldHVybiBjb2RlcyAqLworI2luY2x1ZGUgPGxpbnV4L2tlcm5lbC5oPgorI2luY2x1ZGUgPGxpbnV4L3NsYWIuaD4JCS8qIGttYWxsb2MoKSwga2ZyZWUoKSAqLworI2luY2x1ZGUgPGxpbnV4L21tLmg+CQkvKiB2ZXJpZnlfYXJlYSgpLCBldGMuICovCisjaW5jbHVkZSA8bGludXgvc3RyaW5nLmg+CS8qIGlubGluZSBtZW0qLCBzdHIqIGZ1bmN0aW9ucyAqLworI2luY2x1ZGUgPGxpbnV4L2luaXQuaD4JCS8qIF9faW5pdGZ1bmMgZXQgYWwuICovCisjaW5jbHVkZSA8YXNtL2J5dGVvcmRlci5oPgkvKiBodG9ucygpLCBldGMuICovCisjaW5jbHVkZSA8YXNtL3VhY2Nlc3MuaD4JLyogY29weV90b191c2VyICovCisjaW5jbHVkZSA8YXNtL2lvLmg+CisjaW5jbHVkZSA8bGludXgvcHJvY19mcy5oPgorI2luY2x1ZGUgPGxpbnV4L3NlcV9maWxlLmg+CisjaW5jbHVkZSA8bGludXgvZnMuaD4KKyNpbmNsdWRlIDxsaW51eC9uZXRkZXZpY2Uua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CQkJCQkJbW9kdWxlLgorICogICAgICAgICAgICAgIEFkcmlhbiBTdW4vIAorICogICAgICAgICAgICAgIE1pY2hhZWwgWnVlbHNkb3JmZiAgICAgIDogICAgICAgZml4IGZvciBuZXQuMCBwYWNrZXRzLiBkb24ndCAKKyAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFsbG93IGlsbGVnYWwgZXRoZXIvdG9rZW50YWxrCisgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwb3J0IGFzc2lnbm1lbnQuIHdlIGxvc2UgYSAKKyAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbGlkIGxvY2FsdGFsayBwb3J0IGFzIGEgCisgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXN1bHQuCisgKgkJQXJuYWxkbyBDLiBkZSBNZWxvCToJQ2xlYW51cCwgaW4gcHJlcGFyYXRpb24gZm9yCisgKgkJCQkJCXNoYXJlZCBza2Igc3VwcG9ydCA4KQorICoJCUFybmFsZG8gQy4gZGUgTWVsbwk6CU1vdmUgcHJvYyBzdHVmZiB0byBhdGFsa19wcm9jLmMsCisgKgkJCQkJCXVzZSBzZXFfZmlsZQorICoKKyAqCQlUaGlzIHByb2dyYW0gaXMgZnJlZSBzb2Z0d2FyZTsgeW91IGNhbiByZWRpc3RyaWJ1dGUgaXQgYW5kL29yCisgKgkJbW9kaWZ5IGl0IHVuZGVyIHRoZSB0ZXJtcyBvZiB0aGUgR05VIEdlbmVyYWwgUHVibGljIExpY2Vuc2UKKyAqCQlhcyBwdWJsaXNoZWQgYnkgdGhlIEZyZWUgU29mdHdhcmUgRm91bmRhdGlvbjsgZWl0aGVyIHZlcnNpb24KKyAqCQkyIG9mIHRoZSBMaWNlbnNlLCBvciAoYXQgeW91ciBvcHRpb24pIGFueSBsYXRlciB2ZXJzaW9uLgorICogCisgKi8KKworI2luY2x1ZGUgPGxpbnV4L2NvbmZpZy5oPgorI2luY2x1ZGUgPGxpbnV4L21vZHVsZS5oPgorI2luY2x1ZGUgPGxpbnV4L3RjcC5oPgorI2luY2x1ZGUgPGxpbnV4L2lmX2FycC5oPgorI2luY2x1ZGUgPGxpbnV4L3Rlcm1pb3MuaD4JLyogRm9yIFRJT0NPVVRRL0lOUSAqLworI2luY2x1ZGUgPG5ldC9kYXRhbGluay5oPgorI2luY2x1ZGUgPG5ldC9wc25hcC5oPgorI2luY2x1ZGUgPG5ldC9zb2NrLmg+CisjaW5jbHVkZSA8bmV0L3JvdXRlLmg+CisjaW5jbHVkZSA8bGludXgvYXRhbGsuaD4KKworc3RydWN0IGRhdGFsaW5rX3Byb3RvICpkZHBfZGwsICphYXJwX2RsOworc3RhdGljIHN0cnVjdCBwcm90b19vcHMgYXRhbGtfZGdyYW1fb3BzOworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKipcCisqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqCisqIEhhbmRsZXJzIGZvciB0aGUgc29ja2V0IGxpc3QuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqCisqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqCitcKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisKK0hMSVNUX0hFQUQoYXRhbGtfc29ja2V0cyk7CitERUZJTkVfUldMT0NLKGF0YWxrX3NvY2tldHNfbG9jayk7CisKK3N0YXRpYyBpbmxpbmUgdm9pZCBfX2F0YWxrX2luc2VydF9zb2NrZXQoc3RydWN0IHNvY2sgKnNrKQoreworCXNrX2F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cHV0KHNrKTsKK30KKworc3RhdGljIGlubGluZSB2b2lkIGF0YWxrX2Rlc3Ryb3lfc29ja2V0KHN0cnVjdCBzb2NrICpzaykKK3sKKwlhdGFsa19yZW1vdmVfc29ja2V0KHNrKTsKKwlza2JfcXVldWVfcHVyZ2UoJnNrLT5za19yZWNlaXZlX3F1ZXVlKTsKKworCWlmIChhdG9taWNfcmVhZCgmc2stPnNrX3dtZW1fYWxsb2MpIHx8CisJICAgIGF0b21pY19yZWFkKCZzay0+c2tfcm1lbV9hbGxvYykpIHsKKwkJaW5pdF90aW1lcigmc2stPnNrX3RpbWVyKTsKKwkJc2stPnNrX3RpbWVyLmV4cGlyZXMJPSBqaWZmaWVzICsgU09DS19ERVNUUk9ZX1RJTUU7CisJCXNrLT5za190aW1lci5mdW5jdGlvbgk9IGF0YWxrX2Rlc3Ryb3lfdGltZXI7CisJCXNrLT5za190aW1lci5kYXRhCT0gKHVuc2lnbmVkIGxvbmcpc2s7CisJCWFkZF90aW1lcigmc2stPnNrX3RpbWVyKTsKKwl9IGVsc2UKKwkJc29ja19wdXQoc2spOworfQorCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKipcCisqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqCisqIFJvdXRpbmcgdGFibGVzIGZvciB0aGUgQXBwbGVUYWxrIHNvY2tldCBsYXllci4gICAgICAgICAgICAgICAgICAgICAgICAgICAqCisqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqCitcKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisKKy8qIEFudGktZGVhZGxvY2sgb3JkZXJpbmcgaXMgYXRhbGtfcm91dG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CisJCQlzYS0+c2F0X2FkZHIgPSBhdGlmLT5hZGRyZXNzOworCQkJYnJlYWs7CisKKwkJY2FzZSBTSU9DR0lGQlJEQUREUjoKKwkJCWlmICghYXRpZikKKwkJCQlyZXR1cm4gLUVBRERSTk9UQVZBSUw7CisKKwkJCXNhLT5zYXRfZmFtaWx5ID0gQUZfQVBQTEVUQUxLOworCQkJc2EtPnNhdF9hZGRyLnNfbmV0ID0gYXRpZi0+YWRkcmVzcy5zX25ldDsKKwkJCXNhLT5zYXRfYWRkci5zX25vZGUgPSBBVEFERFJfQkNBU1Q7CisJCQlicmVhazsKKworCSAgICAgICAgY2FzZSBTSU9DQVRBTEtESUZBRERSOgorCSAgICAgICAgY2FzZSBTSU9DRElGQUREUjoKKwkJCWlmICghY2FwYWJsZShDQVBfTkVUX0FETUlOKSkKKwkJCQlyZXR1cm4gLUVQRVJNOworCQkJaWYgKHNhLT5zYXRfZmFtaWx5ICE9IEFGX0FQUExFVEFMSykKKwkJCQlyZXR1cm4gLUVJTlZBTDsKKwkJCWF0YWxrX2Rldl9kb3duKGRldik7CisJCQlicmVhazsJCQkKKworCQljYXNlIFNJT0NTQVJQOgorCQkJaWYgKCFjYXBhYmxlKENBUF9ORVRfQURNSU4pKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gLUVQRVJNOworICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNhLT5zYXRfZmFtaWx5ICE9IEFGX0FQUExFVEFMSykKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIC1FSU5WQUw7CisgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWF0aWYpCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAtRUFERFJOT1RBVkFJTDsKKworICAgICAgICAgICAgICAgICAgICAgICAgLyoKKyAgICAgICAgICAgICAgICAgICAgICAgICAqIGZvciBub3csIHdlIG9ubHkgc3VwcG9ydCBwcm94eSBBQVJQIG9uIEVMQVA7CisgICAgICAgICAgICAgICAgICAgICAgICAgKiB3ZSBzaG91bGQgYmUgYWJsZSB0byBkbyBpdCBmb3IgTG9jYWxUYWxrLCB0b28uCisgICAgICAgICAgICAgICAgICAgICAgICAgKi8KKyAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkZXYtPnR5cGUgIT0gQVJQSFJEX0VUSEVSKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gLUVQUk9UT05PU1VQUE9SVDsKKworICAgICAgICAgICAgICAgICAgICAgICAgLyoKKyAgICAgICAgICAgICAgICAgICAgICAgICAqIGF0aWYgcG9pbnRzIHRvIHRoZSBjdXJyZW50IGludGVyZmFjZSBvbiB0aGlzIG5ldHdvcms7CisgICAgICAgICAgICAgICAgICAgICAgICAgKiB3ZSBhcmVuJ3QgY29uY2VybmVkIGFib3V0IGl0cyBjdXJyZW50IHN0YXR1cyAoYXQKKwkJCSAqIGxlYXN0IGZvciBub3cpLCBidXQgaXQgaGFzIGFsbCB0aGUgc2V0dGluZ3MgYWJvdXQKKwkJCSAqIHRoZSBuZXR3b3JrIHdlJ3JlIGdvaW5nIHRvIHByb2JlLiBDb25zZXF1ZW50bHksIGl0CisJCQkgKiBtdXN0IGV4aXN0LgorICAgICAgICAgICAgICAgICAgICAgICAgICovCisgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWF0aWYpCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAtRUFERFJOT1RBVkFJTDsKKworICAgICAgICAgICAgICAgICAgICAgICAgbnIgPSAoc3RydWN0IGF0YWxrX25ldHJhbmdlICopJihhdGlmLT5uZXRzKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIC8qCisgICAgICAgICAgICAgICAgICAgICAgICAgKiBQaGFzZSAxIGlzIGZpbmUgb24gTG9jYWx0YWxrIGJ1dCB3ZSBkb24ndCBkbworICAgICAgICAgICAgICAgICAgICAgICAgICogRXRoZXJ0YWxrIHBoYXNlIDEuIEFueW9uZSB3YW50aW5nIHRvIGFkZCBpdCBnbyBhaGVhZC4KKyAgICAgICAgICAgICAgICAgICAgICAgICAqLworICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRldi0+dHlwZSA9PSBBUlBIUkRfRVRIRVIgJiYgbnItPm5yX3BoYXNlICE9IDIpCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAtRVBST1RPTk9TVVBQT1JUOworCisgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc2EtPnNhdF9hZGRyLnNfbm9kZSA9PSBBVEFERFJfQkNBU1QgfHwKKwkJCSAgICBzYS0+c2F0X2FkZHIuc19ub2RlID09IDI1NCkKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIC1FSU5WQUw7CisKKyAgICAgICAgICAgICAgICAgICAgICAgIC8qCisgICAgICAgICAgICAgICAgICAgICAgICAgKiBDaGVjayBpZiB0aGUgY2hvc2VuIGFkZHJlc3MgaXMgdXNlZC4gSWYgc28gd2UKKyAgICAgICAgICAgICAgICAgICAgICAgICAqIGVycm9yIGFuZCBBVENQIHdpbGwgdHJ5IGFub3RoZXIuCisgICAgICAgICAgICAgICAgICAgICAgICAgKi8KKyAgICAgICAgICAgICAgICAgICAgICAJaWYgKGF0aWZfcHJveHlfcHJvYmVfZGV2aWNlKGF0aWYsICYoc2EtPnNhdF9hZGRyKSkgPCAwKQorICAgICAgICAgICAgICAgICAgICAgIAkJcmV0dXJuIC1FQUREUklOVVNFOworICAgICAgICAgICAgICAgICAgICAgIAkKKwkJCS8qCisgICAgICAgICAgICAgICAgICAgICAgICAgKiBXZSBub3cgaGF2ZSBhbiBhZGRyZXNzIG9uIHRoZSBsb2NhbCBuZXR3b3JrLCBhbmQKKwkJCSAqIHRoZSBBQVJQIGNvZGUgd2lsbCBkZWZlbmQgaXQgZm9yIHVzIHVudGlsIHdlIHRha2UgaXQKKwkJCSAqIGRvd24uIFdlIGRvbid0IHNldCB1cCBhbnkgcm91dGVzIHJpZ2h0IG5vdywgYmVjYXVzZQorCQkJICogQVRDUCB3aWxsIGluc3RhbGwgdGhlbSBtYW51YWxseSB2aWEgU0lPQ0FERFJULgorICAgICAgICAgICAgICAgICAgICAgICAgICovCisgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKKworICAgICAgICAgICAgICAgIGNhc2UgU0lPQ0RBUlA6CisgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWNhcGFibGUoQ0FQX05FVF9BRE1JTikpCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAtRVBFUk07CisgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc2EtPnNhdF9mYW1pbHkgIT0gQUZfQVBQTEVUQUxLKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gLUVJTlZBTDsKKyAgICAgICAgICAgICAgICAgICAgICAgIGlmICghYXRpZikKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIC1FQUREUk5PVEFWQUlMOworCisgICAgICAgICAgICAgICAgICAgICAgICAvKiBnaXZlIHRvIGFhcnAgbW9kdWxlIHRvIHJlbW92ZSBwcm94eSBlbnRyeSAqLworICAgICAgICAgICAgICAgICAgICAgICAgYWFycF9wcm94eV9yZW1vdmUoYXRpZi0+ZGV2LCAmKHNhLT5zYXRfYWRkcikpOworICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIDA7CisJfQorCisJcmV0dXJuIGNvcHlfdG9fdXNlcihhcmcsICZhdHJlcSwgc2l6ZW9mKGF0cmVxKSkgPyAtRUZBVUxUIDogMDsKK30KKworLyogUm91dGluZyBpb2N0bCgpIGNhbGxzICovCitzdGF0aWMgaW50IGF0cnRyX2lvY3RsKHVuc2lnbmVkIGludCBjbWQsIHZvaWQgX191c2VyICphcmcpCit7CisJc3RydWN0IHJ0ZW50cnkgcnQ7CisKKwlpZiAoY29weV9mcm9tX3VzZXIoJnJ0LCBhcmcsIHNpemVvZihydCkpKQorCQlyZXR1cm4gLUVGQVVMVDsKKworCXN3aXRjaCAoY21kKSB7CisJCWNhc2UgU0lPQ0RFTFJUOgorCQkJaWYgKHJ0LnJ0X2RzdC5zYV9mYW1pbHkgIT0gQUZfQVBQTEVUQUxLKQorCQkJCXJldHVybiAtRUlOVkFMOworCQkJcmV0dXJuIGF0cnRyX2RlbGV0ZSgmKChzdHJ1Y3Qgc29ja2FkZHJfYXQgKikKKwkJCQkJCSZydC5ydF9kc3QpLT5zYXRfYWRkcik7CisKKwkJY2FzZSBTSU9DQUREUlQ6IHsKKwkJCXN0cnVjdCBuZXRfZGV2aWNlICpkZXYgPSBOVUxMOworCQkJaWYgKHJ0LnJ0X2RldikgeworCQkJCWNoYXIgbmFtZVtJRk5BTVNJWl07CisJCQkJaWYgKGNvcHlfZnJvbV91c2VyKG5hbWUsIHJ0LnJ0X2RldiwgSUZOQU1TSVotMSkpCisJCQkJCXJldHVybiAtRUZBVUxUOworCQkJCW5hbWVbSUZOQU1TSVotMV0gPSAnXDAnOworCQkJCWRldiA9IF9fZGV2X2dldF9ieV9uYW1lKG5hbWUpOworCQkJCWlmICghZGV2KQorCQkJCQlyZXR1cm4gLUVOT0RFVjsKKwkJCX0JCQkKKwkJCXJldHVybiBhdHJ0cl9jcmVhdGUoJnJ0LCBkZXYpOworCQl9CisJfQorCXJldHVybiAtRUlOVkFMOworfQorCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKipcCisqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqCisqIEhhbmRsaW5nIGZvciBzeXN0ZW0gY2FsbHMgYXBwbGllZCB2aWEgdGhlIHZhcmlvdXMgaW50ZXJmYWNlcyB0byBhbiAgICAgICAqCisqIEFwcGxlVGFsayBzb2NrZXQgb2JqZWN0LiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqCisqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqCitcKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisKKy8qCisgKiBDaGVja3N1bTogVGhpcyBpcyAnb3B0aW9uYWwnLiBJdCdzIHF1aXRlIGxpa2VseSBhbHNvIGEgZ29vZAorICogY2FuZGlkYXRlIGZvciBhc3NlbWJsZXIgaGFja2VyeSA4KQorICovCitzdGF0aWMgdW5zaWduZWQgbG9uZyBhdGFsa19zdW1fcGFydGlhbChjb25zdCB1bnNpZ25lZCBjaGFyICpkYXRhLCAKKwkJCQkgICAgICAgaW50IGxlbiwgdW5zaWduZWQgbG9uZyBzdW0pCit7CisJLyogVGhpcyBvdWdodCB0byBiZSB1bndyYXBwZWQgbmVhdGx5LiBJJ2xsIHRydXN0IGdjYyBmb3Igbm93ICovCisJd2hpbGUgKGxlbi0tKSB7CisJCXN1bSArPSAqZGF0YTsKKwkJc3VtIDw8PSAxOworCQlpZiAoc3VtICYgMHgxMDAwMCkgeworCQkJc3VtKys7CisJCQlzdW0gJj0gMHhmZmZmOworCQl9CisJCWRhdGErKzsKKwl9CisJcmV0dXJuIHN1bTsKK30KKworLyogIENoZWNrc3VtIHNrYiBkYXRhIC0tICBzaW1pbGFyIHRvIHNrYl9jaGVja3N1bSAgKi8KK3N0YXRpYyB1bnNpZ25lZCBsb25nIGF0YWxrX3N1bV9za2IoY29uc3Qgc3RydWN0IHNrX2J1ZmYgKnNrYiwgaW50IG9mZnNldCwKKwkJCQkgICBpbnQgbGVuLCB1bnNpZ25lZCBsb25nIHN1bSkKK3sKKwlpbnQgc3RhcnQgPSBza2JfaGVhZGxlbihza2IpOworCWludCBpLCBjb3B5OworCisJLyogY2hlY2tzdW0gc3R1ZmYgaW4gaGVhZ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glZCBieXRlcykgZGV0ZWN0ZWQuXG4iLCBhdG9taWNfcmVhZCgmc2stPnNrX3dtZW1fYWxsb2MpKTsKK30KKworc3RhdGljIHZvaWQgdmNjX2RlZl93YWtldXAoc3RydWN0IHNvY2sgKnNrKQoreworCXJlYWRfbG9jaygmc2stPnNrX2NhbGxiYWNrX2xvY2spOworCWlmIChzay0+c2tfc2xlZXAgJiYgd2FpdHF1ZXVlX2FjdGl2ZShzay0+c2tfc2xlZXApKQorCQl3YWtlX3VwKHNrLT5za19zbGVlcCk7CisJcmVhZF91bmxvY2soJnNrLT5za19jYWxsYmFja19sb2NrKTsKK30KKworc3RhdGljIGlubGluZSBpbnQgdmNjX3dyaXRhYmxlKHN0cnVjdCBzb2NrICpzaykKK3sKKwlzdHJ1Y3QgYXRtX3ZjYyAqdmNjID0gYXRtX3NrKHNrKTsKKworCXJldHVybiAodmNjLT5xb3MudHh0cC5tYXhfc2R1ICsKKwkgICAgICAgIGF0b21pY19yZWFkKCZzay0+c2tfd21lbV9hbGxvYykpIDw9IHNrLT5za19zbmRidWY7Cit9CisKK3N0YXRpYyB2b2lkIHZjY193cml0ZV9zcGFjZShzdHJ1Y3Qgc29jayAqc2spCit7ICAgICAgIAorCXJlYWRfbG9jaygmc2stPnNrX2NhbGxiYWNrX2xvY2spOworCisJaWYgKHZjY193cml0YWJsZShzaykpIHsKKwkJaWYgKHNrLT5za19zbGVlcCAmJiB3YWl0cXVldWVfYWN0aXZlKHNrLT5za19zbGVlcCkpCisJCQl3YWtlX3VwX2ludGVycnVwdGlibGUoc2stPnNrX3NsZWVwKTsKKworCQlza193YWtlX2FzeW5jKHNrLCAyLCBQT0xMX09VVCk7CisJfQorCisJcmVhZF91bmxvY2soJnNrLT5za19jYWxsYmFja19sb2NrKTsKK30KKworc3RhdGljIHN0cnVjdCBwcm90byB2Y2NfcHJvdG8gPSB7CisJLm5hbWUJICA9ICJWQ0MiLAorCS5vd25lcgkgID0gVEhJU19NT0RVTEUsCisJLm9ial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I2RlZmluZSBEUFJJTlRLIHByaW50aworI2Vsc2UKKyNkZWZpbmUgRFBSSU5USyhmb3JtYXQsYXJncy4uLikKKyNlbmRpZgorCisjZGVmaW5lIERVTVBfUEFDS0VUUyAwIC8qIDAgPSBOb25lLAorICAgICAgICAgICAgICAgICAgICAgICAgKiAxID0gMzAgZmlyc3QgYnl0ZXMKKyAgICAgICAgICAgICAgICAgICAgICAgICogMiA9IFdob2xlIHBhY2tldAorICAgICAgICAgICAgICAgICAgICAgICAgKi8KKworI2RlZmluZSBMRUNfVU5SRVNfUVVFX0xFTiA4IC8qIG51bWJlciBvZiB0eCBwYWNrZXRzIHRvIHF1ZXVlIGZvciBhCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2luZ2xlIGRlc3RpbmF0aW9uIHdoaWxlIHdhaXRpbmcgZm9yIFNWQyAqLworCitzdGF0aWMgaW50IGxlY19vcGVuKHN0cnVjdCBuZXRfZGV2aWNlICpkZXYpOworc3RhdGljIGludCBsZWNfc3RhcnRfeG1pdChzdHJ1Y3Qgc2tfYnVmZiAqc2tiLCBzdHJ1Y3QgbmV0X2RldmljZSAqZGV2KTsKK3N0YXRpYyBpbnQgbGVjX2Nsb3NlKHN0cnVjdCBuZXRfZGV2aWNlICpkZXYpOworc3RhdGljIHN0cnVjdCBuZXRfZGV2aWNlX3N0YXRzICpsZWNfZ2V0X3N0YXRzKHN0cnVjdCBuZXRfZGV2aWNlICpkZXYpOworc3RhdGljIHZvaWQgbGVjX2luaXQoc3RydWN0IG5ldF9kZXZpY2UgKmRldik7CitzdGF0aWMgc3RydWN0IGxlY19hcnBfdGFibGUqIGxlY19hcnBfZmluZChzdHJ1Y3QgbGVjX3ByaXYgKnByaXYsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVuc2lnbmVkIGNoYXIgKm1hY19hZGRyKTsKK3N0YXRpYyBpbnQgbGVjX2FycF9yZW1vdmUoc3RydWN0IGxlY19w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GV0aGhkciAqKXNrYi0+ZGF0YTsKKyAgICAgICAgYnVmZiA9IHNrYi0+ZGF0YSArIHNrYi0+ZGV2LT5oYXJkX2hlYWRlcl9sZW47CisgICAgICAgIGlmICgqYnVmZisrID09IDB4NDIgJiYgKmJ1ZmYrKyA9PSAweDQyICYmICpidWZmKysgPT0gMHgwMykgeworCQlzdHJ1Y3Qgc29jayAqc2s7CisgICAgICAgICAgICAgICAgc3RydWN0IHNrX2J1ZmYgKnNrYjI7CisgICAgICAgICAgICAgICAgc3RydWN0IGF0bWxlY19tc2cgKm1lc2c7CisKKyAgICAgICAgICAgICAgICBza2IyID0gYWxsb2Nfc2tiKHNpemVvZihzdHJ1Y3QgYXRtbGVjX21zZyksIEdGUF9BVE9NSUMpOworICAgICAgICAgICAgICAgIGlmIChza2IyID09IE5VTEwpIHJldHVybjsKKyAgICAgICAgICAgICAgICBza2IyLT5sZW4gPSBzaXplb2Yoc3RydWN0IGF0bWxlY19tc2cpOworICAgICAgICAgICAgICAgIG1lc2cgPSAoc3RydWN0IGF0bWxlY19tc2cgKilza2IyLT5kYXRhOworICAgICAgICAgICAgICAgIG1lc2ctPnR5cGUgPSBsX3RvcG9sb2d5X2NoYW5nZTsKKyAgICAgICAgICAgICAgICBidWZmICs9IDQ7CisgICAgICAgICAgICAgICAgbWVzZy0+Y29udGVudC5ub3JtYWwuZmxhZyA9ICpidWZmICYgMHgwMTsgLyogMHgwMSBpcyB0b3BvbG9neSBjaGFuZ2UgKi8KKworICAgICAgICAgICAgICAgIHByaXYgPSAoc3RydWN0IGxlY19wcml2ICopZGV2LT5wcml2OworICAgICAgICAgICAgICAgIGF0bV9mb3JjZV9jaGFyZ2UocHJpdi0+bGVjZCwgc2tiMi0+dHJ1ZXNpemUpOworCQlzayA9IHNrX2F0bShwcml2LT5sZWNkKTsKKyAgICAgICAgICAgICAgICBza2JfcXVldWVfdGFpbCgmc2stPnNrX3JlY2VpdmVfcXVldWUsIHNrYjIpOworICAgICAgICAgICAgIC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MF0gJiBUUl9SSUkpIHsKKyAgICAgICAgICAgICAgICByaWZsZW4gPSAobnRvaHModHJoLT5yY2YpICYgVFJfUkNGX0xFTl9NQVNLKSA+PiA4OworICAgICAgICAgICAgICAgIGlmICgobnRvaHModHJoLT5yY2YpID4+IDEzKSAhPSAwKQorICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGJ1c19tYWM7IC8qIEFSRSBvciBTVEUgKi8KKyAgICAgICAgfQorICAgICAgICBlbHNlCisgICAgICAgICAgICAgICAgcmV0dXJuIHRyaC0+ZGFkZHI7IC8qIG5vdCBzb3VyY2Ugcm91dGVkICovCisKKyAgICAgICAgaWYgKHJpZmxlbiA8IDYpCisgICAgICAgICAgICAgICAgcmV0dXJuIHRyaC0+ZGFkZHI7IC8qIGxhc3QgaG9wLCBzb3VyY2Ugcm91dGVkICovCisgICAgICAgICAgICAgICAgCisgICAgICAgIC8qIHJpZmxlbiBpcyA2IG9yIG1vcmUsIHBhY2tldCBoYXMgbW9yZSB0aGFuIG9uZSByb3V0ZSBkZXNjcmlwdG9yICovCisgICAgICAgIG51bV9yZHNjID0gKHJpZmxlbi8yKSAtIDE7CisgICAgICAgIG1lbXNldChyZGVzYywgMCwgRVRIX0FMRU4pOworICAgICAgICAvKiBvZmZzZXQgNCBjb21lcyBmcm9tIExBTiBkZXN0aW5hdGlvbiBmaWVsZCBpbiBMRSBjb250cm9sIGZyYW1lcyAqLworICAgICAgICBpZiAodHJoLT5yY2YgJiBodG9ucygodWludDE2X3QpVFJfUkNGX0RJUl9CSVQpKQorICAgICAgICAgICAgICAgIG1lbWNweSgmcmRlc2NbNF0sICZ0cmgtPnJzZWdbbnVtX3Jkc2MtMl0sIHNpemVvZih1aW50MTZfdCkpOworICAgICAgICBlbHNlIHsKKyAgICAgICAgICAgICAgICBtZW1jcHkoJnJkZXNjWzRdLCAmdHJoLT5yc2VnWzFdLCBzaXplb2YodWludDE2X3QpKTsKKyAgICAgICAgICAgICAgICByZGVzY1s1XSA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IgKi8KKyNlbmRpZgorICAgICAgICBpbnQgaXNfcmRlc2M7CisjaWYgRFVNUF9QQUNLRVRTID4gMAorICAgICAgICBjaGFyIGJ1ZlszMDBdOworICAgICAgICBpbnQgaT0wOworI2VuZGlmIC8qIERVTVBfUEFDS0VUUyA+MCAqLworICAgICAgICAKKyAgICAgICAgRFBSSU5USygibGVjX3N0YXJ0X3htaXQgY2FsbGVkXG4iKTsgIAorICAgICAgICBpZiAoIXByaXYtPmxlY2QpIHsKKyAgICAgICAgICAgICAgICBwcmludGsoIiVzOk5vIGxlY2QgYXR0YWNoZWRcbiIsZGV2LT5uYW1lKTsKKyAgICAgICAgICAgICAgICBwcml2LT5zdGF0cy50eF9lcnJvcnMrKzsKKyAgICAgICAgICAgICAgICBuZXRpZl9zdG9wX3F1ZXVlKGRldik7CisgICAgICAgICAgICAgICAgcmV0dXJuIC1FVU5BVENIOworICAgICAgICB9IAorCisgICAgICAgIERQUklOVEsoInNrYnVmZiBoZWFkOiVseCBkYXRhOiVseCB0YWlsOiVseCBlbmQ6JWx4XG4iLAorICAgICAgICAgICAgICAgIChsb25nKXNrYi0+aGVhZCwgKGxvbmcpc2tiLT5kYXRhLCAobG9uZylza2ItPnRhaWwsCisgICAgICAgICAgICAgICAgKGxvbmcpc2tiLT5lbmQpOworI2lmIGRlZmluZWQoQ09ORklHX0JSSURHRSkgfHwgZGVmaW5lZChDT05GSUdfQlJJREdFX01PRFVMRSkKKyAgICAgICAgaWYgKG1lbWNtcChza2ItPmRhdGEsIGJyaWRnZV91bGFfbGVjLCBzaXplb2YoYnJpZGdlX3VsYV9sZWMpKSA9PSAwKQorICAgICAgICAgICAgICAgIGxlY19oYW5kbGVfYnJpZGdlKHNrYiwgZGV2KTsKKyNlbmRpZgorCisgICAgICAgIC8qIE1ha2Ugc3VyZSB3ZSBoYXZlIHJvb20gZm9yIGxlY19pZCAqLworICAgICAgICBpZiAoc2tiX2hlYWRyb29tKHNrYikgPCAyKSB7CisKKyAgICAgICAgICAgICAgICBEUFJJTlRLKCJsZWNfc3RhcnRfeG1pdDogcmVhbGxvY2F0aW5nIHNrYlxuIik7CisgICAgICAgICAgICAgICAgc2tiMiA9IHNrYl9yZWFsbG9jX2hlYWRyb29tKHNrYiwgTEVDX0hFQURFUl9MRU4pOworICAgICAgICAgICAgICAgIGtmcmVlX3NrYihza2IpOworICAgICAgICAgICAgICAgIGlmIChza2IyID09IE5VTEwpIHJldHVybiAwOworICAgICAgICAgICAgICAgIHNrYiA9IHNrYjI7CisgICAgICAgIH0KKyAgICAgICAgc2tiX3B1c2goc2tiLCAyKTsKKworICAgICAgICAvKiBQdXQgbGUgaGVhZGVyIHRvIHBsYWNlLCB3b3JrcyBmb3IgVG9rZW5SaW5nIHRvbyAqLworICAgICAgICBsZWNfaCA9IChzdHJ1Y3QgbGVjZGF0YWhkcl84MDIzKilza2ItPmRhdGE7CisgICAgICAgIGxlY19oLT5sZV9oZWFkZXIgPSBodG9ucyhwcml2LT5sZWNpZCk7IAorCisjaWZkZWYgQ09ORklHX1RSCisgICAgICAgIC8qIFVnbHkuIFVzZSB0aGlzIHRvIHJlYWxpZ24gVG9rZW4gUmluZyBwYWNrZXRzIGZvcgorICAgICAgICAgKiBlLmcuIFBDQS0yMDBFIGRyaXZlci4gKi8KKyAgICAgICAgaWYgKHByaXYtPmlzX3RyZGV2KSB7CisgICAgICAgICAgICAgICAgc2tiMiA9IHNrYl9yZWFsbG9jX2hlYWRyb29tKHNrYiwgTEVDX0hFQURFUl9MRU4pOworICAgICAgICAgICAgICAgIGtmcmVlX3NrYihza2IpOworICAgICAgICAgICAgICAgIGlmIChza2IyID09IE5VTEwpIHJldHVybiAwOworICAgICAgICAgICAgICAgIHNrYiA9IHNrYjI7CisgICAgICAgIH0KKyNlbmRpZgorCisjaWYgRFVNUF9QQUNLRVRTID4gMAorICAgICAgICBwcmludGsoIiVzOiBzZW5kIGRhdGFsZW46JWxkIGxlY2lkOiU0LjR4XG4iLCBkZXYtPm5hbWUsCisgICAgICAgICAgICAgICBza2ItPmxlbiwgcHJpdi0+bGVjaWQpOworI2lmIERVTVBfUEFDS0VUUyA+PSAyCisgICAgICAgIGZvcihpPTA7aTxza2ItPmxlbiAmJiBpIDw5OTtpKyspIHsKKyAgICAgICAgICAgICAgICBzcHJpbnRmKGJ1ZitpKjMsIiUyLjJ4ICIsMHhmZiZza2ItPmRhdGFbaV0pOworICAgICAgICB9CisjZWxpZiBEVU1QX1BBQ0tFVFMgPj0gMQorICAgICAgICBmb3IoaT0wO2k8c2tiLT5sZW4gJiYgaSA8IDMwO2krKykgeworICAgICAgICAgICAgICAgIHNwcmludGYoYnVmK2kqMywiJTIuMnggIiwgMHhmZiZza2ItPmRhdGFbaV0pOworICAgICAgICB9CisjZW5kaWYgLyogRFVNUF9QQUNLRVRTID49IDEgKi8KKyAgICAgICAgaWYgKGk9PXNrYi0+bGVuKQorICAgICAgICAgICAgICAgIHByaW50aygiJXNcbiIsYnVmKTsKKyAgICAgICAgZWxzZQorICAgICAgICAgICAgICAgIHByaW50aygiJXMuLi5cbiIsYnVmKTsKKyNlbmRpZiAvKiBEVU1QX1BBQ0tFVFMgPiAwICovCisKKyAgICAgICAgLyogTWluaW11bSBldGhlcm5ldC1mcmFtZSBzaXplICovCisjaWZkZWYgQ09ORklHX1RSCisgICAgICAgIGlmIChwcml2LT5pc190cmRldikKKyAgICAgICAgICAgICAgICBtaW5fZnJhbWVfc2l6ZSA9IExFQ19NSU5JTVVNXzgwMjVfU0laRTsKKwllbHNlCisjZW5kaWYKKyAgICAgICAgbWluX2ZyYW1lX3NpemUgPSBMRUNfTUlOSU1VTV84MDIzX1NJWkU7CisgICAgICAgIGlmIChza2ItPmxlbiA8IG1pbl9mcmFtZV9zaXplKSB7CisgICAgICAgICAgICAgICAgaWYgKChza2ItPmxlbiArIHNrYl90YWlscm9vbShza2IpKSA8IG1pbl9mcmFtZV9zaXplKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBza2IyID0gc2tiX2NvcHlfZXhwYW5kKHNrYiwgMCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW5fZnJhbWVfc2l6ZSAtIHNrYi0+dHJ1ZXNpemUsIEdGUF9BVE9NSUMpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXZfa2ZyZWVfc2tiKHNrYik7CisgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc2tiMiA9PSBOVUxMKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByaXYtPnN0YXRzLnR4X2Ryb3BwZWQrKzsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIDA7CisgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgICAgICBza2IgPSBza2IyOworICAgICAgICAgICAgICAgIH0KKwkJc2tiX3B1dChza2IsIG1pbl9mcmFtZV9zaXplIC0gc2tiLT5sZW4pOworICAgICAgICB9CisgICAgICAgIAorICAgICAgICAvKiBTZW5kIHRvIHJpZ2h0IHZjYyAqLworICAgICAgICBpc19yZGVzYyA9IDA7CisgICAgICAgIGRzdCA9IGxlY19oLT5oX2Rlc3Q7CisjaWZkZWYgQ09ORklHX1RSCisgICAgICAgIGlmIChwcml2LT5pc190cmRldikgeworICAgICAgICAgICAgICAgIGRzdCA9IGdldF90cl9kc3Qoc2tiLT5kYXRhKzIsIHJkZXNjKTsKKyAgICAgICAgICAgICAgICBpZiAoZHN0ID09IE5VTEwpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIGRzdCA9IHJkZXNjOworICAgICAgICAgICAgICAgICAgICAgICAgaXNfcmRlc2MgPSAxOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgfQorI2VuZGlmCisgICAgICAgIGVudHJ5ID0gTlVMTDsKKyAgICAgICAgdmNjID0gbGVjX2FycF9yZXNvbHZlKHByaXYsIGRzdCwgaXNfcmRlc2MsICZlbnRyeSk7CisgICAgICAgIERQUklOVEsoIiVzOnZjYzolcCB2Y2NfZmxhZ3M6JXgsIGVudHJ5OiVwXG4iLCBkZXYtPm5hbWUsCisgICAgICAgICAgICAgICAgdmNjLCB2Y2M/dmNjLT5mbGFnczowLCBlbnRyeSk7CisgICAgICAgIGlmICghdmNjIHx8ICF0ZXN0X2JpdChBVE1fVkZfUkVBRFksJnZjYy0+ZmxhZ3MpKSB7ICAgIAorICAgICAgICAgICAgICAgIGlmIChlbnRyeSAmJiAoZW50cnktPnR4X3dhaXQucWxlbiA8IExFQ19VTlJFU19RVUVfTEVOKSkgeworICAgICAgICAgICAgICAgICAgICAgICAgRFBSSU5USygiJXM6bGVjX3N0YXJ0X3htaXQ6IHF1ZXVpbmcgcGFja2V0LCAiLCBkZXYtPm5hbWUpOworICAgICAgICAgICAgICAgICAgICAgICAgRFBSSU5USygiTUFDIGFkZHJlc3MgMHglMDJ4OiUwMng6JTAyeDolMDJ4OiUwMng6JTAyeFxuIiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGVjX2gtPmhfZGVzdFswXSwgbGVjX2gtPmhfZGVzdFsxXSwgbGVjX2gtPmhfZGVzdFsyXSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGVjX2gtPmhfZGVzdFszXSwgbGVjX2gtPmhfZGVzdFs0XSwgbGVjX2gtPmhfZGVzdFs1XSk7CisgICAgICAgICAgICAgICAgICAgICAgICBza2JfcXVldWVfdGFpbCgmZW50cnktPnR4X3dhaXQsIHNrYik7CisgICAgICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIERQUklOVEsoIiVzOmxlY19zdGFydF94bWl0OiB0eCBxdWV1ZSBmdWxsIG9yIG5vIGFycCBlbnRyeSwgZHJvcHBpbmcsICIsIGRldi0+bmFtZSk7CisgICAgICAgICAgICAgICAgICAgICAgICBEUFJJTlRLKCJNQUMgYWRkcmVzcyAweCUwMng6JTAyeDolMDJ4OiUwMng6JTAyeDolMDJ4XG4iLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZWNfaC0+aF9kZXN0WzBdLCBsZWNfaC0+aF9kZXN0WzFdLCBsZWNfaC0+aF9kZXN0WzJdLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZWNfaC0+aF9kZXN0WzNdLCBsZWNfaC0+aF9kZXN0WzRdLCBsZWNfaC0+aF9kZXN0WzVdKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHByaXYtPnN0YXRzLnR4X2Ryb3BwZWQrKzsKKyAgICAgICAgICAgICAgICAgICAgICAgIGRldl9rZnJlZV9za2Ioc2tiKTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgcmV0dXJuIDA7CisgICAgICAgIH0KKyAgICAgICAgICAgICAgICAKKyNpZiBEVU1QX1BBQ0tFVFMgPiAwICAgICAgICAgICAgICAgICAgICAKKyAgICAgICAgcHJpbnRrKCIlczpzZW5kaW5nIHRvIHZwaTolZCB2Y2k6JWRcbiIsIGRldi0+bmFtZSwKKyAgICAgICAgICAgICAgIHZjYy0+dnBpLCB2Y2MtPnZjaSk7ICAgICAgIAorI2VuZGlmIC8qIERVTVBfUEFDS0VUUyA+IDAgKi8KKyAgICAgICAgICAgICAgICAKKyAgICAgICAgd2hpbGUgKGVudHJ5ICYmIChza2IyID0gc2tiX2RlcXVldWUoJmVudHJ5LT50eF93YWl0KSkpIHsKKyAgICAgICAgICAgICAgICBEUFJJTlRLKCJsZWMuYzogZW1wdHlpbmcgdHggcXVldWUsICIpOworICAgICAgICAgICAgICAgIERQUklOVEsoIk1BQyBhZGRyZXNzIDB4JTAyeDolMDJ4OiUwMng6JTAyeDolMDJ4OiUwMnhcbiIsCisgICAgICAgICAgICAgICAgICAgICAgICBsZWNfaC0+aF9kZXN0WzBdLCBsZWNfaC0+aF9kZXN0WzFdLCBsZWNfaC0+aF9kZXN0WzJdLAorICAgICAgICAgICAgICAgICAgICAgICAgbGVjX2gtPmhfZGVzdFszXSwgbGVjX2gtPmhfZGVzdFs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KK3sKKyAgICAgICAgcmV0dXJuICYoKHN0cnVjdCBsZWNfcHJpdiAqKWRldi0+cHJpdiktPnN0YXRzOworfQorCitzdGF0aWMgaW50IAorbGVjX2F0bV9zZW5kKHN0cnVjdCBhdG1fdmNjICp2Y2MsIHN0cnVjdCBza19idWZmICpza2IpCit7CisJdW5zaWduZWQgbG9uZyBmbGFnczsKKyAgICAgICAgc3RydWN0IG5ldF9kZXZpY2UgKmRldiA9IChzdHJ1Y3QgbmV0X2RldmljZSopdmNjLT5wcm90b19kYXRhOworICAgICAgICBzdHJ1Y3QgbGVjX3ByaXYgKnByaXYgPSAoc3RydWN0IGxlY19wcml2KilkZXYtPnByaXY7CisgICAgICAgIHN0cnVjdCBhdG1sZWNfbXNnICptZXNnOworICAgICAgICBzdHJ1Y3QgbGVjX2FycF90YWJsZSAqZW50cnk7CisgICAgICAgIGludCBpOworICAgICAgICBjaGFyICp0bXA7IC8qIEZJWE1FICovCisKKwlhdG9taWNfc3ViKHNrYi0+dHJ1ZXNpemUsICZza19hdG0odmNjKS0+c2tfd21lbV9hbGxvYyk7CisgICAgICAgIG1lc2cgPSAoc3RydWN0IGF0bWxlY19tc2cgKilza2ItPmRhdGE7CisgICAgICAgIHRtcCA9IHNrYi0+ZGF0YTsKKyAgICAgICAgdG1wICs9IHNpemVvZihzdHJ1Y3QgYXRtbGVjX21zZyk7CisgICAgICAgIERQUklOVEsoIiVzOiBtc2cgZnJvbSB6ZXBwZWxpbjolZFxuIiwgZGV2LT5uYW1lLCBtZXNnLT50eXBlKTsKKyAgICAgICAgc3dpdGNoKG1lc2ctPnR5cGUpIHsKKyAgICAgICAgY2FzZSBsX3NldF9tYWNfYWRkcjoKKyAgICAgICAgICAgICAgICBmb3IgKGk9MDtpPDY7aSsrKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBkZXYtPmRldl9hZGRyW2ldID0gbWVzZy0+Y29udGVudC5ub3JtYWwubWFjX2FkZHJbaV07CisgICAgICAgICAgICAgICAgfSAgICAKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgY2FzZSBsX2RlbF9tYWNfYWRkcjoKKyAgICAgICAgICAgICAgICBmb3IoaT0wO2k8NjtpKyspIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIGRldi0+ZGV2X2FkZHJbaV0gPSAwOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgY2FzZSBsX2FkZHJfZGVsZXRlOgorICAgICAgICAgICAgICAgIGxlY19hZGRyX2RlbGV0ZShwcml2LCBtZXNnLT5jb250ZW50Lm5vcm1hbC5hdG1fYWRkciwgCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1lc2ctPmNvbnRlbnQubm9ybWFsLmZsYWcpOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICBjYXNlIGxfdG9wb2xvZ3lfY2hhbmdlOgorICAgICAgICAgICAgICAgIHByaXYtPnRvcG9sb2d5X2NoYW5nZSA9IG1lc2ctPmNvbnRlbnQubm9ybWFsLmZsYWc7ICAKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgY2FzZSBsX2ZsdXNoX2NvbXBsZXRlOgorICAgICAgICAgICAgICAgIGxlY19mbHVzaF9jb21wbGV0ZShwcml2LCBtZXNnLT5jb250ZW50Lm5vcm1hbC5mbGFnKTsKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgY2FzZSBsX25hcnBfcmVxOiAvKiBMQU5FMjogc2VlIDcuMS4zNSBpbiB0aGUgbGFuZTIgc3BlYyAqLworCQlzcGluX2xvY2tfaXJxc2F2ZSgmcHJpdi0+bGVjX2FycF9sb2NrLCBmbGFncyk7CisgICAgICAgICAgICAgICAgZW50cnkgPSBsZWNfYXJwX2ZpbmQocHJpdiwgbWVzZy0+Y29udGVudC5ub3JtYWwubWFjX2FkZHIpOworICAgICAgICAgICAgICAgIGxlY19hcnBfcmVtb3ZlKHByaXYsIGVudHJ5KTsKKwkJc3Bpbl91bmxvY2tfaXJxcmVzdG9yZSgmcHJpdi0+bGVjX2FycF9sb2NrLCBmbGFncyk7CisKKyAgICAgICAgICAgICAgICBpZiAobWVzZy0+Y29udGVudC5ub3JtYWwubm9fc291cmNlX2xlX25hcnApCisgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgICAvKiBGQUxMIFRIUk9VR0ggKi8KKyAgICAgICAgY2FzZSBsX2FycF91cGRhdGU6CisgICAgICAgICAgICAgICAgbGVjX2FycF91cGRhdGUocHJpdiwgbWVzZy0+Y29udGVudC5ub3JtYWwubWFjX2FkZHIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWVzZy0+Y29udGVudC5ub3JtYWwuYXRtX2FkZHIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWVzZy0+Y29udGVudC5ub3JtYWwuZmxhZywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtZXNnLT5jb250ZW50Lm5vcm1hbC50YXJnZXRsZXNzX2xlX2FycCk7CisgICAgICAgICAgICAgICAgRFBSSU5USygibGVjOiBpbiBsX2FycF91cGRhdGVcbiIpOworICAgICAgICAgICAgICAgIGlmIChtZXNnLT5zaXplb2Z0bHZzICE9IDApIHsgLyogTEFORTIgMy4xLjUgKi8KKyAgICAgICAgICAgICAgICAgICAgICAgIERQUklOVEsoImxlYzogTEFORTIgMy4xLjUsIGdvdCB0bHZzLCBzaXplICVkXG4iLCBtZXNnLT5zaXplb2Z0bHZzKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGxhbmUyX2Fzc29jaWF0ZV9pbmQoZGV2LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtZXNnLT5jb250ZW50Lm5vcm1hbC5tYWNfYWRkciwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdG1wLCBtZXNnLT5zaXplb2Z0bHZzKTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIGNhc2UgbF9jb25maWc6CisgICAgICAgICAgICAgICAgcHJpdi0+bWF4aW11bV91bmtub3duX2ZyYW1lX2NvdW50ID0gCisgICAgICAgICAgICAgICAgICAgICAgICBtZXNnLT5jb250ZW50LmNvbmZpZy5tYXhpbXVtX3Vua25vd25fZnJhbWVfY291bnQ7CisgICAgICAgICAgICAgICAgcHJpdi0+bWF4X3Vua25vd25fZnJhbWVfdGltZSA9IAorICAgICAgICAgICAgICAgICAgICAgICAgKG1lc2ctPmNvbnRlbnQuY29uZmlnLm1heF91bmtub3duX2ZyYW1lX3RpbWUqSFopOworICAgICAgICAgICAgICAgIHByaXYtPm1heF9yZXRyeV9jb3VudCA9IAorICAgICAgICAgICAgICAgICAgICAgICAgbWVzZy0+Y29udGVudC5jb25maWcubWF4X3JldHJ5X2NvdW50OworICAgICAgICAgICAgICAgIHByaXYtPmFnaW5nX3RpbWUgPSAobWVzZy0+Y29udGVudC5jb25maWcuYWdpbmdfdGltZSpIWik7CisgICAgICAgICAgICAgICAgcHJpdi0+Zm9yd2FyZF9kZWxheV90aW1lID0gCisgICAgICAgICAgICAgICAgICAgICAgICAobWVzZy0+Y29udGVudC5jb25maWcuZm9yd2FyZF9kZWxheV90aW1lKkhaKTsKKyAgICAgICAgICAgICAgICBwcml2LT5hcnBfcmVzcG9uc2VfdGltZSA9IAorICAgICAgICAgICAgICAgICAgICAgICAgKG1lc2ctPmNvbnRlbnQuY29uZmlnLmFycF9yZXNwb25zZV90aW1lKkhaKTsKKyAgICAgICAgICAgICAgICBwcml2LT5mbHVzaF90aW1lb3V0ID0gKG1lc2ctPmNvbnRlbnQuY29uZmlnLmZsdXNoX3RpbWVvdXQqSFopOworICAgICAgICAgICAgICAgIHByaXYtPnBhdGhfc3dpdGNoaW5nX2RlbGF5ID0gCisgICAgICAgICAgICAgICAgICAgICAgICAobWVzZy0+Y29udGVudC5jb25maWcucGF0aF9zd2l0Y2hpbmdfZGVsYXkqSFopOworICAgICAgICAgICAgICAgIHByaXYtPmxhbmVfdmVyc2lvbiA9IG1lc2ctPmNvbnRlbnQuY29uZmlnLmxhbmVfdmVyc2lvbjsgLyogTEFORTIgKi8KKwkJcHJpdi0+bGFuZTJfb3BzID0gTlVMTDsKKwkJaWYgKHByaXYtPmxhbmVfdmVyc2lvbiA+IDEpCisJCQlwcml2LT5sYW5lMl9vcHMgPSAmbGFuZTJfb3BzOworCQlpZiAoZGV2LT5jaGFuZ2VfbXR1KGRldiwgbWVzZy0+Y29udGVudC5jb25maWcubXR1KSkKKwkJCXByaW50aygiJXM6IGNoYW5nZV9tdHUgdG8gJWQgZmFpbGVkXG4iLCBkZXYtPm5hbWUsCisJCQkgICAgbWVzZy0+Y29udGVudC5jb25maWcubXR1KTsKKwkJcHJpdi0+aXNfcHJveHkgPSBtZXNnLT5jb250ZW50LmNvbmZpZy5pc19wcm94eTsKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgY2FzZSBsX2ZsdXNoX3RyYW5faWQ6CisgICAgICAgICAgICAgICAgbGVjX3NldF9mbHVzaF90cmFuX2lkKHByaXYsIG1lc2ctPmNvbnRlbnQubm9ybWFsLmF0bV9hZGRyLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtZXNnLT5jb250ZW50Lm5vcm1hbC5mbGFnKTsKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgY2FzZSBsX3NldF9sZWNpZDoKKyAgICAgICAgICAgICAgICBwcml2LT5sZWNpZD0odW5zaWduZWQgc2hvcnQpKDB4ZmZmZiZtZXNnLT5jb250ZW50Lm5vcm1hbC5mbGFnKTsKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgY2FzZSBsX3Nob3VsZF9icmlkZ2U6IHsKKyNpZiBkZWZpbmVkKENPTkZJR19CUklER0UpIHx8IGRlZmluZWQoQ09ORklHX0JSSURHRV9NT0RVTEUpCisgICAgICAgICAgICAgICAgc3RydWN0IG5ldF9icmlkZ2VfZmRiX2VudHJ5ICpmOworCisgICAgICAgICAgICAgICAgRFBSSU5USygiJXM6IGJyaWRnZSB6ZXBwZWxpbiBhc2tzIGFib3V0IDB4JTAyeDolMDJ4OiUwMng6JTAyeDolMDJ4OiUwMnhcbiIsCisgICAgICAgICAgICAgICAgICAgICAgICBkZXYtPm5hbWUsCisgICAgICAgICAgICAgICAgICAgICAgICBtZXNnLT5jb250ZW50LnByb3h5Lm1hY19hZGRyWzBdLCBtZXNnLT5jb250ZW50LnByb3h5Lm1hY19hZGRyWzFdLAorICAgICAgICAgICAgICAgICAgICAgICAgbWVzZy0+Y29udGVudC5wcm94eS5tYWNfYWRkclsyXSwgbWVzZy0+Y29udGVudC5wcm94eS5tYWNfYWRkclszXSwKKyAgICAgICAgICAgICAgICAgICAgICAgIG1lc2ctPmNvbnRlbnQucHJveHkubWFjX2FkZHJbNF0sIG1lc2ctPmNvbnRlbnQucHJveHkubWFjX2FkZHJbNV0pOworCisgICAgICAgICAgICAgICAgaWYgKGJyX2ZkYl9nZXRfaG9vayA9PSBOVUxMIHx8IGRldi0+YnJfcG9ydCA9PSBOVUxMKQorICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisKKyAgICAgICAgICAgICAgICBmID0gYnJfZmRiX2dldF9ob29rKGRldi0+YnJfcG9ydC0+YnIsIG1lc2ctPmNvbnRlbnQucHJveHkubWFjX2FkZHIpOworICAgICAgICAgICAgICAgIGlmIChmICE9IE5VTEwgJiYKKyAgICAgICAgICAgICAgICAgICAgZi0+ZHN0LT5kZXYgIT0gZGV2ICYmCisgICAgICAgICAgICAgICAgICAgIGYtPmRzdC0+c3RhdGUgPT0gQlJfU1RBVEVfRk9SV0FSRElORykgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvKiBoaXQgZnJvbSBicmlkZ2UgdGFibGUsIHNlbmQgTEVfQVJQX1JFU1BPTlNFICovCisgICAgICAgICAgICAgICAgICAgICAgICBzdHJ1Y3Qgc2tfYnVmZiAqc2tiMjsKKwkJCXN0cnVjdCBzb2NrICpzazsKKworICAgICAgICAgICAgICAgICAgICAgICAgRFBSSU5USygiJXM6IGVudHJ5IGZvdW5kLCByZXNwb25kaW5nIHRvIHplcHBlbGluXG4iLCBkZXYtPm5hbWUpOworICAgICAgICAgICAgICAgICAgICAgICAgc2tiMiA9IGFsbG9jX3NrYihzaXplb2Yoc3RydWN0IGF0bWxlY19tc2cpLCBHRlBfQVRPTUlDKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGlmIChza2IyID09IE5VTEwpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJfZmRiX3B1dF9ob29rKGYpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgICAgIHNrYjItPmxlbiA9IHNpemVvZihzdHJ1Y3QgYXRtbGVjX21zZyk7CisgICAgICAgICAgICAgICAgICAgICAgICBtZW1jcHkoc2tiMi0+ZGF0YSwgbWVzZywgc2l6ZW9mKHN0cnVjdCBhdG1sZWNfbXNnKSk7CisgICAgICAgICAgICAgICAgICAgICAgICBhdG1fZm9yY2VfY2hhcmdlKHByaXYtPmxlY2QsIHNrYjItPnRydWVzaXplKTsKKwkJCXNrID0gc2tfYXRtKHByaXYtPmxlY2QpOworICAgICAgICAgICAgICAgICAgICAgICAgc2tiX3F1ZXVlX3RhaWwoJnNrLT5za19yZWNlaXZlX3F1ZXVlLCBza2IyKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHNrLT5za19kYXRhX3JlYWR5KHNrLCBza2IyLT5sZW4pOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBpZiAoZiAhPSBOVUxMKSBicl9mZGJfcHV0X2hvb2soZik7CisjZW5kaWYgLyogZGVmaW5lZChDT05GSUdfQlJJREdFKSB8fCBkZWZpbmVkKENPTkZJR19CUklER0VfTU9EVUxFKSAqLworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgZGVmYXVsdDoKKyAgICAgICAgICAgICAgICBwcmludGsoIiVzOiBVbmtub3duIG1lc3NhZ2UgdHlwZSAlZFxuIiwgZGV2LT5uYW1lLCBtZXNnLT50eXBlKTsKKyAgICAgICAgICAgICAgICBkZXZfa2ZyZWVfc2tiKHNrYik7CisgICAgICAgICAgICAgICAgcmV0dXJuIC1FSU5WQUw7CisgICAgICAgIH0KKyAgICAgICAgZGV2X2tmcmVlX3NrYihza2IpOworICAgICAgICByZXR1cm4gMDsKK30KKworc3RhdGljIHZvaWQgCitsZWNfYXRtX2Nsb3NlKHN0cnVjdCBhdG1fdmNjICp2Y2MpCit7CisgICAgICAgIHN0cnVjdCBza19idWZmICpza2I7CisgICAgICAgIHN0cnVjdCBuZXRfZGV2aWNlICpkZXYgPSAoc3RydWN0IG5ldF9kZXZpY2UgKil2Y2MtPnByb3RvX2RhdGE7CisgICAgICAgIHN0cnVjdCBsZWNfcHJpdiAqcHJpdiA9IChzdHJ1Y3QgbGVjX3ByaXYgKilkZXYtPnByaXY7CisKKyAgICAgICAgcHJpdi0+bGVjZCA9IE5VTEw7CisgICAgICAgIC8qIERvIHNvbWV0aGluZyBuZWVkZnVsPyAqLworCisgICAgICAgIG5ldGlmX3N0b3BfcXVldWUoZGV2KTsKKyAgICAgICAgbGVjX2FycF9kZXN0cm95KHByaXYpOworCisgICAgICAgIGlmIChza2JfcGVlaygmc2tfYXRtKHZjYyktPnNrX3JlY2VpdmVfcXVldWUpKQorCQlwcmludGsoIiVzIGxlY19hdG1fY2xvc2U6IGNsb3Npbmcgd2l0aCBtZXNzYWdlcyBwZW5kaW5nXG4iLAorICAgICAgICAgICAgICAgICAgICAgICBkZXYtPm5hbWUpOworICAgICAgICB3aGlsZSAoKHNrYiA9IHNrYl9kZXF1ZXVlKCZza19hdG0odmNjKS0+c2tfcmVjZWl2ZV9xdWV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0ZXMgb2YgZGF0YVxuIiwgZGF0YS0+bGVuKTsKKyAgICAgICAgICAgICAgICBhdG1fZm9yY2VfY2hhcmdlKHByaXYtPmxlY2QsIGRhdGEtPnRydWVzaXplKTsKKyAgICAgICAgICAgICAgICBza2JfcXVldWVfdGFpbCgmc2stPnNrX3JlY2VpdmVfcXVldWUsIGRhdGEpOworICAgICAgICAgICAgICAgIHNrLT5za19kYXRhX3JlYWR5KHNrLCBza2ItPmxlbik7CisgICAgICAgIH0KKworICAgICAgICByZXR1cm4gMDsKK30KKworLyogc2hhbWVsZXNzbHkgc3RvbGVuIGZyb20gZHJpdmVycy9uZXQvbmV0X2luaXQuYyAqLworc3RhdGljIGludCBsZWNfY2hhbmdlX210dShzdHJ1Y3QgbmV0X2RldmljZSAqZGV2LCBpbnQgbmV3X210dSkKK3sKKyAgICAgICAgaWYgKChuZXdfbXR1IDwgNjgpIHx8IChuZXdfbXR1ID4gMTgxOTApKQorICAgICAgICAgICAgICAgIHJldHVybiAtRUlOVkFMOworICAgICAgICBkZXYtPm10dSA9IG5ld19tdHU7CisgICAgICAgIHJldHVybiAwOworfQorCitzdGF0aWMgdm9pZCBsZWNfc2V0X211bHRpY2FzdF9saXN0KHN0cnVjdCBuZXRfZGV2aWNlICpkZXYpCit7CisJLyogYnkgZGVmYXVsdCwgYWxsIG11bHRpY2FzdCBmcmFtZXMgYXJyaXZlIG92ZXIgdGhlIGJ1cy4KKyAgICAgICAgICogZXZlbnR1YWxseSBzdXBwb3J0IHNlbGVjdGl2ZSBtdWx0aWNhc3Qgc2VydmljZQorICAgICAgICAgKi8KKyAgICAgICAgcmV0dXJuOworfQorCitzdGF0aWMgdm9pZCAKK2xlY19pbml0KHN0cnVjdCBuZXRfZGV2aWNlICpkZXYpCit7CisgICAgICAgIGRldi0+Y2hhbmdlX210dSA9IGxlY19jaGFuZ2VfbXR1OworICAgICAgICBkZXYtPm9wZW4gPSBsZWNfb3BlbjsKKyAgICAgICAgZGV2LT5zdG9wID0gbGVjX2Nsb3NlOworICAgICAgICBkZXYtPmhhcmRfc3RhcnRfeG1pdCA9IGxlY19zdGFydF94bWl0OworCWRldi0+dHhfdGltZW91dCA9IGxlY190eF90aW1lb3V0OworCisgICAgICAgIGRldi0+Z2V0X3N0YXRzID0gbGVjX2dldF9zdGF0czsKKyAgICAgICAgZGV2LT5zZXRfbXVsdGljYXN0X2xpc3QgPSBsZWNfc2V0X211bHRpY2FzdF9saXN0OworICAgICAgICBkZXYtPmRvX2lvY3RsICA9IE5VTEw7CisgICAgICAgIHByaW50aygiJXM6IEluaXRpYWxpemVkIVxuIixkZXYtPm5hbWUpOworICAgICAgICByZXR1cm47Cit9CisKK3N0YXRpYyB1bnNpZ25lZCBjaGFyIGxlY19jdHJsX21hZ2ljW10gPSB7CisgICAgICAgIDB4ZmYsCisgICAgICAgIDB4MDAsCisgICAgICAgIDB4MDEsCisgICAgICAgIDB4MDEgfTsKKworc3RhdGljIHZvaWQgCitsZWNfcHVzaChzdHJ1Y3QgYXRtX3ZjYyAqdmNjLCBzdHJ1Y3Qgc2tfYnVmZiAqc2tiKQoreworICAgICAgICBzdHJ1Y3QgbmV0X2RldmljZSAqZGV2ID0gKHN0cnVjdCBuZXRfZGV2aWNlICopdmNjLT5wcm90b19kYXRhOworICAgICAgICBzdHJ1Y3QgbGVjX3ByaXYgKnByaXYgPSAoc3RydWN0IGxlY19wcml2ICopZGV2LT5wcml2OyAKKworI2lmIERVTVBfUEFDS0VUUyA+MAorICAgICAgICBpbnQgaT0wOworICAgICAgICBjaGFyIGJ1ZlszMDBdOworCisgICAgICAgIHByaW50aygiJXM6IGxlY19wdXNoIHZjYyB2cGk6JWQgdmNpOiVkXG4iLCBkZXYtPm5hbWUsCisgICAgICAgICAgICAgICB2Y2MtPnZwaSwgdmNjLT52Y2kpOworI2VuZGlmCisgICAgICAgIGlmICghc2tiKSB7CisgICAgICAgICAgICAgICAgRFBSSU5USygiJXM6IG51bGwgc2tiXG4iLGRldi0+bmFtZSk7CisgICAgICAgICAgICAgICAgbGVjX3ZjY19jbG9zZShwcml2LCB2Y2MpOworICAgICAgICAgICAgICAgIHJldHVybjsKKyAgICAgICAgfQorI2lmIERVTVBfUEFDS0VUUyA+IDAKKyAgICAgICAgcHJpbnRrKCIlczogcmN2IGRhdGFsZW46JWxkIGxlY2lkOiU0LjR4XG4iLCBkZXYtPm5hbWUsCisgICAgICAgICAgICAgICBza2ItPmxlbiwgcHJpdi0+bGVjaWQpOworI2lmIERVTVBfUEFDS0VUUyA+PSAyCisgICAgICAgIGZvcihpPTA7aTxza2ItPmxlbiAmJiBpIDw5OTtpKyspIHsKKyAgICAgICAgICAgICAgICBzcHJpbnRmKGJ1ZitpKjMsIiUyLjJ4ICIsMHhmZiZza2ItPmRhdGFbaV0pOworICAgICAgICB9CisjZWxpZiBEVU1QX1BBQ0tFVFMgPj0gMQorICAgICAgICBmb3IoaT0wO2k8c2tiLT5sZW4gJiYgaSA8IDMwO2krKykgeworICAgICAgICAgICAgICAgIHNwcmludGYoYnVmK2kqMywiJTIuMnggIiwgMHhmZiZza2ItPmRhdGFbaV0pOworICAgICAgICB9CisjZW5kaWYgLyogRFVNUF9QQUNLRVRTID49IDEgKi8KKyAgICAgICAgaWYgKGk9PXNrYi0+bGVuKQorICAgICAgICAgICAgICAgIHByaW50aygiJXNcbiIsYnVmKTsKKyAgICAgICAgZWxzZQorICAgICAgICAgICAgICAgIHByaW50aygiJXMuLi5cbiIsYnVmKTsKKyNlbmRpZiAvKiBEVU1QX1BBQ0tFVFMgPiAwICovCisgICAgICAgIGlmIChtZW1jbXAoc2tiLT5kYXRhLCBsZWNfY3RybF9tYWdpYywgNCkgPT0wKSB7IC8qIENvbnRyb2wgZnJhbWUsIHRvIGRhZW1vbiovCisJCXN0cnVjdCBzb2NrICpzayA9IHNrX2F0bSh2Y2MpOworCisgICAgICAgICAgICAgICAgRFBSSU5USygiJXM6IFRvIGRhZW1vblxuIixkZXYtPm5hbWUpOworICAgICAgICAgICAgICAgIHNrYl9xdWV1ZV90YWlsKCZzay0+c2tfcmVjZWl2ZV9xdWV1ZSwgc2tiKTsKKyAgICAgICAgICAgICAgICBzay0+c2tfZGF0YV9yZWFkeShzaywgc2tiLT5sZW4pOworICAgICAgICB9IGVsc2UgeyAvKiBEYXRhIGZyYW1lLCBxdWV1ZSB0byBwcm90b2NvbCBoYW5kbGVycyAqLworICAgICAgICAgICAgICAgIHVuc2lnbmVkIGNoYXIgKmRzdDsKKworICAgICAgICAgICAgICAgIGF0bV9yZXR1cm4odmNjLHNrYi0+dHJ1ZXNpemUpOworICAgICAgICAgICAgICAgIGlmICgqKHVpbnQxNl90ICopc2tiLT5kYXRhID09IGh0b25zKHByaXYtPmxlY2lkKSB8fAorICAgICAgICAgICAgICAgICAgICAhcHJpdi0+bGVjZCB8fAorICAgICAgICAgICAgICAgICAgICAhKGRldi0+ZmxhZ3MgJiBJRkZfVVApKSB7IAorICAgICAgICAgICAgICAgICAgICAgICAgLyogUHJvYmFibHkgbG9vcGluZyBiYWNrLCBvciBpZiBsZWNkIGlzIG1pc3NpbmcsCisgICAgICAgICAgICAgICAgICAgICAgICAgICBsZWNkIGhhcyBnb25lIGRvd24gKi8KKyAgICAgICAgICAgICAgICAgICAgICAgIERQUklOVEsoIklnbm9yaW5nIGZyYW1lLi4uXG4iKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGRldl9rZnJlZV9za2Ioc2tiKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKKyAgICAgICAgICAgICAgICB9CisjaWZkZWYgQ09ORklHX1RSCisgICAgICAgICAgICAgICAgaWYgKHByaXYtPmlzX3RyZGV2KSBkc3QgPSAoKHN0cnVjdCBsZWNkYXRhaGRyXzgwMjUgKilza2ItPmRhdGEpLT5oX2Rlc3Q7CisgICAgICAgICAgICAgICAgZWxzZQorI2VuZGlmCisgICAgICAgICAgICAgICAgZHN0ID0gKChzdHJ1Y3QgbGVjZGF0YWhkcl84MDIzICopc2tiLT5kYXRhKS0+aF9kZXN0OworCisgICAgICAgICAgICAgICAgaWYgKCEoZHN0WzBdJjB4MDEpICYmICAgLyogTmV2ZXIgZmlsdGVyIE11bHRpL0Jyb2FkY2FzdCAqLworICAgICAgICAgICAgICAgICAgICAhcHJpdi0+aXNfcHJveHkgJiYgIC8qIFByb3h5IHdhbnRzIGFsbCB0aGUgcGFja2V0cyAqLworCQkgICAgbWVtY21wKGRzdCwgZGV2LT5kZXZfYWRkciwgZGV2LT5hZGRyX2xlbikpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIGRldl9rZnJlZV9za2Ioc2tiKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgaWYgKHByaXYtPmxlY19hcnBfZW1wdHlfb25lcykgeworICAgICAgICAgICAgICAgICAgICAgICAgbGVjX2FycF9jaGVja19lbXB0aWVzKHByaXYsIHZjYywgc2tiKTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgc2tiLT5kZXYgPSBkZXY7CisgICAgICAgICAgICAgICAgc2tiX3B1bGwoc2tiLCAyKTsgLyogc2tpcCBsZWNfaWQgKi8KKyNpZmRlZiBDT05GSUdfVFIKKyAgICAgICAgICAgICAgICBpZiAocHJpdi0+aXNfdHJkZXYpIHNrYi0+cHJvdG9jb2wgPSB0cl90eXBlX3RyYW5zKHNrYiwgZGV2KTsKKyAgICAgICAgICAgICAgICBlbHNlCisjZW5kaWYKKyAgICAgICAgICAgICAgICBza2ItPnByb3RvY29sID0gZXRoX3R5cGVfdHJhbnMoc2tiLCBkZXYpOworICAgICAgICAgICAgICAgIHByaXYtPnN0YXRzLnJ4X3BhY2tldHMrKzsKKyAgICAgICAgICAgICAgICBwcml2LT5zdGF0cy5yeF9ieXRlcyArPSBza2ItPmxlbjsKKyAgICAgICAgICAgICAgICBtZW1zZXQoQVRNX1NLQihza2IpLCAwLCBzaXplb2Yoc3RydWN0IGF0bV9za2JfZG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bYXJnXTsKKyAgICAgICAgcmV0dXJuIChsZWNfbWNhc3RfbWFrZSgoc3RydWN0IGxlY19wcml2KilkZXZfbGVjW2FyZ10tPnByaXYsIHZjYykpOworfQorCisvKiBJbml0aWFsaXplIGRldmljZS4gKi8KK3N0YXRpYyBpbnQgCitsZWNkX2F0dGFjaChzdHJ1Y3QgYXRtX3ZjYyAqdmNjLCBpbnQgYXJnKQoreyAgCisgICAgICAgIGludCBpOworICAgICAgICBzdHJ1Y3QgbGVjX3ByaXYgKnByaXY7CisKKyAgICAgICAgaWYgKGFyZzwwKQorICAgICAgICAgICAgICAgIGkgPSAwOworICAgICAgICBlbHNlCisgICAgICAgICAgICAgICAgaSA9IGFyZzsKKyNpZmRlZiBDT05GSUdfVFIKKyAgICAgICAgaWYgKGFyZyA+PSBNQVhfTEVDX0lURikKKyAgICAgICAgICAgICAgICByZXR1cm4gLUVJTlZBTDsKKyNlbHNlIC8qIFJlc2VydmUgdGhlIHRvcCBOVU1fVFJfREVWUyBmb3IgVFIgKi8KKyAgICAgICAgaWYgKGFyZyA+PSAoTUFYX0xFQ19JVEYtTlVNX1RSX0RFVlMpKQorICAgICAgICAgICAgICAgIHJldHVybiAtRUlOVkFMOworI2VuZGlmCisgICAgICAgIGlmICghZGV2X2xlY1tpXSkgeworICAgICAgICAgICAgICAgIGludCBpc190cmRldiwgc2l6ZTsKKworICAgICAgICAgICAgICAgIGlzX3RyZGV2ID0gMDsKKyAgICAgICAgICAgICAgICBpZiAoaSA+PSAoTUFYX0xFQ19JVEYgLSBOVU1fVFJfREVWUykpCisgICAgICAgICAgICAgICAgICAgICAgICBpc190cmRldiA9IDE7CisKKyAgICAgICAgICAgICAgICBzaXplID0gc2l6ZW9mKHN0cnVjdCBsZWNfcHJpdik7CisjaWZkZWYgQ09ORklHX1RSCisgICAgICAgICAgICAgICAgaWYgKGlzX3RyZGV2KQorICAgICAgICAgICAgICAgICAgICAgICAgZGV2X2xlY1tpXSA9IGFsbG9jX3RyZGV2KHNpemUpOworICAgICAgICAgICAgICAgIGVsc2UKKyNlbmRpZgorICAgICAgICAgICAgICAgIGRldl9sZWNbaV0gPSBhbGxvY19ldGhlcmRldihzaXplKTsKKyAgICAgICAgICAgICAgICBpZiAoIWRldl9sZWNbaV0pCisgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gLUVOT01FTTsKKyAgICAgICAgICAgICAgICBzbnByaW50ZihkZXZfbGVjW2ldLT5uYW1lLCBJRk5BTVNJWiwgImxlYyVkIiwgaSk7CisgICAgICAgICAgICAgICAgaWYgKHJlZ2lzdGVyX25ldGRldihkZXZfbGVjW2ldKSkgeworICAgICAgICAgICAgICAgICAgICAgICAgZnJlZV9uZXRkZXYoZGV2X2xlY1tpXSk7CisgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gLUVJTlZBTDsKKyAgICAgICAgICAgICAgICB9CisKKyAgICAgICAgICAgICAgICBwcml2ID0gZGV2X2xlY1tpXS0+cHJpdjsKKyAgICAgICAgICAgICAgICBwcml2LT5pc190cmRldiA9IGlzX3RyZGV2OworICAgICAgICAgICAgICAgIGxlY19pbml0KGRldl9sZWNbaV0pOworICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgICAgIHByaXYgPSBkZXZfbGVjW2ldLT5wcml2OworICAgICAgICAgICAgICAgIGlmIChwcml2LT5sZWNkKQorICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIC1FQUREUklOVVNFOworICAgICAgICB9CisgICAgICAgIGxlY19hcnBfaW5pdChwcml2KTsKKwlwcml2LT5pdGZudW0gPSBpOyAgLyogTEFORTIgYWRkaXRpb24gKi8KKyAgICAgICAgcHJpdi0+bGVjZCA9IHZjYzsKKyAgICAgICAgdmNjLT5kZXYgPSAmbGVjYXRtX2RldjsKKyAgICAgICAgdmNjX2luc2VydF9zb2NrZXQoc2tfYXRtKHZjYykpOworICAgICAgICAKKyAgICAgICAgdmNjLT5wcm90b19kYXRhID0gZGV2X2xlY1tpXTsKKwlzZXRfYml0KEFUTV9WRl9NRVRBLCZ2Y2MtPmZsYWdzKTsKKwlzZXRfYml0KEFUTV9WRl9SRUFEWSwmdmNjLT5mbGFncyk7CisKKyAgICAgICAgLyogU2V0IGRlZmF1bHQgdmFsdWVzIHRvIHRoZXNlIHZhcmlhYmxlcyAqLworICAgICAgICBwcml2LT5tYXhpbXVtX3Vua25vd25fZnJhbWVfY291bnQgPSAxOworICAgICAgICBwcml2LT5tYXhfdW5rbm93bl9mcmFtZV90aW1lID0gKDEqSFopOworICAgICAgICBwcml2LT52Y2NfdGltZW91dF9wZXJpb2QgPSAoMTIwMCpIWik7CisgICAgICAgIHByaXYtPm1heF9yZXRyeV9jb3VudCA9IDE7CisgICAgICAgIHByaXYtPmFnaW5nX3RpbWUgPSAoMzAwKkhaKTsKKyAgICAgICAgcHJpdi0+Zm9yd2FyZF9kZWxheV90aW1lID0gKDE1KkhaKTsKKyAgICAgICAgcHJpdi0+dG9wb2xvZ3lfY2hhbmdlID0gMDsKKyAgICAgICAgcHJpdi0+YXJwX3Jlc3BvbnNlX3RpbWUgPSAoMSpIWik7CisgICAgICAgIHByaXYtPmZsdXNoX3RpbWVvdXQgPSAoNCpIWik7CisgICAgICAgIHByaXYtPnBhdGhfc3dpdGNoaW5nX2RlbGF5ID0gKDYqSFopOworCisgICAgICAgIGlmIChkZXZfbGVjW2ldLT5mbGFncyAmIElGRl9VUCkgeworICAgICAgICAgICAgICAgIG5ldGlmX3N0YXJ0X3F1ZXVlKGRldl9sZWNbaV0pOworICAgICAgICB9CisgICAgICAgIF9fbW9kdWxlX2dldChUSElTX01PRFVMRSk7CisgICAgICAgIHJldHVybiBpOworfQorCisjaWZkZWYgQ09ORklHX1BST0NfRlMKK3N0YXRpYyBjaGFyKiBsZWNfYXJwX2dldF9zdGF0dXNfc3RyaW5nKHVuc2lnbmVkIGNoYXIgc3RhdHVzKQoreworCXN0YXRpYyBjaGFyICpsZWNfYXJwX3N0YXR1c19zdHJpbmdbXSA9IHsKKwkJIkV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ml2ICpwcml2OworCisJcmVtb3ZlX3Byb2NfZW50cnkoImxlYyIsIGF0bV9wcm9jX3Jvb3QpOworCisJZGVyZWdpc3Rlcl9hdG1faW9jdGwoJmxhbmVfaW9jdGxfb3BzKTsKKworICAgICAgICBmb3IgKGkgPSAwOyBpIDwgTUFYX0xFQ19JVEY7IGkrKykgeworICAgICAgICAgICAgICAgIGlmIChkZXZfbGVjW2ldICE9IE5VTEwpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIHByaXYgPSAoc3RydWN0IGxlY19wcml2ICopZGV2X2xlY1tpXS0+cHJpdjsKKwkJCXVucmVnaXN0ZXJfbmV0ZGV2KGRldl9sZWNbaV0pOworICAgICAgICAgICAgICAgICAgICAgICAgZnJlZV9uZXRkZXYoZGV2X2xlY1tpXSk7CisgICAgICAgICAgICAgICAgICAgICAgICBkZXZfbGVjW2ldID0gTlVMTDsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgIH0KKworICAgICAgICByZXR1cm47ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCit9CisKK21vZHVsZV9pbml0KGxhbmVfbW9kdWxlX2luaXQpOworbW9kdWxlX2V4aXQobGFuZV9tb2R1bGVfY2xlYW51cCk7CisKKy8qCisgKiBMQU5FMjogMy4xLjMsIExFX1JFU09MVkUucmVxdWVzdAorICogTm9uIGZvcmNlIGFsbG9jYXRlcyBtZW1vcnkgYW5kIGZpbGxzIGluICp0bHZzLCBmaWxscyBpbiAqc2l6ZW9mdGx2cy4KKyAqIElmIHNpemVvZnRsdnMgPT0gTlVMTCB0aGUgZGVmYXVsdCBUTFZzIGFzc29jaWF0ZWQgd2l0aCB3aXRoIHRoaXMKKyAqIGxlYyB3aWxsIGJlIHVzZWQuCisgKiBJZiBkc3RfbWFjID09IE5VTEwsIHRhcmdldGxlc3MgTEVfQVJQIHdpbGwgYmUgc2VudAorICovCitzdGF0aWMgaW50IGxhbmUyX3Jlc29sdmUoc3RydWN0IG5ldF9kZXZpY2UgKmRldiwgdTggKmRzdF9tYWMsIGludCBmb3JjZSwKKyAgICB1OCAqKnRsdnMsIHUzMiAqc2l6ZW9mdGx2cykKK3sKKwl1bnNpZ25lZCBsb25nIGZsYWdzOworICAgICAgICBzdHJ1Y3QgbGVjX3ByaXYgKnByaXYgPSAoc3RydWN0IGxlY19wcml2ICopZGV2LT5wcml2OworICAgICAgICBzdHJ1Y3QgbGVjX2FycF90YWJsZSAqdGFibGU7CisgICAgICAgIHN0cnVjdCBza19idWZmICpza2I7CisgICAgICAgIGludCByZXR2YWw7CisKKyAgICAgICAgaWYgKGZvcmNlID09IDApIHsKKwkJc3Bpbl9sb2NrX2lycXNhdmUoJnByaXYtPmxlY19hcnBfbG9jaywgZmxhZ3MpOworICAgICAgICAgICAgICAgIHRhYmxlID0gbGVjX2FycF9maW5kKHByaXYsIGRzdF9tYWMpOworCQlzcGluX3VubG9ja19pcnFyZXN0b3JlKCZwcml2LT5sZWNfYXJwX2xvY2ssIGZsYWdzKTsKKyAgICAgICAgICAgICAgICBpZih0YWJsZSA9PSBOVUxMKQorICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIC0xOworICAgICAgICAgICAgICAgIAorICAgICAgICAgICAgICAgICp0bHZzID0ga21hbGxvYyh0YWJsZS0+c2l6ZW9mdGx2cywgR0ZQX0FUT01JQyk7CisgICAgICAgICAgICAgICAgaWYgKCp0bHZzID09IE5VTEwpCisgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gLTE7CisgICAgICAgICAgICAgICAgCisgICAgICAgICAgICAgICAgbWVtY3B5KCp0bHZzLCB0YWJsZS0+dGx2cywgdGFibGUtPnNpemVvZnRsdnMpOworICAgICAgICAgICAgICAgICpzaXplb2Z0bHZzID0gdGFibGUtPnNpemVvZnRsdnM7CisgICAgICAgICAgICAgICAgCisgICAgICAgICAgICAgICAgcmV0dXJuIDA7CisgICAgICAgIH0KKworCWlmIChzaXplb2Z0bHZzID09IE5VTEwpCisJCXJldHZhbCA9IHNl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AgICAgICAgIHJldHVybiAoMCk7ICAgICAgIC8qIG5vdCBvdXIgbWFjIGFkZHJlc3MgKi8KKworICAgICAgICBrZnJlZShwcml2LT50bHZzKTsgLyogTlVMTCBpZiB0aGVyZSB3YXMgbm8gcHJldmlvdXMgYXNzb2NpYXRpb24gKi8KKworICAgICAgICBwcml2LT50bHZzID0ga21hbGxvYyhzaXplb2Z0bHZzLCBHRlBfS0VSTkVMKTsKKyAgICAgICAgaWYgKHByaXYtPnRsdnMgPT0gTlVMTCkKKyAgICAgICAgICAgICAgICByZXR1cm4gKDApOworICAgICAgICBwcml2LT5zaXplb2Z0bHZzID0gc2l6ZW9mdGx2czsKKyAgICAgICAgbWVtY3B5KHByaXYtPnRsdnMsIHRsdnMsIHNpemVvZnRsdnMpOworCisgICAgICAgIHNrYiA9IGFsbG9jX3NrYihzaXplb2Z0bHZzLCBHRlBfQVRPTUlDKTsKKyAgICAgICAgaWYgKHNrYiA9PSBOVUxMKQorICAgICAgICAgICAgICAgIHJldHVybiAwOworICAgICAgICBza2ItPmxlbiA9IHNpemVvZnRsdnM7CisgICAgICAgIG1lbWNweShza2ItPmRhdGEsIHRsdnMsIHNpemVvZnRsdnMpOworICAgICAgICByZXR2YWwgPSBzZW5kX3RvX2xlY2QocHJpdiwgbF9hc3NvY2lhdGVfcmVxLCBOVUxMLCBOVUxMLCBza2IpOworICAgICAgICBpZiAocmV0dmFsICE9IDApCisgICAgICAgICAgICAgICAgcHJpbnRrKCJsZWMuYzogbGFuZTJfYXNzb2NpYXRlX3JlcSgpIGZhaWxlZFxuIik7CisgICAgICAgIC8qIElmIHRoZSBwcmV2aW91cyBhc3NvY2lhdGlvbiBoYXMgY2hhbmdlZCB3ZSBtdXN0CisgICAgICAgICAqIHNvbWVob3cgbm90aWZ5IG90aGVyIExBTkUgZW50aXRpZXMgYWJvdXQgdGhlIGNoYW5nZQorICAgICAgICAgKi8KKyAgICAgICAgcmV0dXJuICgxKTsKK30KKworLyoKKyAqIExBTkUyO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YXNzb2NpYXRlX2luZCgpXG4iKTsKKyAgICAgICAgcHJpbnRrKCJkdW1wIG9mIHRsdnMsIHNpemVvZnRsdnM9JWRcbiIsIHNpemVvZnRsdnMpOworICAgICAgICB3aGlsZSAoaSA8IHNpemVvZnRsdnMpCisgICAgICAgICAgICAgICAgcHJpbnRrKCIlMDJ4ICIsIHRsdnNbaSsrXSk7CisgICAgICAgIAorICAgICAgICBwcmludGsoIlxuIik7CisjZW5kaWYKKworICAgICAgICAvKiB0ZWxsIE1QT0EgYWJvdXQgdGhlIFRMVnMgd2Ugc2F3ICovCisgICAgICAgIGlmIChwcml2LT5sYW5lMl9vcHMgJiYgcHJpdi0+bGFuZTJfb3BzLT5hc3NvY2lhdGVfaW5kaWNhdG9yKSB7CisgICAgICAgICAgICAgICAgcHJpdi0+bGFuZTJfb3BzLT5hc3NvY2lhdGVfaW5kaWNhdG9yKGRldiwgbWFjX2FkZHIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRsdnMsIHNpemVvZnRsdnMpOworICAgICAgICB9CisgICAgICAgIHJldHVybjsKK30KKworLyoKKyAqIEhlcmUgc3RhcnRzIHdoYXQgdXNlZCB0byBsZWNfYXJwYy5jCisgKgorICogbGVjX2FycGMuYyB3YXMgYWRkZWQgaGVyZSB3aGVuIG1ha2luZworICogbGFuZSBjbGllbnQgbW9kdWxhci4gT2N0b2JlciAxOTk3CisgKgorICovCisKKyNpbmNsdWRlIDxsaW51eC90eXBlcy5oPgorI2luY2x1ZGUgPGxpbnV4L3NjaGVkLmg+CisjaW5jbHVkZSA8bGludXgvdGltZXIuaD4KKyNpbmNsdWRlIDxhc20vcGFyYW0uaD4KKyNpbmNsdWRlIDxhc20vYXRvbWljLmg+CisjaW5jbHVkZSA8bGludXgvaW5ldGRldmljZS5oPgorI2luY2x1ZGUgPG5ldC9yb3V0ZS5oPgorCisKKyNpZiAwCisjZGVmaW5lIERQUklOVEsoZm9ybWF0LGFyZ3MuLi4pCisvKgorI2RlZmluZSBEUFJJTlRLIHByaW50aworKi8KKyNlbmRpZgorI2RlZmluZSBERUJVR19BUlBfVEFCTEUgMAorCisjZGVmaW5lIExFQ19BUlBfUkVGUkVTSF9JTlRFUlZBTCAoMypIWikKKworc3RhdGljIHZvaWQgbGVjX2FycF9jaGVja19leHBpcmUodW5zaWduZWQgbG9uZyBkYXRhKTsKK3N0YXRpYyB2b2lkIGxlY19hcnBfZXhwaXJlX2FycCh1bnNpZ25lZCBsb25nIGRhdGEpOworCisvKiAKKyAqIEFycCB0YWJsZSBmdW5jcworICovCisKKyNkZWZpbmUgSEFTSChjaCkgKGNoICYgKExFQ19BUlBfVEFCTEVfU0laRSAtMSkpCisKKy8qCisgKiBJbml0aWFsaXphdGlvbiBvZiBhcnAtY2FjaGUKKyAqLworc3RhdGljIHZvaWQgCitsZWNfYXJwX2luaXQoc3RydWN0IGxlY19wcml2ICpwcml2KQoreworICAgICAgICB1bnNpZ25lZCBzaG9ydCBpOworCisgICAgICAgIGZvciAoaSA9IDA7IGkgPCBMRUNfQVJQX1RBQkxFX1NJWkU7IGkrKykgeworICAgICAgICAgICAgICAgIHByaXYtPmxlY19hcnBfdGFibGVzW2ldID0gTlVMTDsKKyAgICAgICAgfSAgICAgICAgCisJc3Bpbl9sb2NrX2luaXQoJnByaXYtPmxlY19hcnBfbG9jayk7CisgICAgICAgIGluaXRfdGltZXIoJnByaXYtPmxlY19hcnBfdGltZXIpOworICAgICAgICBwcml2LT5sZWNfYXJwX3RpbWVyLmV4cGlyZXMgPSBqaWZmaWVzICsgTEVDX0FSUF9SRUZSRVNIX0lOVEVSVkFMOworICAgICAgICBwcml2LT5sZWNfYXJwX3RpbWVyLmRhdGEgPSAodW5zaWduZWQgbG9uZylwcml2OworICAgICAgICBwcml2LT5sZWNfYXJwX3RpbWVyLmZ1bmN0aW9uID0gbGVjX2FycF9jaGVja19leHBpcmU7CisgICAgICAgIGFkZF90aW1lcigmcHJpdi0+bGVjX2FycF90aW1lcik7Cit9CisKK3N0YXRpYyB2b2lkCitsZWNfYXJwX2NsZWFyX3ZjY3Moc3RydWN0IGxlY19hcnBfdGFibGUgKmVudHJ5KQoreworICAgICAgICBpZiAoZW50cnktPnZjYykgeworCQlzdHJ1Y3QgYXRtX3ZjYyAqdmNjID0gZW50cnktPnZjYzsKKwkJc3RydWN0IGxlY192Y2NfcHJpdiAqdnByaXYgPSBMRUNfVkNDX1BSSVYodmNjKTsKKwkJc3RydWN0IG5ldF9kZXZpY2UgKmRldiA9IChzdHJ1Y3QgbmV0X2RldmljZSopIHZjYy0+cHJvdG9fZGF0YTsKKworICAgICAgICAgICAgICAgIHZjYy0+cG9wID0gdnByaXYtPm9sZF9wb3A7CisJCWlmICh2cHJpdi0+eG9mZikKKwkJCW5ldGlmX3dha2VfcXVldWUoZGV2KTsKKwkJa2ZyZWUodnByaXYpOworCQl2Y2MtPnVzZXJfYmFjayA9IE5VTEw7CisgICAgICAgICAgICAgICAgdmNjLT5wdXNoID0gZW50cnktPm9sZF9wdXNoOworCQl2Y2NfcmVsZWFzZV9hc3luYyh2Y2MsIC1FUElQRSk7CisgICAgICAgICAgICAgICAgdmNjID0gTlVMTDsKKyAgICAgICAgfQorICAgICAgICBpZiAoZW50cnktPnJlY3ZfdmNjKSB7CisgICAgICAgICAgICAgICAgZW50cnktPnJlY3ZfdmNjLT5wdXNoID0gZW50cnktPm9sZF9yZWN2X3B1c2g7CisJCXZjY19yZWxlYXNlX2FzeW5jKGVudHJ5LT5yZWN2X3ZjYywgLUVQSVBFKTsKKyAgICAgICAgICAgICAgICBlbnRyeS0+cmVjdl92Y2MgPSBOVUxMOworICAgICAgICB9ICAgICAgICAKK30KKworLyoKKyAqIEluc2VydCBlbnRyeSB0byBsZWNfYXJwX3RhYmxlCisgKiBMQU5FMjogQWRkIHRvIHRoZSBlbmQgb2YgdGhlIGxpc3QgdG8gc2F0aXNmeSA4LjEuMTMKKyAqLworc3RhdGljIGlubGluZSB2b2lk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fdGFibGUKKyAqLworc3RhdGljIGludCAKK2xlY19hcnBfcmVtb3ZlKHN0cnVjdCBsZWNfcHJpdiAqcHJpdiwKKyAgICAgICAgICAgICAgIHN0cnVjdCBsZWNfYXJwX3RhYmxlICp0b19yZW1vdmUpCit7CisgICAgICAgIHVuc2lnbmVkIHNob3J0IHBsYWNlOworICAgICAgICBzdHJ1Y3QgbGVjX2FycF90YWJsZSAqdG1wOworICAgICAgICBpbnQgcmVtb3ZlX3ZjYz0xOworCisgICAgICAgIGlmICghdG9fcmVtb3ZlKSB7CisgICAgICAgICAgICAgICAgcmV0dXJuIC0xOworICAgICAgICB9CisgICAgICAgIHBsYWNlID0gSEFTSCh0b19yZW1vdmUtPm1hY19hZGRyW0VUSF9BTEVOLTFdKTsKKyAgICAgICAgdG1wID0gcHJpdi0+bGVjX2FycF90YWJsZXNbcGxhY2VdOworICAgICAgICBpZiAodG1wID09IHRvX3JlbW92ZSkgeworICAgICAgICAgICAgICAgIHByaXYtPmxlY19hcnBfdGFibGVzW3BsYWNlXSA9IHRtcC0+bmV4dDsKKyAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICB3aGlsZSh0bXAgJiYgdG1wLT5uZXh0ICE9IHRvX3JlbW92ZSkgeworICAgICAgICAgICAgICAgICAgICAgICAgdG1wID0gdG1wLT5uZXh0OworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBpZiAoIXRtcCkgey8qIEVudHJ5IHdhcyBub3QgZm91bmQgKi8KKyAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAtMTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgIH0KKyAgICAgICAgdG1wLT5uZXh0ID0gdG9fcmVtb3ZlLT5uZXh0OworICAgICAgICBkZWxfdGltZXIoJnRvX3JlbW92ZS0+dGltZXIpOworICAKKyAgICAgICAgLyogSWYgdGhpcyBpcyB0aGUgb25seSBNQUMgY29ubmVjdGVkIHRvIHRoaXMgVkNDLCBhbHNvIHRlYXIgZG93bgorICAgICAgICAgICB0aGUgVkNDICovCisgICAgICAgIGlmICh0b19yZW1vdmUtPnN0YXR1cyA+PSBFU0lfRkxVU0hfUEVORElORykgeworICAgICAgICAgICAgICAgIC8qCisgICAgICAgICAgICAgICAgICogRVNJX0ZMVVNIX1BFTkRJTkcsIEVTSV9GT1JXQVJEX0RJUkVDVAorICAgICAgICAgICAgICAgICAqLworICAgICAgICAgICAgICAgIGZvcihwbGFjZSA9IDA7IHBsYWNlIDwgTEVDX0FSUF9UQUJMRV9TSVpFOyBwbGFjZSsrKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBmb3IodG1wID0gcHJpdi0+bGVjX2FycF90YWJsZXNbcGxhY2VdOyB0bXAgIT0gTlVMTDsgdG1wID0gdG1wLT5uZXh0KSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtZW1jbXAodG1wLT5hdG1fYWRkciwgdG9fcmVtb3ZlLT5hdG1fYWRkciwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBBVE1fRVNBX0xFTik9PTApIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZW1vdmVfdmNjPTA7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgaWYgKHJlbW92ZV92Y2MpCisgICAgICAgICAgICAgICAgICAgICAgICBsZWNfYXJwX2NsZWFyX3ZjY3ModG9fcmVtb3ZlKTsKKyAgICAgICAgfQorICAgICAgICBza2JfcXVldWVfcHVyZ2UoJnRvX3JlbW92ZS0+dHhfd2FpdCk7IC8qIEZJWE1FOiBnb29kIHBsYWNlIGZvciB0aGlzPyAqLworCisgICAgICAgIERQUklOVEsoIkxFQ19BUlA6IFJlbW92ZWQgZW50cnk6JTIuMnggJTIuMnggJTIuMnggJTIuMnggJTIuMnggJTIuMnhcbiIsCisgICAgICAgICAgICAgICAgMHhmZiZ0b19yZW1vdmUtPm1hY19hZGRyWzBdLCAweGZmJnRvX3JlbW92ZS0+bWFjX2FkZHJbMV0sCisgICAgICAgICAgICAgICAgMHhmZiZ0b19yZW1vdmUtPm1hY19hZGRyWzJdLCAweGZmJnRvX3JlbW92ZS0+bWFjX2FkZHJbM10sCisgICAgICAgICAgICAgICAgMHhmZiZ0b19yZW1vdmUtPm1hY19hZGRyWzRdLCAweGZmJnRvX3JlbW92ZS0+bWFjX2FkZHJbNV0pOworICAgICAgICByZXR1cm4gMDsKK30KKworI2lmIERFQlVHX0FSUF9UQUJMRQorc3RhdGljIGNoYXIqCitnZXRfc3RhdHVzX3N0cmluZyh1bnNpZ25lZCBjaGFyIHN0KQoreworICAgICAgICBzd2l0Y2goc3QpIHsKKyAgICAgICAgY2FzZSBFU0lfVU5LTk9XTjoKKyAgICAgICAgICAgICAgICByZXR1cm4gIkVTSV9VTktOT1dOIjsKKyAgICAgICAgY2FzZSBFU0lfQVJQX1BFTkRJTkc6CisgICAgICAgICAgICAgICAgcmV0dXJuICJFU0lfQVJQX1BFTkRJTkciOworICAgICAgICBjYXNlIEVTSV9WQ19QRU5ESU5HOgorICAgICAgICAgICAgICAgIHJldHVybiAiRVNJX1ZDX1BFTkRJTkciOworICAgICAgICBjYXNlIEVTSV9GTFVTSF9QRU5ESU5HOgorICAgICAgICAgICAgICAgIHJldHVybiAiRVNJX0ZMVVNIX1BFTkRJTkciOworICAgICAgICBjYXNlIEVTSV9GT1JXQVJEX0RJUkVDVDoKKyAgICAgICAgICAgICAgICByZXR1cm4gIkVTSV9GT1JXQVJEX0RJUkVDVCI7CisgICAgICAgIGRlZmF1bHQ6CisgICAgICAgICAgICAgICAgcmV0dXJuICI8VU5LTk9XTj4iOworICAgICAgICB9Cit9CisjZW5kaWYKKworc3RhdGljIHZvaWQKK2R1bXBfYXJwX3RhYmxlKHN0cnVjdCBsZWNfcHJpdiAqcHJpdikKK3sKKyNpZiBERUJVR19BUlBfVEFCTEUKKyAgICAgICAgaW50IGksaiwgb2Zmc2V0OworICAgICAgICBzdHJ1Y3QgbGVjX2FycF90YWJsZSAqcnVsbGE7CisgICAgICAgIGNoYXIgYnVmWzEwMjRdOworICAgICAgICBzdHJ1Y3QgbGVjX2FycF90YWJsZSAqKmxlY19hcnBfdGFibGVzID0KKyAgICAgICAgICAgICAgICAoc3RydWN0IGxlY19hcnBfdGFibGUgKiopcHJpdi0+bGVjX2FycF90YWJsZXM7CisgICAgICAgIHN0cnVjdCBsZWNfYXJwX3RhYmxlICpsZWNfYXJwX2VtcHR5X29uZXMgPQorICAgICAgICAgICAgICAgIChzdHJ1Y3QgbGVjX2FycF90YWJsZSAqKXByaXYtPmxlY19hcnBfZW1wdHlfb25lczsKKyAgICAgICAgc3RydWN0IGxlY19hcnBfdGFibGUgKmxlY19ub19mb3J3YXJkID0KKyAgICAgICAgICAgICAgICAoc3RydWN0IGxlY19hcnBfdGFibGUgKilwcml2LT5sZWNfbm9fZm9yd2FyZDsKKyAgICAgICAgc3RydWN0IGxlY19hcnBfdGFibGUgKm1jYXN0X2Z3ZHMgPSBwcml2LT5tY2FzdF9md2RzOworCisKKyAgICAgICAgcHJpbnRrKCJEdW1wICVwOlxuIixwcml2KTsKKyAgICAgICAgZm9yIChpPTA7aTxMRUNfQVJQX1RBQkxFX1NJWkU7aSsrKSB7CisgICAgICAgICAgICAgICAgcnVsbGEgPSBsZWNfYXJwX3RhYmxlc1tpXTsKKyAgICAgICAgICAgICAgICBvZmZzZXQgPSAwOworICAgICAgICAgICAgICAgIG9mZnNldCArPSBzcHJpbnRmKGJ1ZiwiJWQ6ICVwXG4iLGksIHJ1bGxhKTsKKyAgICAgICAgICAgICAgICB3aGlsZSAocnVsbGEpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldCArPSBzcHJpbnRmKGJ1ZitvZmZzZXQsIk1hYzoiKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGZvcihqPTA7ajxFVEhfQUxFTjtqKyspIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb2Zmc2V0Kz1zcHJpbnRmKGJ1ZitvZmZzZXQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAiJTIuMnggIiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJ1bGxhLT5tYWNfYWRkcltqXSYweGZmKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldCArPXNwcmludGYoYnVmK29mZnNldCwiQXRtOiIpOworICAgICAgICAgICAgICAgICAgICAgICAgZm9yKGo9MDtqPEFUTV9FU0FfTEVOO2orKykgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXQrPXNwcmludGYoYnVmK29mZnNldCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICIlMi4yeCAiLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcnVsbGEtPmF0bV9hZGRyW2pdJjB4ZmYpOworICAgICAgICAgICAgICAgICAgICAgICAgfSAgICAgIAorICAgICAgICAgICAgICAgICAgICAgICAgb2Zmc2V0Kz1zcHJpbnRmKGJ1ZitvZmZzZXQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIlZjYyB2cGk6JWQgdmNpOiVkLCBSZWN2X3ZjYyB2cGk6JWQgdmNpOiVkIExhc3RfdXNlZDolbHgsIFRpbWVzdGFtcDolbHgsIE5vX3RyaWVzOiVkICIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcnVsbGEtPnZjYz9ydWxsYS0+dmNjLT52cGk6MCwgCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcnVsbGEtPnZjYz9ydWxsYS0+dmNjLT52Y2k6MCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBydWxsYS0+cmVjdl92Y2M/cnVsbGEtPnJlY3ZfdmNjLT52cGk6MCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBydWxsYS0+cmVjdl92Y2M/cnVsbGEtPnJlY3ZfdmNjLT52Y2k6MCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBydWxsYS0+bGFzdF91c2VkLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJ1bGxhLT50aW1lc3RhbXAsIHJ1bGxhLT5ub190cmllcyk7CisgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXQrPXNwcmludGYoYnVmK29mZnNldCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAiRmxhZ3M6JXgsIFBhY2tldHNfZmxvb2RlZDoleCwgU3RhdHVzOiAlcyAiLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJ1bGxhLT5mbGFncywgcnVsbGEtPnBhY2tldHNfZmxvb2RlZCwgCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ2V0X3N0YXR1c19zdHJpbmcocnVsbGEtPnN0YXR1cykpOworICAgICAgICAgICAgICAgICAgICAgICAgb2Zmc2V0Kz1zcHJpbnRmKGJ1ZitvZmZzZXQsIi0+JXBcbiIscnVsbGEtPm5leHQpOworICAgICAgICAgICAgICAgICAgICAgICAgcnVsbGEgPSBydWxsYS0+bmV4dDsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgcHJpbnRrKCIlcyIsYnVmKTsKKyAgICAgICAgfQorICAgICAgICBydWxsYSA9IGxlY19ub19mb3J3YXJkOworICAgICAgICBpZiAocnVsbGEpCisgICAgICAgICAgICAgICAgcHJpbnRrKCJObyBmb3J3YXJkXG4iKTsgIAorICAgICAgICB3aGlsZShydWxsYSkgeworICAgICAgICAgICAgICAgIG9mZnNldD0wOworICAgICAgICAgICAgICAgIG9mZnNldCArPSBzcHJpbnRmKGJ1ZitvZmZzZXQsIk1hYzoiKTsKKyAgICAgICAgICAgICAgICBmb3Ioaj0wO2o8RVRIX0FMRU47aisrKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXQrPXNwcmludGYoYnVmK29mZnNldCwiJTIuMnggIiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBydWxsYS0+bWFjX2FkZHJbal0mMHhmZik7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIG9mZnNldCArPXNwcmludGYoYnVmK29mZnNldCwiQXRtOiIpOworICAgICAgICAgICAgICAgIGZvcihqPTA7ajxBVE1fRVNBX0xFTjtqKyspIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldCs9c3ByaW50ZihidWYrb2Zmc2V0LCIlMi4yeCAiLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJ1bGxhLT5hdG1fYWRkcltqXSYweGZmKTsKKyAgICAgICAgICAgICAgICB9ICAgICAgCisgICAgICAgICAgICAgICAgb2Zmc2V0Kz1zcHJpbnRmKGJ1ZitvZmZzZXQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICJWY2MgdnBpOiVkIHZjaTolZCwgUmVjdl92Y2MgdnBpOiVkIHZjaTolZCBMYXN0X3VzZWQ6JWx4LCBUaW1lc3RhbXA6JWx4LCBOb190cmllczolZCAiLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBydWxsYS0+dmNjP3J1bGxhLT52Y2MtPnZwaTowLCAKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcnVsbGEtPnZjYz9ydWxsYS0+dmNjLT52Y2k6MCwgCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJ1bGxhLT5yZWN2X3ZjYz9ydWxsYS0+cmVjdl92Y2MtPnZwaTowLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBydWxsYS0+cmVjdl92Y2M/cnVsbGEtPnJlY3ZfdmNjLT52Y2k6MCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcnVsbGEtPmxhc3RfdXNlZCwgCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJ1bGxhLT50aW1lc3RhbXAsIHJ1bGxhLT5ub190cmllcyk7CisgICAgICAgICAgICAgICAgb2Zmc2V0Kz1zcHJpbnRmKGJ1ZitvZmZzZXQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICJGbGFnczoleCwgUGFja2V0c19mbG9vZGVkOiV4LCBTdGF0dXM6ICVzICIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJ1bGxhLT5mbGFncywgcnVsbGEtPnBhY2tldHNfZmxvb2RlZCwgCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdldF9zdGF0dXNfc3RyaW5nKHJ1bGxhLT5zdGF0dXMpKTsKKyAgICAgICAgICAgICAgICBvZmZzZXQrPXNwcmludGYoYnVmK29mZnNldCwiLT4lbHhcbiIsKGxvbmcpcnVsbGEtPm5leHQpOworICAgICAgICAgICAgICAgIHJ1bGxhID0gcnVsbGEtPm5leHQ7CisgICAgICAgICAgICAgICAgcHJpbnRrKCIlcyIsYnVmKTsKKyAgICAgICAgfQorICAgICAgICBydWxsYSA9IGxlY19hcnBfZW1wdHlfb25lczsKKyAgICAgICAgaWYgKHJ1bGxhKQorICAgICAgICAgICAgICAgIHByaW50aygiRW1wdHkgb25lc1xuIik7ICAKKyAgICAgICAgd2hpbGUocnVsbGEpIHsKKyAgICAgICAgICAgICAgICBvZmZzZXQ9MDsKKyAgICAgICAgICAgICAgICBvZmZzZXQgKz0gc3ByaW50ZihidWYrb2Zmc2V0LCJNYWM6Iik7CisgICAgICAgICAgICAgICAgZm9yKGo9MDtqPEVUSF9BTEVOO2orKykgeworICAgICAgICAgICAgICAgICAgICAgICAgb2Zmc2V0Kz1zcHJpbnRmKGJ1ZitvZmZzZXQsIiUyLjJ4ICIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcnVsbGEtPm1hY19hZGRyW2pdJjB4ZmYpOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBvZmZzZXQgKz1zcHJpbnRmKGJ1ZitvZmZzZXQsIkF0bToiKTsKKyAgICAgICAgICAgICAgICBmb3Ioaj0wO2o8QVRNX0VTQV9MRU47aisrKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXQrPXNwcmludGYoYnVmK29mZnNldCwiJTIuMnggIiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBydWxsYS0+YXRtX2FkZHJbal0mMHhmZik7CisgICAgICAgICAgICAgICAgfSAgICAgIAorICAgICAgICAgICAgICAgIG9mZnNldCs9c3ByaW50ZihidWYrb2Zmc2V0LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAiVmNjIHZwaTolZCB2Y2k6JWQsIFJlY3ZfdmNjIHZwaTolZCB2Y2k6JWQgTGFzdF91c2VkOiVseCwgVGltZXN0YW1wOiVseCwgTm9fdHJpZXM6JWQgIiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcnVsbGEtPnZjYz9ydWxsYS0+dmNjLT52cGk6MCwgCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJ1bGxhLT52Y2M/cnVsbGEtPnZjYy0+dmNpOjAsIAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBydWxsYS0+cmVjdl92Y2M/cnVsbGEtPnJlY3ZfdmNjLT52cGk6MCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcnVsbGEtPnJlY3ZfdmNjP3J1bGxhLT5yZWN2X3ZjYy0+dmNpOjAsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJ1bGxhLT5sYXN0X3VzZWQsIAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBydWxsYS0+dGltZXN0YW1wLCBydWxsYS0+bm9fdHJpZXMpOworICAgICAgICAgICAgICAgIG9mZnNldCs9c3ByaW50ZihidWYrb2Zmc2V0LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAiRmxhZ3M6JXgsIFBhY2tldHNfZmxvb2RlZDoleCwgU3RhdHVzOiAlcyAiLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBydWxsYS0+ZmxhZ3MsIHJ1bGxhLT5wYWNrZXRzX2Zsb29kZWQsIAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBnZXRfc3RhdHVzX3N0cmluZyhydWxsYS0+c3RhdHVzKSk7CisgICAgICAgICAgICAgICAgb2Zmc2V0Kz1zcHJpbnRmKGJ1ZitvZmZzZXQsIi0+JWx4XG4iLChsb25nKXJ1bGxhLT5uZXh0KTsKKyAgICAgICAgICAgICAgICBydWxsYSA9IHJ1bGxhLT5uZXh0OworICAgICAgICAgICAgICAgIHByaW50aygiJXMiLGJ1Zik7CisgICAgICAgIH0KKworICAgICAgICBydWxsYSA9IG1jYXN0X2Z3ZHM7CisgICAgICAgIGlmIChydWxsYSkKKyAgICAgICAgICAgICAgICBwcmludGsoIk11bHRpY2FzdCBGb3J3YXJkIFZDQ3NcbiIpOyAgCisgICAgICAgIHdoaWxlKHJ1bGxhKSB7CisgICAgICAgICAgICAgICAgb2Zmc2V0PTA7CisgICAgICAgICAgICAgICAgb2Zmc2V0ICs9IHNwcmludGYoYnVmK29mZnNldCwiTWFjOiIpOworICAgICAgICAgICAgICAgIGZvcihqPTA7ajxFVEhfQUxFTjtqKyspIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldCs9c3ByaW50ZihidWYrb2Zmc2V0LCIlMi4yeCAiLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJ1bGxhLT5tYWNfYWRkcltqXSYweGZmKTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgb2Zmc2V0ICs9c3ByaW50ZihidWYrb2Zmc2V0LCJBdG06Iik7CisgICAgICAgICAgICAgICAgZm9yKGo9MDtqPEFUTV9FU0FfTEVOO2orKykgeworICAgICAgICAgICAgICAgICAgICAgICAgb2Zmc2V0Kz1zcHJpbnRmKGJ1ZitvZmZzZXQsIiUyLjJ4ICIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcnVsbGEtPmF0bV9hZGRyW2pdJjB4ZmYpOworICAgICAgICAgICAgICAgIH0gICAgICAKKyAgICAgICAgICAgICAgICBvZmZzZXQrPXNwcmludGYoYnVmK29mZnNldCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIlZjYyB2cGk6JWQgdmNpOiVkLCBSZWN2X3ZjYyB2cGk6JWQgdmNpOiVkIExhc3RfdXNlZDolbHgsIFRpbWVzdGFtcDolbHgsIE5vX3RyaWVzOiVkICIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJ1bGxhLT52Y2M/cnVsbGEtPnZjYy0+dnBpOjAsIAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBydWxsYS0+dmNjP3J1bGxhLT52Y2MtPnZjaTowLCAKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcnVsbGEtPnJlY3ZfdmNjP3J1bGxhLT5yZWN2X3ZjYy0+dnBpOjAsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJ1bGxhLT5yZWN2X3ZjYz9ydWxsYS0+cmVjdl92Y2MtPnZjaTowLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBydWxsYS0+bGFzdF91c2VkLCAKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcnVsbGEtPnRpbWVzdGFtcCwgcnVsbGEtPm5vX3RyaWVzKTsKKyAgICAgICAgICAgICAgICBvZmZzZXQrPXNwcmludGYoYnVmK29mZnNldCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIkZsYWdzOiV4LCBQYWNrZXRzX2Zsb29kZWQ6JXgsIFN0YXR1czogJXMgIiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcnVsbGEtPmZsYWdzLCBydWxsYS0+cGFja2V0c19mbG9vZGVkLCAKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ2V0X3N0YXR1c19zdHJpbmcocnVsbGEtPnN0YXR1cykpOworICAgICAgICAgICAgICAgIG9mZnNldCs9c3ByaW50ZihidWYrb2Zmc2V0LCItPiVseFxuIiwobG9uZylydWxsYS0+bmV4dCk7CisgICAgICAgICAgICAgICAgcnVsbGEgPSBydWxsYS0+bmV4dDsKKyAgICAgICAgICAgICAgICBwcmludGsoIiVzIixidWYpOworICAgICAgICB9CisKKyNlbmRpZgorfQorCisvKgorICogRGVzdHJ1Y3Rpb24gb2YgYXJwLWNhY2hlCisgKi8KK3N0YXRpYyB2b2lkCitsZWNfYXJwX2Rlc3Ryb3koc3RydWN0IGxlY19wcml2ICpwcml2KQoreworCXVuc2lnbmVkIGxvbmcgZmxhZ3M7CisgICAgICAgIHN0cnVjdCBsZWNfYXJwX3RhYmxlICplbnRyeSwgKm5leHQ7CisgICAgICAgIGludCBpOworCisgICAgICAgIGRlbF90aW1lcl9zeW5jKCZwcml2LT5sZWNfYXJwX3RpbWVyKTsKKyAgICAgICAgCisgICAgICAgIC8qCisgICAgICAgICAqIFJlbW92ZSBhbGwgZW50cmllcworICAgICAgICAgKi8KKworCXNwaW5fbG9ja19pcnFzYXZlKCZwcml2LT5sZWNfYXJwX2xvY2ssIGZsYWdzKTsKKyAgICAgICAgZm9yIChpID0gMDsgaSA8IExFQ19BUlBfVEFCTEVfU0laRTsgaSsrKSB7CisgICAgICAgICAgICAgICAgZm9yKGVudHJ5ID0gcHJpdi0+bGVjX2FycF90YWJsZXNbaV07IGVudHJ5ICE9IE5VTEw7IGVudHJ5PW5leHQpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIG5leHQgPSBlbnRyeS0+bmV4dDsKKyAgICAgICAgICAgICAgICAgICAgICAgIGxlY19hcnBfcmVtb3ZlKHByaXYsIGVudHJ5KTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGtmcmVlKGVudHJ5KTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgIH0KKyAgICAgICAgZW50cnkgPSBwcml2LT5sZWNfYXJwX2VtcHR5X29uZXM7CisgICAgICAgIHdoaWxlKGVudHJ5KSB7CisgICAgICAgICAgICAgICAgbmV4dCA9IGVudHJ5LT5uZXh0OworICAgICAgICAgICAgICAgIGRlbF90aW1lcl9zeW5jKCZlbnRyeS0+dGltZXIpOworICAgICAgICAgICAgICAgIGxlY19hcnBfY2xlYXJfdmNjcyhlbnRyeSk7CisgICAgICAgICAgICAgICAga2ZyZWUoZW50cnkpOworICAgICAgICAgICAgICAgIGVudHJ5ID0gbmV4dDsKKyAgICAgICAgfQorICAgICAgICBwcml2LT5sZWNfYXJwX2VtcHR5X29uZXMgPSBOVUxMOworICAgICAgICBlbnRyeSA9IHByaXYtPmxlY19ub19mb3J3YXJkOworICAgICAgICB3aGlsZShlbnRyeSkgeworICAgICAgICAgICAgICAgIG5leHQgPSBlbnRyeS0+bmV4dDsKKyAgICAgICAgICAgICAgICBkZWxfdGltZXJfc3luYygmZW50cnktPnRpbWVyKTsKKyAgICAgICAgICAgICAgICBsZWNfYXJwX2NsZWFyX3ZjY3MoZW50cnkpOworICAgICAgICAgICAgICAgIGtmcmVlKGVudHJ5KTsKKyAgICAgICAgICAgICAgICBlbnRyeSA9IG5leHQ7CisgICAgICAgIH0KKyAgICAgICAgcHJpdi0+bGVjX25vX2ZvcndhcmQgPSBOVUxMOworICAgICAgICBlbnRyeSA9IHByaXYtPm1jYXN0X2Z3ZHM7CisgICAgICAgIHdoaWxlKGVudHJ5KSB7CisgICAgICAgICAgICAgICAgbmV4dCA9IGVudHJ5LT5uZXh0OworICAgICAgICAgICAgICAgIC8qIE5vIHRpbWVyLCBMQU5FdjIgNy4xLjIwIGFuZCAyLjMuNS4zICovCisgICAgICAgICAgICAgICAgbGVjX2FycF9jbGVhcl92Y2NzKGVudHJ5KTsKKyAgICAgICAgICAgICAgICBrZnJlZShlbnRyeSk7CisgICAgICAgICAgICAgICAgZW50cnkgPSBuZXh0OworICAgICAgICB9CisgICAgICAgIHByaXYtPm1jYXN0X2Z3ZHMgPSBOVUxMOworICAgICAgICBwcml2LT5tY2FzdF92Y2MgPSBOVUxMOworICAgICAgICBtZW1zZXQocHJpdi0+bGVjX2FycF90YWJsZXMsIDAsIAorICAgICAgICAgICAgICAgc2l6ZW9mKHN0cnVjdCBsZWNfYXJwX3RhYmxlICopICogTEVDX0FSUF9UQUJMRV9TSVpFKTsKKwlzcGluX3VubG9ja19pcnFyZXN0b3JlKCZwcml2LT5sZWNfYXJwX2xvY2ssIGZsYWdzKTsKK30KKworCisvKiAKKyAqIEZpbmQgZW50cnkgYnkgbWFjX2FkZHJlc3MKKyAqLworc3RhdGljIHN0cnVjdCBsZWNfYXJwX3RhYmxlKgorbGVjX2FycF9maW5kKHN0cnVjdCBsZWNfcHJpdiAqcHJpdiwKKyAgICAgICAgICAgICB1bnNpZ25lZCBjaGFyICptYWNfYWRkcikKK3sKKyAgICAgICAgdW5zaWduZWQgc2hvcnQgcGxhY2U7CisgICAgICAgIHN0cnVjdCBsZWNfYXJwX3RhYmxlICp0b19yZXR1cm47CisKKyAgICAgICAgRFBSSU5USygiTEVDX0FSUDogbGVjX2FycF9maW5kIDolMi4yeCAlMi4yeCAlMi4yeCAlMi4yeCAlMi4yeCAlMi4yeFxuIiwKKyAgICAgICAgICAgICAgICBtYWNfYWRkclswXSYweGZmLCBtYWNfYWRkclsxXSYweGZmLCBtYWNfYWRkclsyXSYweGZmLCAKKyAgICAgICAgICAgICAgICBtYWNfYWRkclszXSYweGZmLCBtYWNfYWRkcls0XSYweGZmLCBtYWNfYWRkcls1XSYweGZmKTsKKyAgICAgICAgcGxhY2UgPSBIQVNIKG1hY19hZGRyW0VUSF9BTEVOLTFdKTsKKyAgCisgICAgICAgIHRvX3JldHVybiA9IHByaXYtPmxlY19hcnBfdGFibGVzW3BsYWNlXTsKKyAgICAgICAgd2hpbGUodG9fcmV0dXJuKSB7CisgICAgICAgICAgICAgICAgaWYgKG1lbWNtcChtYWNfYWRkciwgdG9fcmV0dXJuLT5tYWNfYWRkciwgRVRIX0FMRU4pID09IDApIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0b19yZXR1cm47CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIHRvX3JldHVybiA9IHRvX3JldHVybi0+bmV4dDsKKyAgICAgICAgfQorICAgICAgICByZXR1cm4gTlVMTDsKK30KKworc3RhdGljIHN0cnVjdCBsZWNfYXJwX3RhYmxlKgorbWFrZV9lbnRyeShzdHJ1Y3QgbGVjX3ByaXYgKnByaXYsIHVuc2lnbmVkIGNoYXIgKm1hY19hZGRyKQoreworICAgICAgICBzdHJ1Y3QgbGVjX2FycF90YWJsZSAqdG9fcmV0dXJuOworCisgICAgICAgIHRvX3JldHVybiA9IChzdHJ1Y3QgbGVjX2FycF90YWJsZSAqKSBrbWFsbG9jKHNpemVvZihzdHJ1Y3QgbGVjX2FycF90YWJsZSksCisJCQkJCQkgICAgIEdGUF9BVE9NSUMpOworICAgICAgICBpZiAoIXRvX3JldHVybikgeworICAgICAgICAgICAgICAgIHByaW50aygiTEVDOiBBcnAgZW50cnkga21hbGxvYyBmYWlsZWRcbiIpOworICAgICAgICAgICAgICAgIHJldHVybiBOVUxMOworICAgICAgICB9CisgICAgICAgIG1lbXNldCh0b19yZXR1cm4sIDAsIHNpemVvZihzdHJ1Y3QgbGVjX2FycF90YWJsZSkpOworICAgICAgICBtZW1jcHkodG9fcmV0dXJuLT5tYWNfYWRkciwgbWFjX2FkZHIsIEVUSF9BTEVOKTsKKyAgICAgICAgaW5pdF90aW1lcigmdG9fcmV0dXJuLT50aW1lcik7CisgICAgICAgIHRvX3JldHVybi0+dGltZXIuZnVuY3Rpb24gPSBsZWNfYXJwX2V4cGlyZV9hcnA7CisgICAgICAgIHRvX3JldHVybi0+dGltZXIuZGF0YSA9ICh1bnNpZ25lZCBsb25nKSB0b19yZXR1cm47CisgICAgICAgIHRvX3JldHVybi0+bGFzdF91c2VkID0gamlmZmllczsKKyAgICAgICAgdG9fcmV0dXJuLT5wcml2ID0gcHJpdjsKKyAgICAgICAgc2tiX3F1ZXVlX2hlYWRfaW5pdCgmdG9fcmV0dXJuLT50eF93YWl0KTsKKyAgICAgICAgcmV0dXJuIHRvX3JldHVybjsKK30KKworLyoKKyAqCisgKiBBcnAgc2VudCB0aW1lciBleHBpcmVkCisgKgorICovCitzdGF0aWMgdm9pZAorbGVjX2FycF9leHBpcmVfYXJwKHVuc2lnbmVkIGxvbmcgZGF0YSkKK3sKKyAgICAgICAgc3RydWN0IGxlY19hcnBfdGFibGUgKmVudHJ5OworCisgICAgICAgIGVudHJ5ID0gKHN0cnVjdCBsZWNfYXJwX3RhYmxlICopZGF0YTsKKworICAgICAgICBEUFJJTlRLKCJsZWNfYXJwX2V4cGlyZV9hcnBcbiIpOworICAgICAgICBpZiAoZW50cnktPnN0YXR1cyA9PSBFU0lfQVJQX1BFTkRJTkcpIHsKKyAgICAgICAgICAgICAgICBpZiAoZW50cnktPm5vX3RyaWVzIDw9IGVudHJ5LT5wcml2LT5tYXhfcmV0cnlfY291bnQpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlbnRyeS0+aXNfcmRlc2MpCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbmRfdG9fbGVjZChlbnRyeS0+cHJpdiwgbF9yZGVzY19hcnBfeG10LCBlbnRyeS0+bWFjX2FkZHIsIE5VTEwsIE5VTEwpOworICAgICAgICAgICAgICAgICAgICAgICAgZWxzZQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZW5kX3RvX2xlY2QoZW50cnktPnByaXYsIGxfYXJwX3htdCwgZW50cnktPm1hY19hZGRyLCBOVUxMLCBOVUxMKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGVudHJ5LT5ub190cmllcysrOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBtb2RfdGltZXIoJmVudHJ5LT50aW1lciwgamlmZmllcyArICgxKkhaKSk7CisgICAgICAgIH0KK30KKworLyoKKyAqCisgKiBVbmtub3duL3VudXNlZCB2Y2MgZXhwaXJlLCByZW1vdmUgYXNzb2NpYXRlZCBlbnRyeQorICoKKyAqLworc3RhdGljIHZvaWQKK2xlY19hcnBfZXhwaXJlX3ZjYyh1bnNpZ25lZCBsb25nIGRhdGEpCit7CisJdW5zaWduZWQgbG9uZyBmbGFnczsKKyAgICAgICAgc3RydWN0IGxlY19hcnBfdGFibGUgKnRvX3JlbW92ZSA9IChzdHJ1Y3QgbGVjX2FycF90YWJsZSopZGF0YTsKKyAgICAgICAgc3RydWN0IGxlY19wcml2ICpwcml2ID0gKHN0cnVjdCBsZWNfcHJpdiAqKXRvX3JlbW92ZS0+cHJpdjsKKyAgICAgICAgc3RydWN0IGxlY19hcnBfdGFibGUgKmVudHJ5ID0gTlVMTDsKKworICAgICAgICBkZWxfdGltZXIoJnRvX3JlbW92ZS0+dGltZXIpOworCisgICAgICAgIERQUklOVEsoIkxFQ19BUlAgJXAgJXA6IGxlY19hcnBfZXhwaXJlX3ZjYyB2cGk6JWQgdmNpOiVkXG4iLAorICAgICAgICAgICAgICAgIHRvX3JlbW92ZSwgcHJpdiwgCisgICAgICAgICAgICAgICAgdG9fcmVtb3ZlLT52Y2M/dG9fcmVtb3ZlLT5yZWN2X3ZjYy0+dnBpOjAsCisgICAgICAgICAgICAgICAgdG9fcmVtb3ZlLT52Y2M/dG9fcmVtb3ZlLT5yZWN2X3ZjYy0+dmNpOjApOworICAgICAgICBEUFJJTlRLKCJlbzolcCBuZjolcFxuIixwcml2LT5sZWNfYXJwX2VtcHR5X29uZXMscHJpdi0+bGVjX25vX2ZvcndhcmQpOworCisJc3Bpbl9sb2NrX2lycXNhdmUoJnByaXYtPmxlY19hcnBfbG9jaywgZmxhZ3MpOworICAgICAgICBpZiAodG9fcmVtb3ZlID09IHByaXYtPmxlY19hcnBfZW1wdHlfb25lcykKKyAgICAgICAgICAgICAgICBwcml2LT5sZWNfYXJwX2VtcHR5X29uZXMgPSB0b19yZW1vdmUtPm5leHQ7CisgICAgICAgIGVsc2UgeworICAgICAgICAgICAgICAgIGVudHJ5ID0gcHJpdi0+bGVjX2FycF9lbXB0eV9vbmVzOworICAgICAgICAgICAgICAgIHdoaWxlIChlbnRyeSAmJiBlbnRyeS0+bmV4dCAhPSB0b19yZW1vdmUpCisgICAgICAgICAgICAgICAgICAgICAgICBlbnRyeSA9IGVudHJ5LT5uZXh0OworICAgICAgICAgICAgICAgIGlmIChlbnRyeSkKKyAgICAgICAgICAgICAgICAgICAgICAgIGVudHJ5LT5uZXh0ID0gdG9fcmVtb3ZlLT5uZXh0OworICAgICAgICB9CisgICAgICAgIGlmICghZW50cnkpIHsKKyAgICAgICAgICAgICAgICBpZiAodG9fcmVtb3ZlID09IHByaXYtPmxlY19ub19mb3J3YXJkKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBwcml2LT5sZWNfbm9fZm9yd2FyZCA9IHRvX3JlbW92ZS0+bmV4dDsKKyAgICAgICAgICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgICAgICAgICAgICAgZW50cnkgPSBwcml2LT5sZWNfbm9fZm9yd2FyZDsKKyAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlIChlbnRyeSAmJiBlbnRyeS0+bmV4dCAhPSB0b19yZW1vdmUpCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVudHJ5ID0gZW50cnktPm5leHQ7CisgICAgICAgICAgICAgICAgICAgICAgICBpZiA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1Y3QgbGVjX3ByaXYgKnByaXYsIHVuc2lnbmVkIGNoYXIgKm1hY190b19maW5kLAorCQlpbnQgaXNfcmRlc2MsIHN0cnVjdCBsZWNfYXJwX3RhYmxlICoqcmV0X2VudHJ5KQoreworCXVuc2lnbmVkIGxvbmcgZmxhZ3M7CisgICAgICAgIHN0cnVjdCBsZWNfYXJwX3RhYmxlICplbnRyeTsKKwlzdHJ1Y3QgYXRtX3ZjYyAqZm91bmQ7CisKKyAgICAgICAgaWYgKG1hY190b19maW5kWzBdICYgMHgwMSkgeworICAgICAgICAgICAgICAgIHN3aXRjaCAocHJpdi0+bGFuZV92ZXJzaW9uKSB7CisgICAgICAgICAgICAgICAgY2FzZSAxOgorICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHByaXYtPm1jYXN0X3ZjYzsKKyAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgIGNhc2UgMjogIC8qIExBTkUyIHdhbnRzIGFycCBmb3IgbXVsdGljYXN0IGFkZHJlc3NlcyAqLworICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCBtZW1jbXAobWFjX3RvX2ZpbmQsIGJ1c19tYWMsIEVUSF9BTEVOKSA9PSAwKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcHJpdi0+bWNhc3RfdmNjOworICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgICAgZGVmYXVsdDoKKyAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgfQorCisJc3Bpbl9sb2NrX2lycXNhdmUoJnByaXYtPmxlY19hcnBfbG9jaywgZmxhZ3MpOworICAgICAgICBlbnRyeSA9IGxlY19hcnBfZmluZChwcml2LCBtYWNfdG9fZmluZCk7CisgIAorICAgICAgICBpZiAoZW50cnkpIHsKKyAgICAgICAgICAgICAgICBpZiAoZW50cnktPnN0YXR1cyA9PSBFU0lfRk9SV0FSRF9ESVJFQ1QpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIC8qIENvbm5lY3Rpb24gT2sgKi8KKyAgICAgICAgICAgICAgICAgICAgICAgIGVudHJ5LT5sYXN0X3VzZWQgPSBqaWZmaWVzOworICAgICAgICAgICAgICAgICAgICAgICAgKnJldF9lbnRyeSA9IGVudHJ5OworICAgICAgICAgICAgICAgICAgICAgICAgZm91bmQgPSBlbnRyeS0+dmNjOworCQkJZ290byBvdXQ7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIC8qIERhdGEgZGlyZWN0IFZDIG5vdCB5ZXQgc2V0IHVwLCBjaGVjayB0byBzZWUgaWYgdGhlIHVua25vd24KKyAgICAgICAgICAgICAgICAgICBmcmFtZSBjb3VudCBpcyBncmVhdGVyIHRoYW4gdGhlIGxpbWl0LiBJZiB0aGUgbGltaXQgaGFzCisgICAgICAgICAgICAgICAgICAgbm90IGJlZW4gcmVhY2hlZCwgYWxsb3cgdGhlIGNhbGxlciB0byBzZW5kIHBhY2tldCB0bworICAgICAgICAgICAgICAgICAgIEJVUy4gKi8KKyAgICAgICAgICAgICAgICBpZiAoZW50cnktPnN0YXR1cyAhPSBFU0lfRkxVU0hfUEVORElORyAmJgorICAgICAgICAgICAgICAgICAgICBlbnRyeS0+cGFja2V0c19mbG9vZGVkPHByaXYtPm1heGltdW1fdW5rbm93bl9mcmFtZV9jb3VudCkgeworICAgICAgICAgICAgICAgICAgICAgICAgZW50cnktPnBhY2tldHNfZmxvb2RlZCsrOworICAgICAgICAgICAgICAgICAgICAgICAgRFBSSU5USygiTEVDX0FSUDogRmxvb2RpbmcuLlxuIik7CisgICAgICAgICAgICAgICAgICAgICAgICBmb3VuZCA9IHByaXYtPm1jYXN0X3ZjYzsKKwkJCWdvdG8gb3V0OworICAgICAgICAgICAgICAgIH0KKwkJLyogV2UgZ290IGhlcmUgYmVjYXVzZSBlbnRyeS0+c3RhdHVzID09IEVTSV9GTFVTSF9QRU5ESU5HCisJCSAqIG9yIEJVUyBmbG9vZCBsaW1pdCB3YXMgcmVhY2hlZCBmb3IgYW4gZW50cnkgd2hpY2ggaXMKKwkJICogaW4gRVNJX0FSUF9QRU5ESU5HIG9yIEVTSV9WQ19QRU5ESU5HIHN0YXRlLgorCQkgKi8KKyAgICAgICAgICAgICAgICAqcmV0X2VudHJ5ID0gZW50cnk7CisgICAgICAgICAgICAgICAgRFBSSU5USygibGVjOiBlbnRyeS0+c3RhdHVzICVkIGVudHJ5LT52Y2MgJXBcbiIsIGVudHJ5LT5zdGF0dXMsIGVudHJ5LT52Y2MpOworICAgICAgICAgICAgICAgIGZvdW5kID0gTlVMTDsKKyAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICAvKiBObyBtYXRjaGluZyBlbnRyeSB3YXMgZm91bmQgKi8KKyAgICAgICAgICAgICAgICBlbnRyeSA9IG1ha2VfZW50cnkocHJpdiwgbWFjX3RvX2ZpbmQpOworICAgICAgICAgICAgICAgIERQUklOVEsoIkxFQ19BUlA6IE1ha2luZyBlbnRyeVxuIik7CisgICAgICAgICAgICAgICAgaWYgKCFlbnRyeSkgeworICAgICAgICAgICAgICAgICAgICAgICAgZm91bmQgPSBwcml2LT5tY2FzdF92Y2M7CisJCQlnb3RvIG91dDsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgbGVjX2FycF9hZGQocHJpdiwgZW50cnkpOworICAgICAgICAgICAgICAgIC8qIFdlIHdhbnQgYXJwLXJlcXVlc3QocykgdG8gYmUgc2VudCAqLworICAgICAgICAgICAgICAgIGVudHJ5LT5wYWNrZXRzX2Zsb29kZWQgPTE7CisgICAgICAgICAgICAgICAgZW50cnktPnN0YXR1cyA9IEVTSV9BUlBfUEVORElORzsKKyAgICAgICAgICAgICAgICBlbnRyeS0+bm9fdHJpZXMgPSAxOworICAgICAgICAgICAgICAgIGVudHJ5LT5sYXN0X3VzZWQgPSBlbnRyeS0+dGltZXN0YW1wID0gamlmZmllczsKKyAgICAgICAgICAgICAgICBlbnRyeS0+aXNfcmRlc2MgPSBpc19yZGVzYzsKKyAgICAgICAgICAgICAgICBpZiAoZW50cnktPmlzX3JkZXNjKQorICAgICAgICAgICAgICAgICAgICAgICAgc2VuZF90b19sZWNkKHByaXYsIGxfcmRlc2NfYXJwX3htdCwgbWFjX3RvX2ZpbmQsIE5VTEwsIE5VTEwpOworICAgICAgICAgICAgICAgIGVsc2UKKyAgICAgICAgICAgICAgICAgICAgICAgIHNlbmRfdG9fbGVjZChwcml2LCBsX2FycF94bXQsIG1hY190b19maW5kLCBOVUxMLCBOVUxMKTsKKyAgICAgICAgICAgICAgICBlbnRyeS0+dGltZXIuZXhwaXJlcyA9IGppZmZpZXMgKyAoMSpIWik7CisgICAgICAgICAgICAgICAgZW50cnktPnRpbWVyLmZ1bmN0aW9uID0gbGVjX2FycF9leHBpcmVfYXJwOworICAgICAgICAgICAgICAgIGFkZF90aW1lcigmZW50cnktPnRpbWVyKTsKKyAgICAgICAgICAgICAgICBmb3VuZCA9IHByaXYtPm1jYXN0X3ZjYzsKKyAgICAgICAgfQorCitvdXQ6CisJc3Bpbl91bmxvY2tfaXJxcmVzdG9yZSgmcHJpdi0+bGVjX2FycF9sb2NrLCBmbGFncyk7CisJcmV0dXJuIGZvdW5kOworfQorCitzdGF0aWMgaW50CitsZWNfYWRkcl9kZWxldGUoc3RydWN0IGxlY19wcml2ICpwcml2LCB1bnNpZ25lZCBjaGFyICphdG1fYWRkciwgCisgICAgICAgICAgICAgICAgdW5zaWduZWQgbG9uZyBwZXJtYW5lbnQpCit7CisJdW5zaWduZWQgbG9uZyBmbGFnczsKKyAgICAgICAgc3RydWN0IGxlY19hcnBfdGFibGUgKmVudHJ5LCAqbmV4dDsKKyAgICAgICAgaW50IGk7CisKKyAgICAgICAgRFBSSU5USygibGVjX2FkZHJfZGVsZXRlXG4iKTsKKwlzcGluX2xvY2tfaXJxc2F2ZSgmcHJpdi0+bGVjX2FycF9sb2NrLCBmbGFncyk7CisgICAgICAgIGZvcihpID0gMDsgaSA8IExFQ19BUlBfVEFCTEVfU0laRTsgaSsrKSB7CisgICAgICAgICAgICAgICAgZm9yKGVudHJ5ID0gcHJpdi0+bGVjX2FycF90YWJsZXNbaV07IGVudHJ5ICE9IE5VTEw7IGVudHJ5ID0gbmV4dCkgeworICAgICAgICAgICAgICAgICAgICAgICAgbmV4dCA9IGVudHJ5LT5uZXh0OworICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFtZW1jbXAoYXRtX2FkZHIsIGVudHJ5LT5hdG1fYWRkciwgQVRNX0VTQV9MRU4pCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgJiYgKHBlcm1hbmVudCB8fCAKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIShlbnRyeS0+ZmxhZ3MgJiBMRUNfUEVSTUFORU5UX0ZMQUcpKSkgeworCQkJCWxlY19hcnBfcmVtb3ZlKHByaXYsIGVudHJ5KTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAga2ZyZWUoZW50cnkpOworICAgICAgICAgICAgICAgICAgICAgICAgfQorCQkJc3Bpbl91bmxvY2tfaXJxcmVzdG9yZSgmcHJpdi0+bGVjX2FycF9sb2NrLCBmbGFncyk7CisgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gMDsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgIH0KKwlzcGluX3VubG9ja19pcnFyZXN0b3JlKCZwcml2LT5sZWNfYXJwX2xvY2ssIGZsYWdzKTsKKyAgICAgICAgcmV0dXJuIC0xOworfQorCisvKgorICogTm90aWZpZXM6ICBSZXNwb25zZSB0byBhcnBfcmVxdWVzdCAoYXRtX2FkZHIgIT0gTlVMTCkgCisgKi8KK3N0YXRpYyB2b2lkCitsZWNfYXJwX3VwZGF0ZShzdHJ1Y3QgbGVjX3ByaXYgKnByaXYsIHVuc2lnbmVkIGNoYXIgKm1hY19hZGRyLAorICAgICAgICAgICAgICAgdW5zaWduZWQgY2hhciAqYXRtX2FkZHIsIHVuc2lnbmVkIGxvbmcgcmVtb3RlZmxhZywKKyAgICAgICAgICAgICAgIHVuc2lnbmVkIGludCB0YXJnZXRsZXNzX2xlX2FycCkKK3sKKwl1bnNpZ25lZCBsb25nIGZsYWdzOworICAgICAgICBzdHJ1Y3QgbGVjX2FycF90YWJsZSAqZW50cnksICp0bXA7CisgICAgICAgIGludCBpOworCisgICAgICAgIERQUklOVEsoImxlYzolcyIsICh0YXJnZXRsZXNzX2xlX2FycCkgPyAidGFyZ2V0bGVzcyAiOiAiICIpOworICAgICAgICBEUFJJTlRLKCJsZWNfYXJwX3VwZGF0ZSBtYWM6JTIuMnglMi4yeCUyLjJ4JTIuMnglMi4yeCUyLjJ4XG4iLAorICAgICAgICAgICAgICAgIG1hY19hZGRyWzBdLG1hY19hZGRyWzFdLG1hY19hZGRyWzJdLG1hY19hZGRyWzNdLAorICAgICAgICAgICAgICAgIG1hY19hZGRyWzRdLG1hY19hZGRyWzVdKTsKKworCXNwaW5fbG9ja19pcnFzYXZlKCZwcml2LT5sZWNfYXJwX2xvY2ssIGZsYWdzKTsKKyAgICAgICAgZW50cnkgPSBsZWNfYXJwX2ZpbmQocHJpdiwgbWFjX2FkZHIpOworICAgICAgICBpZiAoZW50cnkgPT0gTlVMTCAmJiB0YXJnZXRsZXNzX2xlX2FycCkKKyAgICAgICAgICAgICAgICBnb3RvIG91dDsgICAvKiBMQU5FMjogaWdub3JlIHRhcmdldGxlc3MgTEVfQVJQcyBmb3Igd2hpY2gKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKiB3ZSBoYXZlIG5vIGVudHJ5IGluIHRoZSBjYWNoZS4gNy4xLjMwCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICovCisgICAgICAgIGlmIChwcml2LT5sZWNfYXJwX2VtcHR5X29uZXMpIHsKKyAgICAgICAgICAgICAgICBlbnRyeSA9IHByaXYtPmxlY19hcnBfZW1wdHlfb25lczsKKyAgICAgICAgICAgICAgICBpZiAoIW1lbWNtcChlbnRyeS0+YXRtX2FkZHIsIGF0bV9hZGRyLCBBVE1fRVNBX0xFTikpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIHByaXYtPmxlY19hcnBfZW1wdHlfb25lcyA9IGVudHJ5LT5uZXh0OworICAgICAgICAgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAgICAgICAgICAgICB3aGlsZShlbnRyeS0+bmV4dCAmJiBtZW1jbXAoZW50cnktPm5leHQtPmF0bV9hZGRyLCAKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdG1fYWRkciwgQVRNX0VTQV9MRU4pKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbnRyeSA9IGVudHJ5LT5uZXh0OworICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVudHJ5LT5uZXh0KSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRtcCA9IGVudHJ5OworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbnRyeSA9IGVudHJ5LT5uZXh0OworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0bXAtPm5leHQgPSBlbnRyeS0+bmV4dDsKKyAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbnRyeSA9IE5VTEw7CisgICAgICAgICAgICAgICAgICAgICAgICAKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgaWYgKGVudHJ5KSB7CisgICAgICAgICAgICAgICAgICAgICAgICBkZWxfdGltZXIoJmVudHJ5LT50aW1lcik7CisgICAgICAgICAgICAgICAgICAgICAgICB0bXAgPSBsZWNfYXJwX2ZpbmQocHJpdiwgbWFjX2FkZHIpOworICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRtcCkgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWxfdGltZXIoJnRtcC0+dGltZXIpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0bXAtPnN0YXR1cyA9IEVTSV9GT1JXQVJEX0RJUkVDVDsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWVtY3B5KHRtcC0+YXRtX2FkZHIsIGF0bV9hZGRyLCBBVE1fRVNBX0xFTik7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRtcC0+dmNjID0gZW50cnktPnZjYzsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdG1wLT5vbGRfcHVzaCA9IGVudHJ5LT5vbGRfcHVzaDsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdG1wLT5sYXN0X3VzZWQgPSBqaWZmaWVzOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWxfdGltZXIoJmVudHJ5LT50aW1lcik7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGtmcmVlKGVudHJ5KTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZW50cnk9dG1wOworICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZW50cnktPnN0YXR1cyA9IEVTSV9GT1JXQVJEX0RJUkVDVDsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWVtY3B5KGVudHJ5LT5tYWNfYWRkciwgbWFjX2FkZHIsIEVUSF9BTEVOKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZW50cnktPmxhc3RfdXNlZCA9IGppZmZpZXM7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxlY19hcnBfYWRkKHByaXYsIGVudHJ5KTsKKyAgICAgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgICAgIGlmIChyZW1vdGVmbGFnKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbnRyeS0+ZmxhZ3N8PUxFQ19SRU1PVEVfRkxBRzsKKyAgICAgICAgICAgICAgICAgICAgICAgIGVsc2UKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZW50cnktPmZsYWdzJj1+TEVDX1JFTU9URV9GTEFHOworICAgICAgICAgICAgICAgICAgICAgICAgRFBSSU5USygiQWZ0ZXIgdXBkYXRlXG4iKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGR1bXBfYXJwX3RhYmxlKHByaXYpOworICAgICAgICAgICAgICAgICAgICAgICAgZ290byBvdXQ7CisgICAgICAgICAgICAgICAgfQorICAgICAgICB9CisgICAgICAgIGVudHJ5ID0gbGVjX2FycF9maW5kKHByaXYsIG1hY19hZGRyKTsKKyAgICAgICAgaWYgKCFlbnRyeSkgeworICAgICAgICAgICAgICAgIGVudHJ5ID0gbWFrZV9lbnRyeShwcml2LCBtYWNfYWRkcik7CisgICAgICAgICAgICAgICAgaWYgKCFlbnRyeSkKKwkJCWdvdG8gb3V0OworICAgICAgICAgICAgICAgIGVudHJ5LT5zdGF0dXMgPSBFU0lfVU5LTk9XTjsKKyAgICAgICAgICAgICAgICBsZWNfYXJwX2FkZChwcml2LCBlbnRyeSk7CisgICAgICAgICAgICAgICAgLyogVGVtcG9yYXJ5LCBjaGFuZ2VzIGJlZm9yZSBlbmQgb2YgZnVuY3Rpb24gKi8KKyAgICAgICAgfQorICAgICAgICBtZW1jcHkoZW50cnktPmF0bV9hZGRyLCBhdG1fYWRkciwgQVRNX0VTQV9MRU4pOworICAgICAgICBkZWxfdGltZXIoJmVudHJ5LT50aW1lcik7CisgICAgICAgIGZvcihpID0gMDsgaSA8IExFQ19BUlBfVEFCTEVfU0laRTsgaSsrKSB7CisgICAgICAgICAgICAgICAgZm9yKHRtcCA9IHByaXYtPmxlY19hcnBfdGFibGVzW2ldOyB0bXA7IHRtcD10bXAtPm5leHQpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlbnRyeSAhPSB0bXAgJiYKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAhbWVtY21wKHRtcC0+YXRtX2FkZHIsIGF0bV9hZGRyLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQVRNX0VTQV9MRU4pKSB7IAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvKiBWY2MgdG8gdGhpcyBob3N0IGV4aXN0cyAqLworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodG1wLT5zdGF0dXMgPiBFU0lfVkNfUEVORElORykgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8qCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICogRVNJX0ZMVVNIX1BFTkRJTkcsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICogRVNJX0ZPUldBUkRfRElSRUNUCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICovCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZW50cnktPnZjYyA9IHRtcC0+dmNjOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVudHJ5LT5vbGRfcHVzaD10bXAtPm9sZF9wdXNoOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVudHJ5LT5zdGF0dXM9dG1wLT5zdGF0dXM7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIH0KKyAgICAgICAgfQorICAgICAgICBpZiAocmVtb3RlZmxhZykKKyAgICAgICAgICAgICAgICBlbnRyeS0+ZmxhZ3N8PUxFQ19SRU1PVEVfRkxBRzsKKyAgICAgICAgZWxzZQorICAgICAgICAgICAgICAgIGVudHJ5LT5mbGFncyY9fkxFQ19SRU1PVEVfRkxBRzsKKyAgICAgICAgaWYgKGVudHJ5LT5zdGF0dXMgPT0gRVNJX0FSUF9QRU5ESU5HIHx8CisgICAgICAgICAgICBlbnRyeS0+c3RhdHVzID09IEVTSV9VTktOT1dOKSB7CisgICAgICAgICAgICAgICAgZW50cnktPnN0YXR1cyA9IEVTSV9WQ19QRU5ESU5HOworICAgICAgICAgICAgICAgIHNlbmRfdG9fbGVjZChwcml2LCBsX3N2Y19zZXR1cCwgZW50cnktPm1hY19hZGRyLCBhdG1fYWRkciwgTlVMTCk7CisgICAgICAgIH0KKyAgICAgICAgRFBSSU5USygiQWZ0ZXIgdXBkYXRlMlxuIik7CisgICAgICAgIGR1bXBfYXJwX3RhYmxlKHByaXYpOworb3V0OgorCXNwaW5fdW5sb2NrX2lycXJlc3RvcmUoJnByaXYtPmxlY19hcnBfbG9jaywgZmxhZ3MpOworfQorCisvKgorICogTm90aWZpZXM6IFZjYyBzZXR1cCByZWFkeSAKKyAqLworc3RhdGljIHZvaWQKK2xlY192Y2NfYWRkZWQoc3RydWN0IGxlY19wcml2ICpwcml2LCBzdHJ1Y3QgYXRtbGVjX2lvYyAqaW9jX2RhdGEsCisgICAgICAgICAgICAgIHN0cnVjdCBhdG1fdmNjICp2Y2MsCisgICAgICAgICAgICAgIHZvaWQgKCpvbGRfcHVzaCkoc3RydWN0IGF0bV92Y2MgKnZjYywgc3RydWN0IHNrX2J1ZmYgKnNrYikpCit7CisJdW5zaWduZWQgbG9uZyBmbGFnczsKKyAgICAgICAgc3RydWN0IGxlY19hcnBfdGFibGUgKmVudHJ5OworICAgICAgICBpbnQgaSwgZm91bmRfZW50cnk9MDsKKworCXNwaW5fbG9ja19pcnFzYXZlKCZwcml2LT5sZWNfYXJwX2xvY2ssIGZsYWdzKTsKKyAgICAgICAgaWYgKGlvY19kYXRhLT5yZWNlaXZlID09IDIpIHsKKyAgICAgICAgICAgICAgICAvKiBWY2MgZm9yIE11bHRpY2FzdCBGb3J3YXJkLiBObyB0aW1lciwgTEFORXYyIDcuMS4yMCBhbmQgMi4zLjUuMyAqLworCisgICAgICAgICAgICAgICAgRFBSSU5USygiTEVDX0FSUDogQXR0YWNoaW5nIG1jYXN0IGZvcndhcmRcbiIpOworI2lmIDAKKyAgICAgICAgICAgICAgICBlbnRyeSA9IGxlY19hcnBfZmluZChwcml2LCBidXNfbWFjKTsKKyAgICAgICAgICAgICAgICBpZiAoIWVudHJ5KSB7CisgICAgICAgICAgICAgICAgICAgICAgICBwcmludGsoIkxFQ19BUlA6IE11bHRpY2FzdCBlbnRyeSBub3QgZm91bmQhXG4iKTsKKwkJCWdvdG8gb3V0OworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBtZW1jcHkoZW50cnktPmF0bV9hZGRyLCBpb2NfZGF0YS0+YXRtX2FkZHIsIEFUTV9FU0FfTEVOKTsKKyAgICAgICAgICAgICAgICBlbnRyeS0+cmVjdl92Y2MgPSB2Y2M7CisgICAgICAgICAgICAgICAgZW50cnktPm9sZF9yZWN2X3B1c2ggPSBvbGRfcHVzaDsKKyNlbmRpZgorICAgICAgICAgICAgICAgIGVudHJ5ID0gbWFrZV9lbnRyeShwcml2LCBidXNfbWFjKTsKKyAgICAgICAgICAgICAgICBpZiAoZW50cnkgPT0gTlVMTCkKKwkJCWdvdG8gb3V0OworICAgICAgICAgICAgICAgIGRlbF90aW1lcigmZW50cnktPnRpbWVyKTsKKyAgICAgICAgICAgICAgICBtZW1jcHkoZW50cnktPmF0bV9hZGRyLCBpb2NfZGF0YS0+YXRtX2FkZHIsIEFUTV9FU0FfTEVOKTsKKyAgICAgICAgICAgICAgICBlbnRyeS0+cmVjdl92Y2MgPSB2Y2M7CisgICAgICAgICAgICAgICAgZW50cnktPm9sZF9yZWN2X3B1c2ggPSBvbGRfcHVzaDsKKyAgICAgICAgICAgICAgICBlbnRyeS0+bmV4dCA9IHByaXYtPm1jYXN0X2Z3ZHM7CisgICAgICAgICAgICAgICAgcHJpdi0+bWNhc3RfZndkcyA9IGVudHJ5OworICAgICAgICAgICAgICAgIGdvdG8gb3V0OworICAgICAgICB9IGVsc2UgaWYgKGlvY19kYXRhLT5yZWNlaXZlID09IDEpIHsKKyAgICAgICAgICAgICAgICAvKiBWY2Mgd2hpY2ggd2UgZG9uJ3Qgd2FudCB0byBtYWtlIGRlZmF1bHQgdmNjLCBhdHRhY2ggaXQKKyAgICAgICAgICAgICAgICAgICBhbnl3YXkuICovCisgICAgICAgICAgICAgICAgRFBSSU5USygiTEVDX0FSUDpBdHRhY2hpbmcgZGF0YSBkaXJlY3QsIG5vdCBkZWZhdWx0IDolMi4yeCUyLjJ4JTIuMnglMi4yeCUyLjJ4JTIuMnglMi4yeCUyLjJ4JTIuMnglMi4yeCUyLjJ4JTIuMnglMi4yeCUyLjJ4JTIuMnglMi4yeCUyLjJ4JTIuMnglMi4yeCUyLjJ4XG4iLAorICAgICAgICAgICAgICAgICAgICAgICAgaW9jX2RhdGEtPmF0bV9hZGRyWzBdLGlvY19kYXRhLT5hdG1fYWRkclsxXSwKKyAgICAgICAgICAgICAgICAgICAgICAgIGlvY19kYXRhLT5hdG1fYWRkclsyXSxpb2NfZGF0YS0+YXRtX2FkZHJbM10sCisgICAgICAgICAgICAgICAgICAgICAgICBpb2NfZGF0YS0+YXRtX2FkZHJbNF0saW9jX2RhdGEtPmF0bV9hZGRyWzVdLAorICAgICAgICAgICAgICAgICAgICAgICAgaW9jX2RhdGEtPmF0bV9hZGRyWzZdLGlvY19kYXRhLT5hdG1fYWRkcls3XSwKKyAgICAgICAgICAgICAgICAgICAgICAgIGlvY19kYXRhLT5hdG1fYWRkcls4XSxpb2NfZGF0YS0+YXRtX2FkZHJbOV0sCisgICAgICAgICAgICAgICAgICAgICAgICBpb2NfZGF0YS0+YXRtX2FkZHJbMTBdLGlvY19kYXRhLT5hdG1fYWRkclsxMV0sCisgICAgICAgICAgICAgICAgICAgICAgICBpb2NfZGF0YS0+YXRtX2FkZHJbMTJdLGlvY19kYXRhLT5hdG1fYWRkclsxM10sCisgICAgICAgICAgICAgICAgICAgICAgICBpb2NfZGF0YS0+YXRtX2FkZHJbMTRdLGlvY19kYXRhLT5hdG1fYWRkclsxNV0sCisgICAgICAgICAgICAgICAgICAgICAgICBpb2NfZGF0YS0+YXRtX2FkZHJbMTZdLGlvY19kYXRhLT5hdG1fYWRkclsxN10sCisgICAgICAgICAgICAgICAgICAgICAgICBpb2NfZGF0YS0+YXRtX2FkZHJbMThdLGlvY19kYXRhLT5hdG1fYWRkclsxOV0pOworICAgICAgICAgICAgICAgIGVudHJ5ID0gbWFrZV9lbnRyeShwcml2LCBidXNfbWFjKTsKKyAgICAgICAgICAgICAgICBpZiAoZW50cnkgPT0gTlVMTCkKKwkJCWdvdG8gb3V0OworICAgICAgICAgICAgICAgIG1lbWNweShlbnRyeS0+YXRtX2FkZHIsIGlvY19kYXRhLT5hdG1fYWRkciwgQVRNX0VTQV9MRU4pOworICAgICAgICAgICAgICAgIG1lbXNldChlbnRyeS0+bWFjX2FkZHIsIDAsIEVUSF9BTEVOKTsKKyAgICAgICAgICAgICAgICBlbnRyeS0+cmVjdl92Y2MgPSB2Y2M7CisgICAgICAgICAgICAgICAgZW50cnktPm9sZF9yZWN2X3B1c2ggPSBvbGRfcHVzaDsKKyAgICAgICAgICAgICAgICBlbnRyeS0+c3RhdHVzID0gRVNJX1VOS05PV047CisgICAgICAgICAgICAgICAgZW50cnktPnRpbWVyLmV4cGlyZXMgPSBqaWZmaWVzICsgcHJpdi0+dmNjX3RpbWVvdXRfcGVyaW9kOworICAgICAgICAgICAgICAgIGVudHJ5LT50aW1lci5mdW5jdGlvbiA9IGxlY19hcnBfZXhwaXJlX3ZjYzsKKyAgICAgICAgICAgICAgICBhZGRfdGltZXIoJmVudHJ5LT50aW1lcik7CisgICAgICAgICAgICAgICAgZW50cnktPm5leHQgPSBwcml2LT5sZWNfbm9fZm9yd2FyZDsKKyAgICAgICAgICAgICAgICBwcml2LT5sZWNfbm9fZm9yd2FyZCA9IGVudHJ5OworCQlkdW1wX2FycF90YWJsZShwcml2KTsKKwkJZ290by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PCBMRUNfQVJQX1RBQkxFX1NJWkU7IGkrKykgeworICAgICAgICAgICAgICAgIGZvciAoZW50cnkgPSBwcml2LT5sZWNfYXJwX3RhYmxlc1tpXTsgZW50cnk7IGVudHJ5PWVudHJ5LT5uZXh0KSB7CisgICAgICAgICAgICAgICAgICAgICAgICBpZiAobWVtY21wKGlvY19kYXRhLT5hdG1fYWRkciwgZW50cnktPmF0bV9hZGRyLCAKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQVRNX0VTQV9MRU4pPT0wKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIERQUklOVEsoIkxFQ19BUlA6IEF0dGFjaGluZyBkYXRhIGRpcmVjdFxuIik7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIERQUklOVEsoIkN1cnJlbnRseSAtPiBWY2M6ICVkLCBSdmNjOiVkXG4iLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVudHJ5LT52Y2M/ZW50cnktPnZjYy0+dmNpOjAsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZW50cnktPnJlY3ZfdmNjP2VudHJ5LT5yZWN2X3ZjYy0+dmNpOjApOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3VuZF9lbnRyeT0xOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWxfdGltZXIoJmVudHJ5LT50aW1lcik7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVudHJ5LT52Y2MgPSB2Y2M7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVudHJ5LT5vbGRfcHVzaCA9IG9sZF9wdXNoOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZW50cnktPnN0YXR1cyA9PSBFU0lfVkNfUEVORElORykgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmKHByaXYtPm1heGltdW1fdW5rbm93bl9mcmFtZV9jb3VudAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgID09MCkKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVudHJ5LT5zdGF0dXMgPSAKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgRVNJX0ZPUldBUkRfRElSRUNUOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsc2UgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZW50cnktPnRpbWVzdGFtcCA9IGppZmZpZXM7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbnRyeS0+c3RhdHVzID0gCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEVTSV9GTFVTSF9QRU5ESU5HOworI2lmIDAKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbmRfdG9fbGVjZChwcml2LGxfZmx1c2hfeG10LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIE5VTEwsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZW50cnktPmF0bV9hZGRyLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIE5VTEwpOworI2VuZGlmCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8qIFRoZXkgd2VyZSBmb3JtaW5nIGEgY29ubmVjdGlvbgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRvIHVzLCBhbmQgd2UgdG8gdGhlbS4gT3VyCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQVRNIGFkZHJlc3MgaXMgbnVtZXJpY2FsbHkgbG93ZXIKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGFuIHRoZWlycywgc28gd2UgbWFrZSBjb25uZWN0aW9uCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2UgZm9ybWVkIGludG8gZGVmYXVsdCBWQ0MgKDguMS4xMSkuCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29ubmVjdGlvbiB0aGV5IG1hZGUgZ2V0cyB0b3JuCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZG93bi4gVGhpcyBtaWdodCBjb25mdXNlIHNvbWUKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGllbnRzLiBDYW4gYmUgY2hhbmdlZCBpZgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvbWVvbmUgcmVwb3J0cyB0cm91YmxlLi4uICovCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgfQorICAgICAgICB9CisgICAgICAgIGlmIChmb3VuZF9lbnRyeSkgeworICAgICAgICAgICAgICAgIERQUklOVEsoIkFmdGVyIHZjYyB3YXMgYWRkZWRcbiIpOworICAgICAgICAgICAgICAgIGR1bXBfYXJwX3RhYmxlKHByaXYpOworCQlnb3RvIG91dDsKKyAgICAgICAgfQorICAgICAgICAvKiBOb3QgZm91bmQsIHNuYXRjaCBhZGRyZXNzIGZyb20gZmlyc3QgZGF0YSBwYWNrZXQgdGh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FycF90YWJsZSAqZW50cnk7CisgICAgICAgIGludCBpOworICAKKyAgICAgICAgRFBSSU5USygiTEVDOmxlY19mbHVzaF9jb21wbGV0ZSAlbHhcbiIsdHJhbl9pZCk7CisJc3Bpbl9sb2NrX2lycXNhdmUoJnByaXYtPmxlY19hcnBfbG9jaywgZmxhZ3MpOworICAgICAgICBmb3IgKGkgPSAwOyBpIDwgTEVDX0FSUF9UQUJMRV9TSVpFOyBpKyspIHsKKyAgICAgICAgICAgICAgICBmb3IgKGVudHJ5ID0gcHJpdi0+bGVjX2FycF90YWJsZXNbaV07IGVudHJ5OyBlbnRyeT1lbnRyeS0+bmV4dCkgeworICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVudHJ5LT5mbHVzaF90cmFuX2lkID09IHRyYW5faWQgJiYKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbnRyeS0+c3RhdHVzID09IEVTSV9GTFVTSF9QRU5ESU5HKSB7CisJCQkgICAgICAgIHN0cnVjdCBza19idWZmICpza2I7CisKKyAJCQkJd2hpbGUgKChza2IgPSBza2JfZGVxdWV1ZSgmZW50cnktPnR4X3dhaXQpKSAhPSBOVUxMKQorCQkJCQlsZWNfc2VuZChlbnRyeS0+dmNjLCBza2IsIGVudHJ5LT5wcml2KTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZW50cnktPnN0YXR1cyA9IEVTSV9GT1JXQVJEX0RJUkVDVDsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgRFBSSU5USygiTEVDX0FSUDogRmx1c2hlZFxuIik7CisgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgfQorICAgICAgICB9CisJc3Bpbl91bmxvY2tfaXJxcmVzdG9yZSgmcHJpdi0+bGVjX2FycF9sb2NrLCBmbGFncyk7CisgICAgICAgIGR1bXBfYXJwX3RhYmxlKHByaXYpOworfQorCitzdGF0aWMgdm9pZAorbGVjX3NldF9mbHVzaF90cmFuX2lkKHN0cnVjdCBsZWNfcHJpdiAqcHJpdiwKKyAgICAgICAgICAgICAgICAgICAgICB1bnNpZ25lZCBjaGFyICphdG1fYWRkciwgdW5zaWduZWQgbG9uZyB0cmFuX2lkKQoreworCXVuc2lnbmVkIGxvbmcgZmxhZ3M7CisgICAgICAgIHN0cnVjdCBsZWNfYXJwX3RhYmxlICplbnRyeTsKKyAgICAgICAgaW50IGk7CisKKwlzcGluX2xvY2tfaXJxc2F2ZSgmcHJpdi0+bGVjX2FycF9sb2NrLCBmbGFncyk7CisgICAgICAgIGZvciAoaSA9IDA7IGkgPCBMRUNfQVJQX1RBQkxFX1NJWkU7IGkrKykKKyAgICAgICAgICAgICAgICBmb3IoZW50cnkgPSBwcml2LT5sZWNfYXJwX3RhYmxlc1tpXTsgZW50cnk7IGVudHJ5PWVudHJ5LT5uZXh0KQorICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFtZW1jbXAoYXRtX2FkZHIsIGVudHJ5LT5hdG1fYWRkciwgQVRNX0VTQV9MRU4pKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVudHJ5LT5mbHVzaF90cmFuX2lkID0gdHJhbl9pZDsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgRFBSSU5USygiU2V0IGZsdXNoIHRyYW5zYWN0aW9uIGlkIHRvICVseCBmb3IgJXBcbiIsdHJhbl9pZCxlbnRyeSk7CisgICAgICAgICAgICAgICAgICAgICAgICB9CisJc3Bpbl91bmxvY2tfaXJxcmVzdG9yZSgmcHJpdi0+bGVjX2FycF9sb2NrLCBmbGFncyk7Cit9CisKK3N0YXRpYyBpbnQgCitsZWNfbWNhc3RfbWFrZShzdHJ1Y3QgbGVjX3ByaXYgKnByaXYsIHN0cnVjdCBhdG1fdmNjICp2Y2MpCit7CisJdW5zaWduZWQgbG9uZyBmbGFnczsKKyAgICAgICAgdW5zaWduZWQgY2hhciBtYWNfYWRkcltdID0geworICAgICAgICAgICAgICAgIDB4ZmYsIDB4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jYyA9IHZjYzsKKyAgICAgICAgbGVjX2FycF9hZGQocHJpdiwgdG9fYWRkKTsKK291dDoKKwlzcGluX3VubG9ja19pcnFyZXN0b3JlKCZwcml2LT5sZWNfYXJwX2xvY2ssIGZsYWdzKTsKKyAgICAgICAgcmV0dXJuIGVycjsKK30KKworc3RhdGljIHZvaWQKK2xlY192Y2NfY2xvc2Uoc3RydWN0IGxlY19wcml2ICpwcml2LCBzdHJ1Y3QgYXRtX3ZjYyAqdmNjKQoreworCXVuc2lnbmVkIGxvbmcgZmxhZ3M7CisgICAgICAgIHN0cnVjdCBsZWNfYXJwX3RhYmxlICplbnRyeSwgKm5leHQ7CisgICAgICAgIGludCBpOworCisgICAgICAgIERQUklOVEsoIkxFQ19BUlA6IGxlY192Y2NfY2xvc2UgdnBpOiVkIHZjaTolZFxuIix2Y2MtPnZwaSx2Y2MtPnZjaSk7CisgICAgICAgIGR1bXBfYXJwX3RhYmxlKHByaXYpOworCXNwaW5fbG9ja19pcnFzYXZlKCZwcml2LT5sZWNfYXJwX2xvY2ssIGZsYWdzKTsKKyAgICAgICAgZm9yKGk9MDtpPExFQ19BUlBfVEFCTEVfU0laRTtpKyspIHsKKyAgICAgICAgICAgICAgICBmb3IoZW50cnkgPSBwcml2LT5sZWNfYXJwX3RhYmxlc1tpXTtlbnRyeTsgZW50cnk9bmV4dCkgeworICAgICAgICAgICAgICAgICAgICAgICAgbmV4dCA9IGVudHJ5LT5uZXh0OworICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZjYyA9PSBlbnRyeS0+dmNjKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxlY19hcnBfcmVtb3ZlKHByaXYsIGVudHJ5KTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAga2ZyZWUoZW50cnkpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocHJpdi0+bWNhc3RfdmNjID09IHZjYykgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByaXYtPm1jYXN0X3ZjYyA9IE5VTEw7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICB9CisgICAgICAgIH0KKworICAgICAgICBlbnRyeSA9IHByaXYtPmxlY19hcnBfZW1wdHlfb25lczsKKyAgICAgICAgcHJpdi0+bGVjX2FycF9lbXB0eV9vbmVzID0gTlVMTDsKKyAgICAgICAgd2hpbGUgKGVudHJ5ICE9IE5VTEwpIHsKKyAgICAgICAgICAgICAgICBuZXh0ID0gZW50cnktPm5leHQ7CisgICAgICAgICAgICAgICAgaWYgKGVudHJ5LT52Y2MgPT0gdmNjKSB7IC8qIGxlYXZlIGl0IG91dCBmcm9tIHRoZSBsaXN0ICovCisgICAgICAgICAgICAgICAgICAgICAgICBsZWNfYXJwX2NsZWFyX3ZjY3MoZW50cnkpOworICAgICAgICAgICAgICAgICAgICAgICAgZGVsX3RpbWVyKCZlbnRyeS0+dGltZXIpOworICAgICAgICAgICAgICAgICAgICAgICAga2ZyZWUoZW50cnkpOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBlbHNlIHsgICAgICAgICAgICAgIC8qIHB1dCBpdCBiYWNrIHRvIHRoZSBsaXN0ICovCisgICAgICAgICAgICAgICAgICAgICAgICBlbnRyeS0+bmV4dCA9IHByaXYtPmxlY19hcnBfZW1wdHlfb25lczsKKyAgICAgICAgICAgICAgICAgICAgICAgIHByaXYtPmxlY19hcnBfZW1wdHlfb25lcyA9IGVudHJ5OworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBlbnRyeSA9IG5leHQ7CisgICAgICAgIH0KKyAgICAgICAgCisgICAgICAgIGVudHJ5ID0gcHJpdi0+bGVjX25vX2ZvcndhcmQ7CisgICAgICAgIHByaXYtPmxlY19ub19mb3J3YXJkID0gTlVMTDsKKyAgICAgICAgd2hpbGUgKGVudHJ5ICE9IE5VTEwpIHsKKyAgICAgICAgICAgICAgICBuZXh0ID0gZW50cnktPm5leHQ7CisgICAgICAgICAgICAgICAgaWYgKGVudHJ5LT5yZWN2X3ZjYyA9PSB2Y2MpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIGxlY19hcnBfY2xlYXJfdmNjcyhlbnRyeSk7CisgICAgICAgICAgICAgICAgICAgICAgICBkZWxfdGltZXIoJmVudHJ5LT50aW1lcik7CisgICAgICAgICAgICAgICAgICAgICAgICBrZnJlZShlbnRyeSk7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIGVsc2UgeworICAgICAgICAgICAgICAgICAgICAgICAgZW50cnktPm5leHQgPSBwcml2LT5sZWNfbm9fZm9yd2FyZDsKKyAgICAgICAgICAgICAgICAgICAgICAgIHByaXYtPmxlY19ub19mb3J3YXJkID0gZW50cnk7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIGVudHJ5ID0gbmV4dDsKKyAgICAgICAgfQorCisgICAgICAgIGVudHJ5ID0gcHJpdi0+bWNhc3RfZndkczsKKyAgICAgICAgcHJpdi0+bWNhc3RfZndkcyA9IE5VTEw7CisgICAgICAgIHdoaWxlIChlbnRyeSAhPSBOVUxMKSB7CisgICAgICAgICAgICAgICAgbmV4dCA9IGVudHJ5LT5uZXh0OworICAgICAgICAgICAgICAgIGlmIChlbnRyeS0+cmVjdl92Y2MgPT0gdmNjKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBsZWNfYXJwX2NsZWFyX3ZjY3MoZW50cnkpOworICAgICAgICAgICAgICAgICAgICAgICAgLyogTm8gdGltZXIsIExBTkV2MiA3LjEuMjAgYW5kIDIuMy41LjMgKi8KKyAgICAgICAgICAgICAgICAgICAgICAgIGtmcmVlKGVudHJ5KTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgZWxzZSB7CisgICAgICAgICAgICAgICAgICAgICAgICBlbnRyeS0+bmV4dCA9IHByaXYtPm1jYXN0X2Z3ZHM7CisgICAgICAgICAgICAgICAgICAgICAgICBwcml2LT5tY2FzdF9md2RzID0gZW50cnk7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIGVudHJ5ID0gbmV4dDsKKyAgICAgICAgfQorCisJc3Bpbl91bmxvY2tfaXJxcmVzdG9yZSgmcHJpdi0+bGVjX2FycF9sb2NrLCBmbGFncyk7CisJZHVtcF9hcnBfdGFibGUocHJpdik7Cit9CisKK3N0YXRpYyB2b2lkCitsZWNfYXJwX2NoZWNrX2VtcHRpZXMoc3RydWN0IGxlY19wcml2ICpwcml2LAorICAgICAgICAgICAgICAgICAgICAgIHN0cnVjdCBhdG1fdmNjICp2Y2MsIHN0cnVjdCBza19idWZmICpza2IpCit7CisgICAgICAgIHVuc2lnbmVkIGxvbmcgZmxhZ3M7CisgICAgICAgIHN0cnVjdCBsZWNfYXJwX3RhYmxlICplbnRyeSwgKnByZXY7CisgICAgICAgIHN0cnVjdCBsZWNkYXRhaGRyXzgwMjMgKmhkciA9IChzdHJ1Y3QgbGVjZGF0YWhkcl84MDIzICopc2tiLT5kYXRhOworICAgICAgICB1bnNpZ25lZCBjaGFyICpzcmM7CisjaWZkZWYgQ09ORklHX1RSCisgICAgICAgIHN0cnVjdCBsZWNkYXRhaGRyXzgwMjUgKnRyX2hkciA9IChzdHJ1Y3QgbGVjZGF0YWhkcl84MDI1ICopc2tiLT5kYXRhOworCisgICAgICAgIGlmIChwcml2LT5pc190cmRldikgc3JjID0gdHJfaGRyLT5oX3NvdXJjZTsKKyAgICAgICAgZWxzZQorI2VuZGlmCisgICAgICAgIHNyYyA9IGhkci0+aF9zb3VyY2U7CisKKwlzcGluX2xvY2tfaXJxc2F2ZSgmcHJpdi0+bGVjX2FycF9sb2NrLCBmbGFncyk7CisgICAgICAgIGVudHJ5ID0gcHJpdi0+bGVjX2FycF9lbXB0eV9vbmVzOworICAgICAgICBpZiAodmNjID09IGVudHJ5LT52Y2MpIHsKKyAgICAgICAgICAgICAgICBkZWxfdGltZXIoJmVudHJ5LT50aW1lcik7CisgICAgICAgICAgICAgICAgbWVtY3B5KGVudHJ5LT5tYWNfYWRkciwgc3JjLCBFVEhfQUxFTik7CisgICAgICAgICAgICAgICAgZW50cnktPnN0YXR1cyA9IEVTSV9GT1JXQVJEX0RJUkVDVDsKKyAgICAgICAgICAgICAgICBlbnRyeS0+bGFzdF91c2VkID0gamlmZmllczsKKyAgICAgICAgICAgICAgICBwcml2LT5sZWNfYXJwX2VtcHR5X29uZXMgPSBlbnRyeS0+bmV4dDsKKyAgICAgICAgICAgICAgICAvKiBXZSBtaWdodCBoYXZlIGdvdCBhbiBlbnRyeSAqLworICAgICAgICAgICAgICAgIGlmICgocHJldiA9IGxlY19hcnBfZmluZChwcml2LHNyYykpKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBsZWNfYXJwX3JlbW92ZShwcml2LCBwcmV2KTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGtmcmVlKHByZXYpOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBsZWNfYXJwX2FkZChwcml2LCBlbnRyeSk7CisJCWdvdG8gb3V0OworICAgICAgICB9CisgICAgICAgIHByZXYgPSBlbnRyeTsKKyAgICAgICAgZW50cnkgPSBlbnRyeS0+bmV4dDsKKyAgICAgICAgd2hpbGUgKGVudHJ5ICYmIGVudHJ5LT52Y2MgIT0gdmNjKSB7CisgICAgICAgICAgICAgICAgcHJldj0gZW50cnk7CisgICAgICAgICAgICAgICAgZW50cnkgPSBlbnRyeS0+bmV4dDsKKyAgICAgICAgfQorICAgICAgICBpZiAoIWVudHJ5KSB7CisgICAgICAgICAgICAgICAgRFBSSU5USygiTEVDX0FSUDogQXJwX2NoZWNrX2VtcHRpZXM6IGVudHJ5IG5vdCBmb3VuZCFcbiIpOworCQlnb3RvIG91dDsKKyAgICAgICAgfQorICAgICAgICBkZWxfdGltZXIoJmVudHJ5LT50aW1lcik7CisgICAgICAgIG1lbWNweShlbnRyeS0+bWFjX2F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TsgLyogQXRtIGFkZHJlc3MgKi8KKyAgICAgICAgdW5zaWduZWQgY2hhciBtYWNfYWRkcltFVEhfQUxFTl07ICAgIC8qIE1hYyBhZGRyZXNzICovCisgICAgICAgIGludCBpc19yZGVzYzsgICAgICAgICAgICAgICAgICAgICAgICAvKiBNYWMgYWRkcmVzcyBpcyBhIHJvdXRlIGRlc2NyaXB0b3IgKi8KKyAgICAgICAgc3RydWN0IGF0bV92Y2MgKnZjYzsgICAgICAgICAgICAgICAgIC8qIFZjYyB0aGlzIGVudHJ5IGlzIGF0dGFjaGVkICovCisgICAgICAgIHN0cnVjdCBhdG1fdmNjICpyZWN2X3ZjYzsgICAgICAgICAgICAvKiBWY2Mgd2UgcmVjZWl2ZSBkYXRhIGZyb20gKi8KKyAgICAgICAgdm9pZCAoKm9sZF9wdXNoKShzdHJ1Y3QgYXRtX3ZjYyAqdmNjLHN0cnVjdCBza19idWZmICpza2IpOyAKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8qIFB1c2ggdGhhdCBsZWFkcyB0byBkYWVtb24gKi8KKyAgICAgICAgdm9pZCAoKm9sZF9yZWN2X3B1c2gpKHN0cnVjdCBhdG1fdmNjICp2Y2MsIHN0cnVjdCBza19idWZmICpza2IpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLyogUHVzaCB0aGF0IGxlYWRzIHRvIGRhZW1vbiAqLworICAgICAgICB2b2lkICgqb2xkX2Nsb3NlKShzdHJ1Y3QgYXRtX3ZjYyAqdmNjKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8qIFdlIHdhbnQgdG8gc2VlIHdoZW4gdGhpcworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICogdmNjIGdldHMgY2xvc2VkICovCisgICAgICAgIHVuc2lnbmVkIGxvbmcgbGFzdF91c2VkOyAgICAgICAgICAgICAvKiBGb3IgZXhwaXJ5ICovCisgICAgICAgIHVuc2lnbmVkIGxvbmcgdGltZXN0YW1wOyAgICAgICAgICAgICAvKiBVc2VkIGZvciB2YXJpb3VzIHRpbWVzdGFtcGluZworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICogdGhpbmdzOgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICogMS4gRkxVU0ggc3RhcnRlZCAKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqICAgIChzdGF0dXM9RVNJX0ZMVVNIX1BFTkRJTkcpCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKiAyLiBDb3VudGluZyB0byAKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqICAgIG1heF91bmtub3duX2ZyYW1lX3RpbWUKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqICAgIChzdGF0dXM9RVNJX0FSUF9QRU5ESU5HfHwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqICAgICBzdGF0dXM9RVNJX1ZDX1BFTkRJTkcpCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKi8KKyAgICAgICAgdW5zaWduZWQgY2hhciBub190cmllczsgICAgICAgICAgICAgIC8qIE5vIG9mIHRpbWVzIGFycCByZXRyeSBoYXMgYmVlbiAKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyaWVkICovCisgICAgICAgIHVuc2lnbmVkIGNoYXIgc3RhdHVzOyAgICAgICAgICAgICAgICAvKiBTdGF0dXMgb2YgdGhpcyBlbnRyeSAqLworICAgICAgICB1bnNpZ25lZCBzaG9ydCBmbGFnczsgICAgICAgICAgICAgICAgLyogRmxhZ3MgZm9yIHRoaXMgZW50cnkgKi8KKyAgICAgICAgdW5zaWduZWQgc2hvcnQgcGFja2V0c19mbG9vZGVkOyAgICAgIC8qIERhdGEgcGFja2V0cyBmbG9vZGVkICovCisgICAgICAgIHVuc2lnbmVkIGxvbmcgZmx1c2hfdHJhbl9pZDsgICAgICAgICAvKiBUcmFuc2FjdGlvbiBpZCBpbiBmbHVzaCBwcm90b2NvbCAqLworICAgICAgICBzdHJ1Y3QgdGltZXJfbGlzdCB0aW1lcjsgICAgICAgICAgICAgLyogQXJwaW5nIHRpbWVyICovCisgICAgICAgIHN0cnVjdCBsZWNfcHJpdiAqcHJpdjsgICAgICAgICAgICAgICAvKiBQb2ludGVyIGJhY2sgKi8KKworICAgICAgICB1OCAgKnRsdnM7ICAgICAgICAgICAgIC8qIExBTkUyOiBFYWNoIE1BQyBhZGRyZXNzIGNhbiBoYXZlIFRMVnMgICAgKi8KKyAgICAgICAgdTMyIHNpemVvZnRsdnM7ICAgICAgICAvKiBhc3NvY2lhdGVkIHdpdGggaXQuIHNpemVvZnRsdnMgdGVsbHMgdGhlICovCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLyogdGhlIGxlbmd0aCBvZiB0aGUgdGx2cyBhcnJheSAgICAgICAgICAgICAqLworICAgICAgICBzdHJ1Y3Qgc2tfYnVmZl9oZWFkIHR4X3dhaXQ7IC8qIHdhaXQgcXVldWUgZm9yIG91dGdvaW5nIHBhY2tldHMgICAgKi8KK307CisKK3N0cnVjdCB0bHYgeyAgICAgICAgICAgICAgICAgICAvKiBMQU5FMjogVGVtcGxhdGUgdGx2IHN0cnVjdCBmb3IgYWNjZXNzaW5nICovCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLyogdGhlIHRsdnMgaW4gdGhlIGxlY19hcnBfdGFibGUtPnRsdnMgYXJyYXkqLworICAgICAgICB1MzIgdHlwZTsKKyAgICAgICAgdTggIGxlbmd0aDsKKyAgICAgICAgdTggIHZhbHVlWzI1NV07Cit9OworCisvKiBTdGF0dXMgZmllbGRzICovCisjZGVmaW5lIEVTSV9VTktOT1dOIDAgICAgICAgLyoKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKiBOZXh0IHBhY2tldCBzZW50IHRvIHRoaXMgbWFjIGFkZHJlc3MKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKiBjYXVzZXMgQVJQLXJlcXVlc3QgdG8gYmUgc2VudCAKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKi8KKyNkZWZpbmUgRVNJX0FSUF9QRU5ESU5HIDEgICAvKgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqIFRoZXJlIGlzIG5vIEFUTSBhZGRyZXNzIGFzc29jaWF0ZWQgd2l0aCB0aGlzCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICogNDgtYml0IGFkZHJlc3MuICBUaGUgTEUtQVJQIHByb3RvY29sIGlzIGluCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICogcHJvZ3Jlc3MuCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICovCisjZGVmaW5lIEVTSV9WQ19QRU5ESU5HIDIgICAgLyoKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKiBUaGVyZSBpcyBhIHZhbGlkIEFUTSBhZGRyZXNzIGFzc29jaWF0ZWQgd2l0aCAKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKiB0aGlzIDQ4LWJpdCBhZGRyZXNzIGJ1dCB0aGVyZSBpcyBubyBWQyBzZXQgCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICogdXAgdG8gdGhhdCBBVE0gYWRkcmVzcy4gIFRoZSBzaWduYWxpbmcgCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICogcHJvdG9jb2wgaXMgaW4gcHJvY2Vzcy4KKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKi8KKyNkZWZpbmUgRVNJX0ZMVVNIX1BFTkRJTkcgNCAvKgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqIFRoZSBMRUMgaGFzIGJlZW4gbm90aWZpZWQgb2YgdGhlIEZMVVNIX1NUQVJUCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICogc3RhdHVzIGFuZCBpdCBpcyBhc3N1bWVkIHRoYXQgdGhlIGZsdXNoIAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqIHByb3RvY29sIGlzIGluIHByb2Nlc3MuCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICovCisjZGVmaW5lIEVTSV9GT1JXQVJEX0RJUkVDVCA1IC8qCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqIEVpdGhlciB0aGUgUGF0aCBTd2l0Y2hpbmcgRGVsYXkgKEMyMikgaGFzIAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKiBlbGFwc2VkIG9yIHRoZSBMRUMgaGFzIG5vdGlmaWVkIHRoZSBNYXBwaW5nIAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKiB0aGF0IHRoZSBmbHVzaCBwcm90b2NvbCBoYXMgY29tcGxldGVkLiAgSW4gCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqIGVpdGhlciBjYXNlLCBpdCBpcyBzYWZlIHRvIGZvcndhcmQgcGFja2V0cyAKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICogdG8gdGhpcyBhZGRyZXNzIHZpYSB0aGUgZGF0YSBkaXJlY3QgVkMuCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqLworCisvKiBGbGFnIHZhbHVlcyAqLworI2RlZmluZSBMRUNfUkVNT1RFX0ZMQUcgICAgICAweDAwMDEKKyNkZWZpbmUgTEVDX1BFUk1BTkVOVF9GTEFHICAgMHgwMDAyCisKKyNlbmRpZgpkaWZmIC0tZ2l0IGEvbmV0L2F0bS9tcGMuYyBiL25ldC9hdG0vbXBjLmMKbmV3IGZpbGUgbW9kZSAxMDA2NDQKaW5kZXggMDAwMDAwMC4uMTdhODFlYgotLS0gL2Rldi9udWxsCisrKyBiL25ld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JpbnRrKCJcbm1wb2E6ICglcykgbGFuZTJfYXNzb2NfaW5kOiBzaG9ydCBNUE9BIERldmljZSBUeXBlIFRMVlxuIiwKKwkJCSAgICAgICBkZXYtPm5hbWUpOworCQkJY29udGludWU7CisJCX0KKwkJaWYgKChtcG9hX2RldmljZV90eXBlID09IE1QUyB8fCBtcG9hX2RldmljZV90eXBlID09IE1QQykKKwkJICAgICYmIGxlbmd0aCA8IDIyICsgbnVtYmVyX29mX21wc19tYWNzKkVUSF9BTEVOKSB7CisJCQlwcmludGsoIlxubXBvYTogKCVzKSBsYW5lMl9hc3NvY19pbmQ6IHNob3J0IE1QT0EgRGV2aWNlIFR5cGUgVExWXG4iLAorCQkJCWRldi0+bmFtZSk7CisJCQljb250aW51ZTsKKwkJfQorCQlpZiAobXBvYV9kZXZpY2VfdHlwZSAhPSBNUFMgJiYgbXBvYV9kZXZpY2VfdHlwZSAhPSBNUFNfQU5EX01QQykgeworCQkJZHByaW50aygiaWdub3Jpbmcgbm9uLU1QUyBkZXZpY2VcbiIpOworCQkJaWYgKG1wb2FfZGV2aWNlX3R5cGUgPT0gTVBDKSB0bHZzICs9IDIwOworCQkJY29udGludWU7ICAvKiB3ZSBhcmUgb25seSBpbnRlcmVzdGVkIGluIE1QU3MgKi8KKwkJfQorCQlpZiAobnVtYmVyX29mX21wc19tYWNzID09IDAgJiYgbXBvYV9kZXZpY2VfdHlwZSA9PSBNUFNfQU5EX01QQykgeworCQkJcHJpbnRrKCJcbm1wb2E6ICglcykgbGFuZTJfYXNzb2NfaW5kOiBNUFNfQU5EX01QQyBoYXMgemVybyBNQUNzXG4iLCBkZXYtPm5hbWUpOworCQkJY29udGludWU7ICAvKiBzb21lb25lIHNob3VsZCByZWFkIHRoZSBzcGVjICovCisJCX0KKwkJZHByaW50aygidGhpcyBNUFMgaGFzICVkIE1BQyBhZGRyZXNzZXNcbiIsIG51bWJlcl9vZl9tcHNfbWFjcyk7CisJCQorCQkvKiBvaywgbm93IHdlIGNhbi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GluIHF1ZXN0aW9uICAgICAgICAgICAgICAgICAgICAgKi8KKyAgICAgICAgaW50IGRldl9udW07ICAgICAgICAgICAgICAgICAvKiBlLmcuIDIgZm9yIGxlYzIgICAgICAgICAgICAgICAgICAgICAqLworICAgICAgICBpbnQgKCpvbGRfaGFyZF9zdGFydF94bWl0KShzdHJ1Y3Qgc2tfYnVmZiAqc2tiLCBzdHJ1Y3QgbmV0X2RldmljZSAqZGV2KTsKKyAgICAgICAgc3RydWN0IGF0bV92Y2MgKm1wb2FkX3ZjYzsgICAvKiBjb250cm9sIGNoYW5uZWwgdG8gbXBvYWQgICAgICAgICAgICAqLworICAgICAgICB1aW50OF90IG1wc19jdHJsX2FkZHJbQVRNX0VTQV9MRU5dOyAgLyogTVBTIGNvbnRyb2wgQVRNIGFkZHJlc3MgICAgICovCisgICAgICAgIHVpbnQ4X3Qgb3VyX2N0cmxfYWRkcltBVE1fRVNBX0xFTl07ICAvKiBNUEMncyBjb250cm9sIEFUTSBhZGRyZXNzICAgKi8KKworICAgICAgICByd2xvY2tfdCBpbmdyZXNzX2xvY2s7CisgICAgICAgIHN0cnVjdCBpbl9jYWNoZV9vcHMgKmluX29wczsgLyogaW5ncmVzcyBjYWNoZSBvcGVyYXRpb25zICAgICAgICAgICAgKi8KKyAgICAgICAgaW5fY2FjaGVfZW50cnkgKmluX2NhY2hlOyAgICAvKiB0aGUgaW5ncmVzcyBjYWNoZSBvZiB0aGlzIE1QQyAgICAgICAqLworCisgICAgICAgIHJ3bG9ja190IGVncmVzc19sb2NrOworICAgICAgICBzdHJ1Y3QgZWdfY2FjaGVfb3BzICplZ19vcHM7IC8qIGVncmVzcyBjYWNoZSBvcGVyYXRpb25zICAgICAgICAgICAgICovCisgICAgICAgIGVnX2NhY2hlX2VudHJ5ICplZ19jYWNoZTsgICAgLyogdGhlIGVncmVzcyAgY2FjaGUgb2YgdGhpcyBNUEMgICAgICAgKi8KKworICAgICAgICB1aW50OF90ICptcHNfbWFjczsgICAgICAgIC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ICAgICAgICAgLyogZ2V0ICAgICAgICAgICAgICovCisJaW5fY2FjaGVfZ2V0X3dpdGhfbWFzaywgICAgICAgICAgIC8qIGdldF93aXRoX21hc2sgICAqLworCWluX2NhY2hlX2dldF9ieV92Y2MsICAgICAgICAgICAgICAvKiBnZXRfYnlfdmNjICAgICAgKi8KKwlpbl9jYWNoZV9wdXQsICAgICAgICAgICAgICAgICAgICAgLyogcHV0ICAgICAgICAgICAgICovCisJaW5fY2FjaGVfcmVtb3ZlX2VudHJ5LCAgICAgICAgICAgIC8qIHJlbW92ZV9lbnRyeSAgICAqLworCWNhY2hlX2hpdCwgICAgICAgICAgICAgICAgICAgICAgICAvKiBjYWNoZV9oaXQgICAgICAgKi8KKwljbGVhcl9jb3VudF9hbmRfZXhwaXJlZCwgICAgICAgICAgLyogY2xlYXJfY291bnQgICAgICovCisJY2hlY2tfcmVzb2x2aW5nX2VudHJpZXMsICAgICAgICAgIC8qIGNoZWNrX3Jlc29sdmluZyAqLworCXJlZnJlc2hfZW50cmllcywgICAgICAgICAgICAgICAgICAvKiByZWZyZXNoICAgICAgICAgKi8KKwlpbl9kZXN0cm95X2NhY2hlICAgICAgICAgICAgICAgICAgLyogZGVzdHJveV9jYWNoZSAgICovCit9OworCitzdGF0aWMgc3RydWN0IGVnX2NhY2hlX29wcyBlZ3Jlc3Nfb3BzID0geworCWVnX2NhY2hlX2FkZF9lbnRyeSwgICAgICAgICAgICAgICAvKiBhZGRfZW50cnkgICAgICAgICovCisJZWdfY2FjaGVfZ2V0X2J5X2NhY2hlX2lkLCAgICAgICAgIC8qIGdldF9ieV9jYWNoZV9pZCAgKi8KKwllZ19jYWNoZV9nZXRfYnlfdGFnLCAgICAgICAgICAgICAgLyogZ2V0X2J5X3RhZyAgICAgICAqLworCWVnX2NhY2hlX2dldF9ieV92Y2MsICAgICAgICAgICAgICAvKiBnZXRfYnlfdmNjICAgICAgICovCisJZWdfY2FjaGVfZ2V0X2J5X3NyY19pcCwgICAgICAgICAgIC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BvYV9pbml0X2NhY2hlKHN0cnVjdCBtcG9hX2NsaWVudCAqbXBjKTsKKwordHlwZWRlZiBzdHJ1Y3QgaW5fY2FjaGVfZW50cnkgeworICAgICAgICBzdHJ1Y3QgaW5fY2FjaGVfZW50cnkgKm5leHQ7CisgICAgICAgIHN0cnVjdCBpbl9jYWNoZV9lbnRyeSAqcHJldjsKKyAgICAgICAgc3RydWN0IHRpbWV2YWwgIHR2OworICAgICAgICBzdHJ1Y3QgdGltZXZhbCAgcmVwbHlfd2FpdDsKKyAgICAgICAgc3RydWN0IHRpbWV2YWwgIGhvbGRfZG93bjsKKyAgICAgICAgdWludDMyX3QgIHBhY2tldHNfZndkZWQ7CisgICAgICAgIHVpbnQxNl90ICBlbnRyeV9zdGF0ZTsgCisgICAgICAgIHVpbnQzMl90IHJldHJ5X3RpbWU7CisgICAgICAgIHVpbnQzMl90IHJlZnJlc2hfdGltZTsKKyAgICAgICAgdWludDMyX3QgY291bnQ7CisgICAgICAgIHN0cnVjdCAgIGF0bV92Y2MgKnNob3J0Y3V0OworICAgICAgICB1aW50OF90ICBNUFNfY3RybF9BVE1fYWRkcltBVE1fRVNBX0xFTl07CisgICAgICAgIHN0cnVjdCAgIGluX2N0cmxfaW5mbyBjdHJsX2luZm87CisgICAgICAgIGF0b21pY190IHVzZTsKK30gaW5fY2FjaGVfZW50cnk7CisKK3N0cnVjdCBpbl9jYWNoZV9vcHN7CisgICAgICAgIGluX2NhY2hlX2VudHJ5ICooKmFkZF9lbnRyeSkodWludDMyX3QgZHN0X2lwLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJ1Y3QgbXBvYV9jbGllbnQgKmNsaWVudCk7CisgICAgICAgIGluX2NhY2hlX2VudHJ5ICooKmdldCkodWludDMyX3QgZHN0X2lwLCBzdHJ1Y3QgbXBvYV9jbGllbnQgKmNsaWVudCk7CisgICAgICAgIGluX2NhY2hlX2VudHJ5ICooKmdldF93aXRoX21hc2spKHVpbnQzMl90IGRzdF9pcCwgCisJCQkJCSBzdHJ1Y3QgbXBvYV9jbGllbnQgKmNsaWVudCwKKwkJCQkJIHVpbnQzMl90IG1hc2spOworICAgICAgICBpbl9jYWNoZV9lbnRyeSAqKCpnZXRfYnlfdmNjKShzdHJ1Y3QgYXRtX3ZjYyAqdmNjLCAKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RydWN0IG1wb2FfY2xpZW50ICpjbGllbnQpOworICAgICAgICB2b2lkICAgICAgICAgICAgKCpwdXQpKGluX2NhY2hlX2VudHJ5ICplbnRyeSk7CisgICAgICAgIHZvaWQgICAgICAgICAgICAoKnJlbW92ZV9lbnRyeSkoaW5fY2FjaGVfZW50cnkgKmRlbEVudHJ5LAorCQkJCQlzdHJ1Y3QgbXBvYV9jbGllbnQgKmNsaWVudCApOworICAgICAgICBpbnQgICAgICAgICAgICAgKCpjYWNoZV9oaXQpKGluX2NhY2hlX2VudHJ5ICplbnRyeSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJ1Y3QgbXBvYV9jbGllbnQgKmNsaWVudCk7CisgICAgICAgIHZvaWQgICAgICAgICAgICAoKmNsZWFyX2NvdW50KShzdHJ1Y3QgbXBvYV9jbGllbnQgKmNsaWVudCk7CisgICAgICAgIHZvaWQgICAgICAgICAgICAoKmNoZWNrX3Jlc29sdmluZykoc3RydWN0IG1wb2FfY2xpZW50ICpjbGllbnQpOworICAgICAgICB2b2lkICAgICAgICAgICAgKCpyZWZyZXNoKShzdHJ1Y3QgbXBvYV9jbGllbnQgKmNsaWVudCk7CisgICAgICAgIHZvaWQgICAgICAgICAgICAoKmRlc3Ryb3lfY2FjaGUpKHN0cnVjdCBtcG9hX2NsaWVudCAqbXBjKTsKK307CisKK3R5cGVkZWYgc3RydWN0IGVnX2NhY2hlX2VudHJ5eworICAgICAgICBzdHJ1Y3QgICAgICAgICAgICAgICBlZ19jYWNoZV9lbnRyeSAqbmV4dDsKKyAgICAgICAgc3RydWN0ICAgICAgICAgICAgICAgZWdfY2FjaGVfZW50cnkgKnByZXY7CisgICAgICAgIHN0cnVjdCAgICAgICAgICAgICAgIHRpbWV2YWwgIHR2OworICAgICAgICB1aW50OF90ICAgICAgICAgICAgICBNUFNfY3RybF9BVE1fYWRkcltBVE1fRVNBX0xFTl07CisgICAgICAgIHN0cnVjdCBhdG1fdmNjICAgICAgICpzaG9ydGN1dDsKKyAgICAgICAgdWludDMyX3QgICAgICAgICAgICAgcGFja2V0c19yY3ZkOworICAgICAgICB1aW50MTZfdCAgICAgICAgICAgICBlbnRyeV9zdGF0ZTsKKyAgICAgICAgdWludDMyX3QgICAgICAgICAgICAgbGF0ZXN0X2lwX2FkZHI7ICAgIC8qIFRoZSBzcmMgSVAgYWRkcmVzcyBvZiB0aGUgbGFzdCBwYWNrZXQgKi8KKyAgICAgICAgc3RydWN0IGVnX2N0cmxfaW5mbyAgY3RybF9pbmZvOworICAgICAgICBhdG9taWNfdCAgICAgICAgICAgICB1c2U7Cit9IGVnX2NhY2hlX2VudHJ5OworCitzdHJ1Y3QgZWdfY2FjaGVfb3BzeworICAgICAgICBlZ19jYWNoZV9lbnRyeSAqKCphZGRfZW50cnkpKHN0cnVjdCBrX21lc3NhZ2UgKm1zZywgc3RydWN0IG1wb2FfY2xpZW50ICpjbGllbnQpOworICAgICAgICBlZ19jYWNoZV9lbnRyeSAqKCpnZXRfYnlfY2FjaGVfaWQpKHVpbnQzMl90IGNhY2hlX2lkLCBzdHJ1Y3QgbXBvYV9jbGllbnQgKmNsaWVudCk7CisgICAgICAgIGVnX2NhY2hlX2VudHJ5ICooKmdldF9ieV90YWcpKHVpbnQzMl90IGNhY2hlX2lkLCBzdHJ1Y3QgbXBvYV9jbGllbnQgKmNsaWVudCk7CisgICAgICAgIGVnX2NhY2hlX2VudHJ5ICooKmdldF9ieV92Y2MpKHN0cnVjdCBhdG1fdmNjICp2Y2MsIHN0cnVjdCBtcG9hX2NsaWVudCAqY2xpZW50K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dmVkICAgIjsKKwkJYnJlYWs7CisJY2FzZSBJTkdSRVNTX0lOVkFMSUQ6CisJICAgICAgICByZXR1cm4gImludmFsaWQgICAgIjsKKwkJYnJlYWs7CisJY2FzZSBJTkdSRVNTX1JFRlJFU0hJTkc6CisJICAgICAgICByZXR1cm4gInJlZnJlc2hpbmcgIjsKKwkJYnJlYWs7CisJZGVmYXVsdDoKKwkgICAgICAgcmV0dXJuICIiOworCX0KK30KKworLyoKKyAqIFJldHVybnMgdGhlIHN0YXRlIG9mIGFuIGVncmVzcyBjYWNoZSBlbnRyeSBhcyBhIHN0cmluZworICovCitzdGF0aWMgY29uc3QgY2hhciAqZWdyZXNzX3N0YXRlX3N0cmluZyhpbnQgc3RhdGUpeworICAgICAgICBzd2l0Y2goc3RhdGUpIHsKKwljYXNlIEVHUkVTU19SRVNPTFZFRDoKKwkgICAgICAgIHJldHVybiAicmVzb2x2ZWQgICAiOworCQlicmVhazsKKwljYXNlIEVHUkVTU19QVVJHRToKKyAgICAgICAgICAgICAgICByZXR1cm4gInB1cmdlICAgICAgIjsKKwkJYnJlYWs7CisJY2FzZSBFR1JFU1NfSU5WQUxJRDoKKwkgICAgICAgIHJldHVybiAiaW52YWxpZCAgICAiOworCQlicmVhazsKKwlkZWZhdWx0OgorCSAgICAgICByZXR1cm4gIiI7CisJfQorfQorCisvKgorICogRklYTUU6IG1wY3MgKGFuZCBwZXItbXBjIGxpc3RzKSBoYXZlIG5vIGxvY2tpbmcgd2hhdHNvZXZlci4KKyAqLworCitzdGF0aWMgdm9pZCAqbXBjX3N0YXJ0KHN0cnVjdCBzZXFfZmlsZSAqbSwgbG9mZl90ICpwb3MpCit7CisJbG9mZl90IGwgPSAqcG9zOworCXN0cnVjdCBtcG9hX2NsaWVudCAqbXBjOworCisJaWYgKCFsLS0pCisJCXJldHVybiBTRVFfU1RBUlRfVE9LRU47CisJZm9yIChtcGMgPSBtcGNzOyBtcGM7IG1wYyA9IG1wYy0+bmV4dCkKKwkJaWYgK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CisJc3Bpbl91bmxvY2soJmF0bV9kZXZfbG9jayk7CisKKwlpZiAoYXRtX3Byb2NfZGV2X3JlZ2lzdGVyKGRldikgPCAwKSB7CisJCXByaW50ayhLRVJOX0VSUiAiYXRtX2Rldl9yZWdpc3RlcjogIgorCQkgICAgICAgImF0bV9wcm9jX2Rldl9yZWdpc3RlciBmYWlsZWQgZm9yIGRldiAlc1xuIiwKKwkJICAgICAgIHR5cGUpOworCQlzcGluX2xvY2soJmF0bV9kZXZfbG9jayk7CisJCWxpc3RfZGVsKCZkZXYtPmRldl9saXN0KTsKKwkJc3Bpbl91bmxvY2soJmF0bV9kZXZfbG9jayk7CisJCV9fZnJlZV9hdG1fZGV2KGRldik7CisJCXJldHVybiBOVUxMOworCX0KKworCXJldHVybiBkZXY7Cit9CisKKwordm9pZCBhdG1fZGV2X2RlcmVnaXN0ZXIoc3RydWN0IGF0bV9kZXYgKmRldikKK3sKKwl1bnNpZ25lZCBsb25nIHdhcm5pbmdfdGltZTsKKworCWF0bV9wcm9jX2Rldl9kZXJlZ2lzdGVyKGRldik7CisKKwlzcGluX2xvY2soJmF0bV9kZXZfbG9jayk7CisJbGlzdF9kZWwoJmRldi0+ZGV2X2xpc3QpOworCXNwaW5fdW5sb2NrKCZhdG1fZGV2X2xvY2spOworCisgICAgICAgIHdhcm5pbmdfdGltZSA9IGppZmZpZXM7CisgICAgICAgIHdoaWxlIChhdG9taWNfcmVhZCgmZGV2LT5yZWZjbnQpICE9IDEpIHsKKyAgICAgICAgICAgICAgICBtc2xlZXAoMjUwKTsKKyAgICAgICAgICAgICAgICBpZiAoKGppZmZpZXMgLSB3YXJuaW5nX3RpbWUpID4gMTAgKiBIWikgeworICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnRrKEtFUk5fRU1FUkcgImF0bV9kZXZfZGVyZWdpc3Rlcjogd2FpdGluZyBmb3IgIgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICJkZXYgJWQgdG8gYmVjb21lIGZyZWUu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sgPSBzb2NrLT5zazsKKwlheDI1X2NiICpheDI1OworCXN0cnVjdCBuZXRfZGV2aWNlICpkZXY7CisJY2hhciBkZXZuYW1lW0lGTkFNU0laXTsKKwlpbnQgb3B0LCByZXMgPSAwOworCisJaWYgKGxldmVsICE9IFNPTF9BWDI1KQorCQlyZXR1cm4gLUVOT1BST1RPT1BUOworCisJaWYgKG9wdGxlbiA8IHNpemVvZihpbnQpKQorCQlyZXR1cm4gLUVJTlZBTDsKKworCWlmIChnZXRfdXNlcihvcHQsIChpbnQgX191c2VyICopb3B0dmFsKSkKKwkJcmV0dXJuIC1FRkFVTFQ7CisKKwlsb2NrX3NvY2soc2spOworCWF4MjUgPSBheDI1X3NrKHNrKTsKKworCXN3aXRjaCAob3B0bmFtZSkgeworCWNhc2UgQVgyNV9XSU5ET1c6CisJCWlmIChheDI1LT5tb2R1bHVzID09IEFYMjVfTU9EVUxVUykgeworCQkJaWYgKG9wdCA8IDEgfHwgb3B0ID4gNykgeworCQkJCXJlcyA9IC1FSU5WQUw7CisJCQkJYnJlYWs7CisJCQl9CisJCX0gZWxzZSB7CisJCQlpZiAob3B0IDwgMSB8fCBvcHQgPiA2MykgeworCQkJCXJlcyA9IC1FSU5WQUw7CisJCQkJYnJlYWs7CisJCQl9CisJCX0KKwkJYXgyNS0+d2luZG93ID0gb3B0OworCQlicmVhazsKKworCWNhc2UgQVgyNV9UMToKKwkJaWYgKG9wdCA8IDEpIHsKKwkJCXJlcyA9IC1FSU5WQUw7CisJCQlicmVhazsKKwkJfQorCQlheDI1LT5ydHQgPSAob3B0ICogSFopIC8gMjsKKwkJYXgyNS0+dDEgID0gb3B0ICogSFo7CisJCWJyZWFrOworCisJY2FzZSBBWDI1X1QyOgorCQlpZiAob3B0IDwgMSkgeworCQkJcmVzID0gLUVJTlZBTDsKKwkJCWJyZWFrOworCQl9CisJCWF4MjUtPnQyID0gb3B0ICogSFo7CisJCWJyZWFrOworCisJY2FzZSBBWDI1X04yOgorCQlpZiAob3B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DI1X2RldiAqYXgyNV9kZXYpCit7CisJc3RydWN0IHNvY2sgKnNrOworCWF4MjVfY2IgKmF4MjUsICpvYXgyNTsKKworCWlmICgoc2sgPSBza19hbGxvYyhQRl9BWDI1LCBHRlBfQVRPTUlDLCBvc2stPnNrX3Byb3QsIDEpKSA9PSBOVUxMKQorCQlyZXR1cm4gTlVMTDsKKworCWlmICgoYXgyNSA9IGF4MjVfY3JlYXRlX2NiKCkpID09IE5VTEwpIHsKKwkJc2tfZnJlZShzayk7CisJCXJldHVybiBOVUxMOworCX0KKworCXN3aXRjaCAob3NrLT5za190eXBlKSB7CisJY2FzZSBTT0NLX0RHUkFNOgorCQlicmVhazsKKwljYXNlIFNPQ0tfU0VRUEFDS0VUOgorCQlicmVhazsKKwlkZWZhdWx0OgorCQlza19mcmVlKHNrKTsKKwkJYXgyNV9jYl9wdXQoYXgyNSk7CisJCXJldHVybiBOVUxMOworCX0KKworCXNvY2tfaW5pdF9kYXRhKE5VTEwsIHNrKTsKKworCXNrLT5za19kZXN0cnVjdCA9IGF4MjVfZnJlZV9zb2NrOworCXNrLT5za190eXBlICAgICA9IG9zay0+c2tfdHlwZTsKKwlzay0+c2tfc29ja2V0ICAgPSBvc2stPnNrX3NvY2tldDsKKwlzay0+c2tfcHJpb3JpdHkgPSBvc2stPnNrX3ByaW9yaXR5OworCXNrLT5za19wcm90b2NvbCA9IG9zay0+c2tfcHJvdG9jb2w7CisJc2stPnNrX3JjdmJ1ZiAgID0gb3NrLT5za19yY3ZidWY7CisJc2stPnNrX3NuZGJ1ZiAgID0gb3NrLT5za19zbmRidWY7CisJc2stPnNrX3N0YXRlICAgID0gVENQX0VTVEFCTElTSEVEOworCXNrLT5za19zbGVlcCAgICA9IG9zay0+c2tfc2xlZXA7CisKKwlpZiAoc29ja19mbGFnKG9zaywgU09DS19EQkcpKQorCQlzb2NrX3NldF9mbGFnKHNrLCBTT0NLX0RCRyk7CisKKwlpZiAoc29ja19mbGFnKG9zaywgU09DS19aQVB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YW1lbGVuID0gc2l6ZW9mKHN0cnVjdCBmdWxsX3NvY2thZGRyX2F4MjUpOworCX0KKworCXNrYl9mcmVlX2RhdGFncmFtKHNrLCBza2IpOworCWVyciA9IGNvcGllZDsKKworb3V0OgorCXJlbGVhc2Vfc29jayhzayk7CisKKwlyZXR1cm4gZXJyOworfQorCitzdGF0aWMgaW50IGF4MjVfc2h1dGRvd24oc3RydWN0IHNvY2tldCAqc2ssIGludCBob3cpCit7CisJLyogRklYTUUgLSBnZW5lcmF0ZSBETSBhbmQgUk5SIHN0YXRlcyAqLworCXJldHVybiAtRU9QTk9UU1VQUDsKK30KKworc3RhdGljIGludCBheDI1X2lvY3RsKHN0cnVjdCBzb2NrZXQgKnNvY2ssIHVuc2lnbmVkIGludCBjbWQsIHVuc2lnbmVkIGxvbmcgYXJnKQoreworCXN0cnVjdCBzb2NrICpzayA9IHNvY2stPnNrOworCXZvaWQgX191c2VyICphcmdwID0gKHZvaWQgX191c2VyICopYXJnOworCWludCByZXMgPSAwOworCisJbG9ja19zb2NrKHNrKTsKKwlzd2l0Y2ggKGNtZCkgeworCWNhc2UgVElPQ09VVFE6IHsKKwkJbG9uZyBhbW91bnQ7CisJCWFtb3VudCA9IHNrLT5za19zbmRidWYgLSBhdG9taWNfcmVhZCgmc2stPnNrX3dtZW1fYWxsb2MpOworCQlpZiAoYW1vdW50IDwgMCkKKwkJCWFtb3VudCA9IDA7CisJCXJlcyA9IHB1dF91c2VyKGFtb3VudCwgKGludCBfX3VzZXIgKilhcmdwKTsKKwkJYnJlYWs7CisJfQorCisJY2FzZSBUSU9DSU5ROiB7CisJCXN0cnVjdCBza19idWZmICpza2I7CisJCWxvbmcgYW1vdW50ID0gMEw7CisJCS8qIFRoZXNlIHR3byBhcmUgc2FmZSBvbiBhIHNpbmdsZSBDUFUgc3lzdGVtIGFzIG9ubHkgdXNlciB0YXNrcyBmaWRkbGUgaGVyZSAqLworCQlpZiAoKHNrYiA9IHNrYl9wZWVrKCZzay0+c2t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gKHBpZCA9PSBBWDI1X1BfSVAgfHwgcGlkID09IEFYMjVfUF9BUlApCisJCXJldHVybiAwOworI2VuZGlmCisJaWYgKChwcm90b2NvbCA9IGttYWxsb2Moc2l6ZW9mKCpwcm90b2NvbCksIEdGUF9BVE9NSUMpKSA9PSBOVUxMKQorCQlyZXR1cm4gMDsKKworCXByb3RvY29sLT5waWQgID0gcGlkOworCXByb3RvY29sLT5mdW5jID0gZnVuYzsKKworCXdyaXRlX2xvY2soJnByb3RvY29sX2xpc3RfbG9jayk7CisJcHJvdG9jb2wtPm5leHQgPSBwcm90b2NvbF9saXN0OworCXByb3RvY29sX2xpc3QgID0gcHJvdG9jb2w7CisJd3JpdGVfdW5sb2NrKCZwcm90b2NvbF9saXN0X2xvY2spOworCisJcmV0dXJuIDE7Cit9CisKK3ZvaWQgYXgyNV9wcm90b2NvbF9yZWxlYXNlKHVuc2lnbmVkIGludCBwaWQpCit7CisJc3RydWN0IHByb3RvY29sX3N0cnVjdCAqcywgKnByb3RvY29sOworCisJd3JpdGVfbG9jaygmcHJvdG9jb2xfbGlzdF9sb2NrKTsKKwlwcm90b2NvbCA9IHByb3RvY29sX2xpc3Q7CisJaWYgKHByb3RvY29sID09IE5VTEwpIHsKKwkJd3JpdGVfdW5sb2NrKCZwcm90b2NvbF9saXN0X2xvY2spOworCQlyZXR1cm47CisJfQorCisJaWYgKHByb3RvY29sLT5waWQgPT0gcGlkKSB7CisJCXByb3RvY29sX2xpc3QgPSBwcm90b2NvbC0+bmV4dDsKKwkJd3JpdGVfdW5sb2NrKCZwcm90b2NvbF9saXN0X2xvY2spOworCQlrZnJlZShwcm90b2NvbCk7CisJCXJldHVybjsKKwl9CisKKwl3aGlsZSAocHJvdG9jb2wgIT0gTlVMTCAmJiBwcm90b2NvbC0+bmV4dCAhPSBOVUxMKSB7CisJCWlmIChwcm90b2NvbC0+bmV4dC0+cGlkID09IHBpZCkgeworCQkJcyA9IHByb3RvY29sLT5uZXh0OworCQkJcHJvdG9j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4MjVfY2IgKmF4MjUpCit7CisJZGVsX3RpbWVyKCZheDI1LT50M3RpbWVyKTsKKworCWlmIChheDI1LT50MyA+IDApIHsKKwkJYXgyNS0+dDN0aW1lci5kYXRhICAgICA9ICh1bnNpZ25lZCBsb25nKWF4MjU7CisJCWF4MjUtPnQzdGltZXIuZnVuY3Rpb24gPSAmYXgyNV90M3RpbWVyX2V4cGlyeTsKKwkJYXgyNS0+dDN0aW1lci5leHBpcmVzICA9IGppZmZpZXMgKyBheDI1LT50MzsKKworCQlhZGRfdGltZXIoJmF4MjUtPnQzdGltZXIpOworCX0KK30KKwordm9pZCBheDI1X3N0YXJ0X2lkbGV0aW1lcihheDI1X2NiICpheDI1KQoreworCWRlbF90aW1lcigmYXgyNS0+aWRsZXRpbWVyKTsKKworCWlmIChheDI1LT5pZGxlID4gMCkgeworCQlheDI1LT5pZGxldGltZXIuZGF0YSAgICAgPSAodW5zaWduZWQgbG9uZylheDI1OworCQlheDI1LT5pZGxldGltZXIuZnVuY3Rpb24gPSAmYXgyNV9pZGxldGltZXJfZXhwaXJ5OworCQlheDI1LT5pZGxldGltZXIuZXhwaXJlcyAgPSBqaWZmaWVzICsgYXgyNS0+aWRsZTsKKworCQlhZGRfdGltZXIoJmF4MjUtPmlkbGV0aW1lcik7CisJfQorfQorCit2b2lkIGF4MjVfc3RvcF9oZWFydGJlYXQoYXgyNV9jYiAqYXgyNSkKK3sKKwlkZWxfdGltZXIoJmF4MjUtPnRpbWVyKTsKK30KKwordm9pZCBheDI1X3N0b3BfdDF0aW1lcihheDI1X2NiICpheDI1KQoreworCWRlbF90aW1lcigmYXgyNS0+dDF0aW1lcik7Cit9CisKK3ZvaWQgYXgyNV9zdG9wX3QydGltZXIoYXgyNV9jYiAqYXgyNSkKK3sKKwlkZWxfdGltZXIoJmF4MjUtPnQydGltZXIpOworfQorCit2b2lkIGF4MjVfc3RvcF90M3RpbWVyKGF4MjVfY2IgKmF4MjUpCit7CisJZGVsX3RpbWVyKCZheDI1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K3N0cnVjdCBibmVwX3NldHVwX2Nvbm5fcmVxIHsKKwlfX3U4ICB0eXBlOworCV9fdTggIGN0cmw7CisJX191OCAgdXVpZF9zaXplOworCV9fdTggIHNlcnZpY2VbMF07Cit9IF9fYXR0cmlidXRlX18oKHBhY2tlZCkpOworCitzdHJ1Y3QgYm5lcF9zZXRfZmlsdGVyX3JlcSB7CisJX191OCAgdHlwZTsKKwlfX3U4ICBjdHJsOworCV9fdTE2IGxlbjsKKwlfX3U4ICBsaXN0WzBdOworfSBfX2F0dHJpYnV0ZV9fKChwYWNrZWQpKTsKKworc3RydWN0IGJuZXBfY29udHJvbF9yc3AgeworCV9fdTggIHR5cGU7CisJX191OCAgY3RybDsKKwlfX3UxNiByZXNwOworfSBfX2F0dHJpYnV0ZV9fKChwYWNrZWQpKTsKKworc3RydWN0IGJuZXBfZXh0X2hkciB7CisJX191OCAgdHlwZTsKKwlfX3U4ICBsZW47CisJX191OCAgZGF0YVswXTsKK30gX19hdHRyaWJ1dGVfXygocGFja2VkKSk7CisKKy8qIEJORVAgaW9jdGwgZGVmaW5lcyAqLworI2RlZmluZSBCTkVQQ09OTkFERAlfSU9XKCdCJywgMjAwLCBpbnQpCisjZGVmaW5lIEJORVBDT05OREVMCV9JT1coJ0InLCAyMDEsIGludCkKKyNkZWZpbmUgQk5FUEdFVENPTk5MSVNUCV9JT1IoJ0InLCAyMTAsIGludCkKKyNkZWZpbmUgQk5FUEdFVENPTk5JTkZPCV9JT1IoJ0InLCAyMTEsIGludCkKKworc3RydWN0IGJuZXBfY29ubmFkZF9yZXEgeworCWludCAgIHNvY2s7ICAgICAgIC8vIENvbm5lY3RlZCBzb2NrZXQKKwlfX3UzMiBmbGFnczsKKwlfX3UxNiByb2xlOworCWNoYXIgIGRldmljZVsxNl07IC8vIE5hbWUgb2YgdGhlIEV0aGVybmV0IGRldmljZQorfTsKKworc3RydWN0IGJuZXBfY29ubmRlbF9yZXEgeworCV9fdTMyIGZsYWdzOworCV9fdTggIGR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QljYXNlIEJORVBfRVhUX0NPTlRST0w6CisJCQlibmVwX3J4X2NvbnRyb2wocywgc2tiLT5kYXRhLCBza2ItPmxlbik7CisJCQlicmVhazsKKworCQlkZWZhdWx0OgorCQkJLyogVW5rbm93biBleHRlbnNpb24sIHNraXAgaXQuICovCisJCQlicmVhazsKKwkJfQorCisJCWlmICghc2tiX3B1bGwoc2tiLCBoLT5sZW4pKSB7CisJCQllcnIgPSAtRUlMU0VROworCQkJYnJlYWs7CisJCX0KKwl9IHdoaWxlICghZXJyICYmIChoLT50eXBlICYgQk5FUF9FWFRfSEVBREVSKSk7CisJCisJcmV0dXJuIGVycjsKK30KKworc3RhdGljIHU4IF9fYm5lcF9yeF9obGVuW10gPSB7CisJRVRIX0hMRU4sICAgICAvKiBCTkVQX0dFTkVSQUwgKi8KKwkwLCAgICAgICAgICAgIC8qIEJORVBfQ09OVFJPTCAqLworCTIsICAgICAgICAgICAgLyogQk5FUF9DT01QUkVTU0VEICovCisJRVRIX0FMRU4gKyAyLCAvKiBCTkVQX0NPTVBSRVNTRURfU1JDX09OTFkgKi8KKwlFVEhfQUxFTiArIDIgIC8qIEJORVBfQ09NUFJFU1NFRF9EU1RfT05MWSAqLworfTsKKyNkZWZpbmUgQk5FUF9SWF9UWVBFUwkoc2l6ZW9mKF9fYm5lcF9yeF9obGVuKSAtIDEpCisKK3N0YXRpYyBpbmxpbmUgaW50IGJuZXBfcnhfZnJhbWUoc3RydWN0IGJuZXBfc2Vzc2lvbiAqcywgc3RydWN0IHNrX2J1ZmYgKnNrYikKK3sKKwlzdHJ1Y3QgbmV0X2RldmljZSAqZGV2ID0gcy0+ZGV2OworCXN0cnVjdCBza19idWZmICpuc2tiOworCXU4IHR5cGU7CisKKwlkZXYtPmxhc3RfcnggPSBqaWZmaWVzOworCXMtPnN0YXRzLnJ4X2J5dGVzICs9IHNrYi0+bGVuOworCisJdHlwZSA9ICoodTggKikgc2tiLT5kYXRhOyBza2JfcHVsbChza2IsIDEpOworCisJa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BkbWktPm5leHQ7CisJCX0KKwkJci0+bGVuID0gaHRvbnMoc2tiLT5sZW4gLSBsZW4pOworCX0KKworCXNrYl9xdWV1ZV90YWlsKCZzay0+c2tfd3JpdGVfcXVldWUsIHNrYik7CisJd2FrZV91cF9pbnRlcnJ1cHRpYmxlKHNrLT5za19zbGVlcCk7CisjZW5kaWYKK30KKworc3RhdGljIGludCBibmVwX25ldF9zZXRfbWFjX2FkZHIoc3RydWN0IG5ldF9kZXZpY2UgKmRldiwgdm9pZCAqYXJnKQoreworCUJUX0RCRygiJXMiLCBkZXYtPm5hbWUpOworCXJldHVybiAwOworfQorCitzdGF0aWMgdm9pZCBibmVwX25ldF90aW1lb3V0KHN0cnVjdCBuZXRfZGV2aWNlICpkZXYpCit7CisJQlRfREJHKCJuZXRfdGltZW91dCIpOworCW5ldGlmX3dha2VfcXVldWUoZGV2KTsKK30KKworc3RhdGljIGludCBibmVwX25ldF9pb2N0bChzdHJ1Y3QgbmV0X2RldmljZSAqZGV2LCBzdHJ1Y3QgaWZyZXEgKmlmciwgaW50IGNtZCkKK3sKKwlyZXR1cm4gLUVJTlZBTDsKK30KKworI2lmZGVmIENPTkZJR19CVF9CTkVQX01DX0ZJTFRFUgorc3RhdGljIGlubGluZSBpbnQgYm5lcF9uZXRfbWNfZmlsdGVyKHN0cnVjdCBza19idWZmICpza2IsIHN0cnVjdCBibmVwX3Nlc3Npb24gKnMpCit7CisJc3RydWN0IGV0aGhkciAqZWggPSAodm9pZCAqKSBza2ItPmRhdGE7CisKKwlpZiAoKGVoLT5oX2Rlc3RbMF0gJiAxKSAmJiAhdGVzdF9iaXQoYm5lcF9tY19oYXNoKGVoLT5oX2Rlc3QpLCAodWxvbmcgKikgJnMtPm1jX2ZpbHRlcikpCisJCXJldHVybiAxOworCXJldHVybiAwOworfQorI2VuZGlmCisKKyNpZmRlZiBDT05GSUdfQlRfQk5FUF9QUk9UT19GSUxURVIKKy8qIERldGVybWluZSBldGhlciBwcm90b2NvbC4gQm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ROQU1TSVogMTgKKworLyogQ01UUCBpb2N0bCBkZWZpbmVzICovCisjZGVmaW5lIENNVFBDT05OQURECV9JT1coJ0MnLCAyMDAsIGludCkKKyNkZWZpbmUgQ01UUENPTk5ERUwJX0lPVygnQycsIDIwMSwgaW50KQorI2RlZmluZSBDTVRQR0VUQ09OTkxJU1QJX0lPUignQycsIDIxMCwgaW50KQorI2RlZmluZSBDTVRQR0VUQ09OTklORk8JX0lPUignQycsIDIxMSwgaW50KQorCisjZGVmaW5lIENNVFBfTE9PUEJBQ0sJMAorCitzdHJ1Y3QgY210cF9jb25uYWRkX3JlcSB7CisJaW50ICAgc29jazsJLy8gQ29ubmVjdGVkIHNvY2tldAorCV9fdTMyIGZsYWdzOworfTsKKworc3RydWN0IGNtdHBfY29ubmRlbF9yZXEgeworCWJkYWRkcl90IGJkYWRkcjsKKwlfX3UzMiAgICBmbGFnczsKK307CisKK3N0cnVjdCBjbXRwX2Nvbm5pbmZvIHsKKwliZGFkZHJfdCBiZGFkZHI7CisJX191MzIgICAgZmxhZ3M7CisJX191MTYgICAgc3RhdGU7CisJaW50ICAgICAgbnVtOworfTsKKworc3RydWN0IGNtdHBfY29ubmxpc3RfcmVxIHsKKwlfX3UzMiAgY251bTsKKwlzdHJ1Y3QgY210cF9jb25uaW5mbyBfX3VzZXIgKmNpOworfTsKKworaW50IGNtdHBfYWRkX2Nvbm5lY3Rpb24oc3RydWN0IGNtdHBfY29ubmFkZF9yZXEgKnJlcSwgc3RydWN0IHNvY2tldCAqc29jayk7CitpbnQgY210cF9kZWxfY29ubmVjdGlvbihzdHJ1Y3QgY210cF9jb25uZGVsX3JlcSAqcmVxKTsKK2ludCBjbXRwX2dldF9jb25ubGlzdChzdHJ1Y3QgY210cF9jb25ubGlzdF9yZXEgKnJlcSk7CitpbnQgY210cF9nZXRfY29ubmluZm8oc3RydWN0IGNtdHBfY29ubmluZm8gKmNpKTsKKworLyogQ01UUCBzZXNzaW9uIGRlZmluZXMgKi8KKyNkZWZ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c3RydWN0IGNtdHBfc2Vzc2lvbiwgbGlzdCk7CisKKwkJX19jbXRwX2NvcHlfc2Vzc2lvbihzZXNzaW9uLCAmY2kpOworCisJCWlmIChjb3B5X3RvX3VzZXIocmVxLT5jaSwgJmNpLCBzaXplb2YoY2kpKSkgeworCQkJZXJyID0gLUVGQVVMVDsKKwkJCWJyZWFrOworCQl9CisKKwkJaWYgKCsrbiA+PSByZXEtPmNudW0pCisJCQlicmVhazsKKworCQlyZXEtPmNpKys7CisJfQorCXJlcS0+Y251bSA9IG47CisKKwl1cF9yZWFkKCZjbXRwX3Nlc3Npb25fc2VtKTsKKwlyZXR1cm4gZXJyOworfQorCitpbnQgY210cF9nZXRfY29ubmluZm8oc3RydWN0IGNtdHBfY29ubmluZm8gKmNpKQoreworCXN0cnVjdCBjbXRwX3Nlc3Npb24gKnNlc3Npb247CisJaW50IGVyciA9IDA7CisKKwlkb3duX3JlYWQoJmNtdHBfc2Vzc2lvbl9zZW0pOworCisJc2Vzc2lvbiA9IF9fY210cF9nZXRfc2Vzc2lvbigmY2ktPmJkYWRkcik7CisJaWYgKHNlc3Npb24pCisJCV9fY210cF9jb3B5X3Nlc3Npb24oc2Vzc2lvbiwgY2kpOworCWVsc2UKKwkJZXJyID0gLUVOT0VOVDsKKworCXVwX3JlYWQoJmNtdHBfc2Vzc2lvbl9zZW0pOworCXJldHVybiBlcnI7Cit9CisKKworc3RhdGljIGludCBfX2luaXQgY210cF9pbml0KHZvaWQpCit7CisJbDJjYXBfbG9hZCgpOworCisJQlRfSU5GTygiQ01UUCAoQ0FQSSBFbXVsYXRpb24pIHZlciAlcyIsIFZFUlNJT04pOworCisJY210cF9pbml0X3NvY2tldHMoKTsKKworCXJldHVybiAwOworfQorCitzdGF0aWMgdm9pZCBfX2V4aXQgY210cF9leGl0KHZvaWQpCit7CisJY210cF9jbGVhbnVwX3NvY2tldHMoKTsKK30KKworbW9kdWxlX2luaXQoY210cF9pbml0KTsKK21vZHVsZV9leGl0KGNtdH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zaXplLCBHRlBfS0VSTkVMKSkpCisJCXJldHVybiAtRU5PTUVNOworCisJaWYgKCEoaGRldiA9IGhjaV9kZXZfZ2V0KHJlcS5kZXZfaWQpKSkgeworCQlrZnJlZShjbCk7CisJCXJldHVybiAtRU5PREVWOworCX0KKworCWNpID0gY2wtPmNvbm5faW5mbzsKKworCWhjaV9kZXZfbG9ja19iaChoZGV2KTsKKwlsaXN0X2Zvcl9lYWNoKHAsICZoZGV2LT5jb25uX2hhc2gubGlzdCkgeworCQlyZWdpc3RlciBzdHJ1Y3QgaGNpX2Nvbm4gKmM7CisJCWMgPSBsaXN0X2VudHJ5KHAsIHN0cnVjdCBoY2lfY29ubiwgbGlzdCk7CisKKwkJYmFjcHkoJihjaSArIG4pLT5iZGFkZHIsICZjLT5kc3QpOworCQkoY2kgKyBuKS0+aGFuZGxlID0gYy0+aGFuZGxlOworCQkoY2kgKyBuKS0+dHlwZSAgPSBjLT50eXBlOworCQkoY2kgKyBuKS0+b3V0ICAgPSBjLT5vdXQ7CisJCShjaSArIG4pLT5zdGF0ZSA9IGMtPnN0YXRlOworCQkoY2kgKyBuKS0+bGlua19tb2RlID0gYy0+bGlua19tb2RlOworCQlpZiAoKytuID49IHJlcS5jb25uX251bSkKKwkJCWJyZWFrOworCX0KKwloY2lfZGV2X3VubG9ja19iaChoZGV2KTsKKworCWNsLT5kZXZfaWQgPSBoZGV2LT5pZDsKKwljbC0+Y29ubl9udW0gPSBuOworCXNpemUgPSBzaXplb2YocmVxKSArIG4gKiBzaXplb2YoKmNpKTsKKworCWhjaV9kZXZfcHV0KGhkZXYpOworCisJZXJyID0gY29weV90b191c2VyKGFyZywgY2wsIHNpemUpOworCWtmcmVlKGNsKTsKKworCXJldHVybiBlcnIgPyAtRUZBVUxUIDogMDsKK30KKworaW50IGhjaV9nZXRfY29ubl9pbmZvKHN0cnVjdCBoY2lfZGV2ICpoZGV2LCB2b2lkIF9fdXNlciAqYXJnKQoreworCXN0cnVjdCBoY2lfY29ubl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mVudF9tYXNrKSkKKwkJCQljb250aW51ZTsKKworCQkJaWYgKGZsdC0+b3Bjb2RlICYmICgoZXZ0ID09IEhDSV9FVl9DTURfQ09NUExFVEUgJiYgCisJCQkJCWZsdC0+b3Bjb2RlICE9ICooX191MTYgKikoc2tiLT5kYXRhICsgMykpIHx8CisJCQkJCShldnQgPT0gSENJX0VWX0NNRF9TVEFUVVMgJiYgCisJCQkJCWZsdC0+b3Bjb2RlICE9ICooX191MTYgKikoc2tiLT5kYXRhICsgNCkpKSkKKwkJCQljb250aW51ZTsKKwkJfQorCisJCWlmICghKG5za2IgPSBza2JfY2xvbmUoc2tiLCBHRlBfQVRPTUlDKSkpCisJCQljb250aW51ZTsKKworCQkvKiBQdXQgdHlwZSBieXRlIGJlZm9yZSB0aGUgZGF0YSAqLworCQltZW1jcHkoc2tiX3B1c2gobnNrYiwgMSksICZuc2tiLT5wa3RfdHlwZSwgMSk7CisKKwkJaWYgKHNvY2tfcXVldWVfcmN2X3NrYihzaywgbnNrYikpCisJCQlrZnJlZV9za2IobnNrYik7CisJfQorCXJlYWRfdW5sb2NrKCZoY2lfc2tfbGlzdC5sb2NrKTsKK30KKworc3RhdGljIGludCBoY2lfc29ja19yZWxlYXNlKHN0cnVjdCBzb2NrZXQgKnNvY2spCit7CisJc3RydWN0IHNvY2sgKnNrID0gc29jay0+c2s7CisJc3RydWN0IGhjaV9kZXYgKmhkZXYgPSBoY2lfcGkoc2spLT5oZGV2OworCisJQlRfREJHKCJzb2NrICVwIHNrICVwIiwgc29jaywgc2spOworCisJaWYgKCFzaykKKwkJcmV0dXJuIDA7CisKKwlidF9zb2NrX3VubGluaygmaGNpX3NrX2xpc3QsIHNrKTsKKworCWlmIChoZGV2KSB7CisJCWF0b21pY19kZWMoJmhkZXYtPnByb21pc2MpOworCQloY2lfZGV2X3B1dChoZGV2KTsKKwl9CisKKwlzb2NrX29ycGhhbihzayk7CisKKwlza2JfcXVldWVfcHVyZ2UoJnNrLT5za19yZWNlaXZl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sKKwkJCWhjaV9zY2hlZF9jbWQoaGRldik7CisJCX0KKwl9IGVsc2UgeworCQlpZiAoIWNhcGFibGUoQ0FQX05FVF9SQVcpKSB7CisJCQllcnIgPSAtRVBFUk07CisJCQlnb3RvIGRyb3A7CisJCX0KKworCQlza2JfcXVldWVfdGFpbCgmaGRldi0+cmF3X3EsIHNrYik7CisJCWhjaV9zY2hlZF90eChoZGV2KTsKKwl9CisKKwllcnIgPSBsZW47CisKK2RvbmU6CisJcmVsZWFzZV9zb2NrKHNrKTsKKwlyZXR1cm4gZXJyOworCitkcm9wOgorCWtmcmVlX3NrYihza2IpOworCWdvdG8gZG9uZTsKK30KKworc3RhdGljIGludCBoY2lfc29ja19zZXRzb2Nrb3B0KHN0cnVjdCBzb2NrZXQgKnNvY2ssIGludCBsZXZlbCwgaW50IG9wdG5hbWUsIGNoYXIgX191c2VyICpvcHR2YWwsIGludCBsZW4pCit7CisJc3RydWN0IGhjaV91ZmlsdGVyIHVmID0geyAub3Bjb2RlID0gMCB9OworCXN0cnVjdCBzb2NrICpzayA9IHNvY2stPnNrOworCWludCBlcnIgPSAwLCBvcHQgPSAwOworCisJQlRfREJHKCJzayAlcCwgb3B0ICVkIiwgc2ssIG9wdG5hbWUpOworCisJbG9ja19zb2NrKHNrKTsKKworCXN3aXRjaCAob3B0bmFtZSkgeworCWNhc2UgSENJX0RBVEFfRElSOgorCQlpZiAoZ2V0X3VzZXIob3B0LCAoaW50IF9fdXNlciAqKW9wdHZhbCkpIHsKKwkJCWVyciA9IC1FRkFVTFQ7CisJCQlicmVhazsKKwkJfQorCisJCWlmIChvcHQpCisJCQloY2lfcGkoc2spLT5jbXNnX21hc2sgfD0gSENJX0NNU0dfRElSOworCQllbHNlCisJCQloY2lfcGkoc2spLT5jbXNnX21hc2sgJj0gfkhDSV9DTVNHX0RJUjsKKwkJYnJlYWs7CisKKwljYXNlIEhDSV9USU1FX1NUQU1QOgorCQlpZiAoZ2V0X3VzZXIob3B0LCAoaW50IF9f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QX1BST1RPX0JPT1QJCQkJMHgwMAorI2RlZmluZSBISURQX1BST1RPX1JFUE9SVAkJCTB4MDEKKworLyogSElEUCBpb2N0bCBkZWZpbmVzICovCisjZGVmaW5lIEhJRFBDT05OQURECV9JT1coJ0gnLCAyMDAsIGludCkKKyNkZWZpbmUgSElEUENPTk5ERUwJX0lPVygnSCcsIDIwMSwgaW50KQorI2RlZmluZSBISURQR0VUQ09OTkxJU1QJX0lPUignSCcsIDIxMCwgaW50KQorI2RlZmluZSBISURQR0VUQ09OTklORk8JX0lPUignSCcsIDIxMSwgaW50KQorCisjZGVmaW5lIEhJRFBfVklSVFVBTF9DQUJMRV9VTlBMVUcJMAorI2RlZmluZSBISURQX0JPT1RfUFJPVE9DT0xfTU9ERQkJMQorI2RlZmluZSBISURQX0JMVUVUT09USF9WRU5ET1JfSUQJOQorCitzdHJ1Y3QgaGlkcF9jb25uYWRkX3JlcSB7CisJaW50ICAgY3RybF9zb2NrOwkvLyBDb25uZWN0ZWQgY29udHJvbCBzb2NrZXQKKwlpbnQgICBpbnRyX3NvY2s7CS8vIENvbm50ZXRlZCBpbnRlcnJ1cHQgc29ja2V0CisJX191MTYgcGFyc2VyOworCV9fdTE2IHJkX3NpemU7CisJX191OCAqcmRfZGF0YTsKKwlfX3U4ICBjb3VudHJ5OworCV9fdTggIHN1YmNsYXNzOworCV9fdTE2IHZlbmRvcjsKKwlfX3UxNiBwcm9kdWN0OworCV9fdTE2IHZlcnNpb247CisJX191MzIgZmxhZ3M7CisJX191MzIgaWRsZV90bzsKKwljaGFyICBuYW1lWzEyOF07Cit9OworCitzdHJ1Y3QgaGlkcF9jb25uZGVsX3JlcSB7CisJYmRhZGRyX3QgYmRhZGRyOworCV9fdTMyICAgIGZsYWdzOworfTsKKworc3RydWN0IGhpZHBfY29ubmluZm8geworCWJkYWRkcl90IGJkYWRkcjsKKwlfX3UzMiAgICBmbGFnczsKKwlfX3UxNiAgICBzdGF0ZTsKKwlfX3UxNiAgICB2ZW5k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Vfc29jayhzayk7CisJcmV0dXJuIGVycjsKK30KKworc3RhdGljIGludCBsMmNhcF9zb2NrX2dldHNvY2tvcHQoc3RydWN0IHNvY2tldCAqc29jaywgaW50IGxldmVsLCBpbnQgb3B0bmFtZSwgY2hhciBfX3VzZXIgKm9wdHZhbCwgaW50IF9fdXNlciAqb3B0bGVuKQoreworCXN0cnVjdCBzb2NrICpzayA9IHNvY2stPnNrOworCXN0cnVjdCBsMmNhcF9vcHRpb25zIG9wdHM7CisJc3RydWN0IGwyY2FwX2Nvbm5pbmZvIGNpbmZvOworCWludCBsZW4sIGVyciA9IDA7CisKKwlCVF9EQkcoInNrICVwIiwgc2spOworCisJaWYgKGdldF91c2VyKGxlbiwgb3B0bGVuKSkKKwkJcmV0dXJuIC1FRkFVTFQ7CisKKwlsb2NrX3NvY2soc2spOworCisJc3dpdGNoIChvcHRuYW1lKSB7CisJY2FzZSBMMkNBUF9PUFRJT05TOgorCQlvcHRzLmltdHUgICAgID0gbDJjYXBfcGkoc2spLT5pbXR1OworCQlvcHRzLm9tdHUgICAgID0gbDJjYXBfcGkoc2spLT5vbXR1OworCQlvcHRzLmZsdXNoX3RvID0gbDJjYXBfcGkoc2spLT5mbHVzaF90bzsKKwkJb3B0cy5tb2RlICAgICA9IDB4MDA7CisKKwkJbGVuID0gbWluX3QodW5zaWduZWQgaW50LCBsZW4sIHNpemVvZihvcHRzKSk7CisJCWlmIChjb3B5X3RvX3VzZXIob3B0dmFsLCAoY2hhciAqKSAmb3B0cywgbGVuKSkKKwkJCWVyciA9IC1FRkFVTFQ7CisKKwkJYnJlYWs7CisKKwljYXNlIEwyQ0FQX0xNOgorCQlpZiAocHV0X3VzZXIobDJjYXBfcGkoc2spLT5saW5rX21vZGUsICh1MzIgX191c2VyICopIG9wdHZhbCkpCisJCQllcnIgPSAtRUZBVUxUOworCQlicmVhazsKKworCWNhc2UgTDJDQVBfQ09OTklORk86CisJCWlmIChzay0+c2tfc3RhdGUgIT0gQlRfQ09OTkVDVEVEKSB7CisJCQllcnIgPSAtRU5PVENPTk47CisJCQlicmVhazsKKwkJfQorCisJCWNpbmZvLmhjaV9oYW5kbGUgPSBsMmNhcF9waShzayktPmNvbm4tPmhjb24tPmhhbmRsZTsKKwkJbWVtY3B5KGNpbmZvLmRldl9jbGFzcywgbDJjYXBfcGkoc2spLT5jb25uLT5oY29uLT5kZXZfY2xhc3MsIDMpOworCisJCWxlbiA9IG1pbl90KHVuc2lnbmVkIGludCwgbGVuLCBzaXplb2YoY2luZm8pKTsKKwkJaWYgKGNvcHlfdG9fdXNlcihvcHR2YWwsIChjaGFyICopICZjaW5mbywgbGVuKSkKKwkJCWVyciA9IC1FRkFVTFQ7CisKKwkJYnJlYWs7CisKKwlkZWZhdWx0OgorCQllcnIgPSAtRU5PUFJPVE9PUFQ7CisJCWJyZWFrOworCX0KKworCXJlbGVhc2Vfc29jayhzayk7CisJcmV0dXJuIGVycjsKK30KKworc3RhdGljIGludCBsMmNhcF9zb2NrX3NodXRkb3duKHN0cnVjdCBzb2NrZXQgKnNvY2ssIGludCBob3cpCit7CisJc3RydWN0IHNvY2sgKnNrID0gc29jay0+c2s7CisJaW50IGVyciA9IDA7CisKKwlCVF9EQkcoInNvY2sgJXAsIHNrICVwIiwgc29jaywgc2spOworCisJaWYgKCFzaykKKwkJcmV0dXJuIDA7CisKKwlsb2NrX3NvY2soc2spOworCWlmICghc2stPnNrX3NodXRkb3duKSB7CisJCXNrLT5za19zaHV0ZG93biA9IFNIVVRET1dOX01BU0s7CisJCWwyY2FwX3NvY2tfY2xlYXJfdGltZXIoc2spOworCQlfX2wyY2FwX3NvY2tfY2xvc2Uoc2ssIDApOworCisJCWlmIChzb2NrX2ZsYWcoc2ssIFNPQ0tfTElOR0VSKSAmJiBzay0+c2tfbGluZ2VydGltZSkKKwkJCWVyciA9IGJ0X3NvY2tfd2FpdF9zdGF0ZShzaywgQlRfQ0xPU0VELCBzay0+c2tfbGluZ2VydGltZSk7CisJfQorCXJlbGVhc2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ZiBzb2NrZXQgcmVjdiBidWZmZXJzIG92ZXJmbG93cyB3ZSBkcm9wIGRhdGEgaGVyZQorCSAqIHdoaWNoIGlzICpiYWQqIGJlY2F1c2UgTDJDQVAgaGFzIHRvIGJlIHJlbGlhYmxlLgorCSAqIEJ1dCB3ZSBkb24ndCBoYXZlIGFueSBvdGhlciBjaG9pY2UuIEwyQ0FQIGRvZXNuJ3QKKwkgKiBwcm92aWRlIGZsb3cgY29udHJvbCBtZWNoYW5pc20uICovCisKKwlpZiAoIXNvY2tfcXVldWVfcmN2X3NrYihzaywgc2tiKSkKKwkJZ290byBkb25lOworCitkcm9wOgorCWtmcmVlX3NrYihza2IpOworCitkb25lOgorCWlmIChzaykgYmhfdW5sb2NrX3NvY2soc2spOworCXJldHVybiAwOworfQorCitzdGF0aWMgaW5saW5lIGludCBsMmNhcF9jb25sZXNzX2NoYW5uZWwoc3RydWN0IGwyY2FwX2Nvbm4gKmNvbm4sIHUxNiBwc20sIHN0cnVjdCBza19idWZmICpza2IpCit7CisJc3RydWN0IHNvY2sgKnNrOworCisJc2sgPSBsMmNhcF9nZXRfc29ja19ieV9wc20oMCwgcHNtLCBjb25uLT5zcmMpOworCWlmICghc2spCisJCWdvdG8gZHJvcDsKKworCUJUX0RCRygic2sgJXAsIGxlbiAlZCIsIHNrLCBza2ItPmxlbik7CisKKwlpZiAoc2stPnNrX3N0YXRlICE9IEJUX0JPVU5EICYmIHNrLT5za19zdGF0ZSAhPSBCVF9DT05ORUNURUQpCisJCWdvdG8gZHJvcDsKKworCWlmIChsMmNhcF9waShzayktPmltdHUgPCBza2ItPmxlbikKKwkJZ290byBkcm9wOworCisJaWYgKCFzb2NrX3F1ZXVlX3Jjdl9za2Ioc2ssIHNrYikpCisJCWdvdG8gZG9uZTsKKworZHJvcDoKKwlrZnJlZV9za2Ioc2tiKTsKKworZG9uZToKKwlpZiAoc2spIGJoX3VubG9ja19zb2NrKHNrKTsKKwlyZXR1cm4gMDsKK30KKworc3RhdGljIH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isKKwlCVF9EQkcoImNvbm4gJXAiLCBjb25uKTsKKworCXJlYWRfbG9jaygmbC0+bG9jayk7CisKKwlmb3IgKHNrID0gbC0+aGVhZDsgc2s7IHNrID0gbDJjYXBfcGkoc2spLT5uZXh0X2MpIHsKKwkJYmhfbG9ja19zb2NrKHNrKTsKKworCQlpZiAoc2stPnNrX3N0YXRlICE9IEJUX0NPTk5FQ1QyKSB7CisJCQliaF91bmxvY2tfc29jayhzayk7CisJCQljb250aW51ZTsKKwkJfQorCisJCWlmICghc3RhdHVzKSB7CisJCQlzay0+c2tfc3RhdGUgPSBCVF9DT05GSUc7CisJCQlyZXN1bHQgPSAwOworCQl9IGVsc2UgeworCQkJc2stPnNrX3N0YXRlID0gQlRfRElTQ09OTjsKKwkJCWwyY2FwX3NvY2tfc2V0X3RpbWVyKHNrLCBIWi8xMCk7CisJCQlyZXN1bHQgPSBMMkNBUF9DUl9TRUNfQkxPQ0s7CisJCX0KKworCQlyc3Auc2NpZCAgID0gX19jcHVfdG9fbGUxNihsMmNhcF9waShzayktPmRjaWQpOworCQlyc3AuZGNpZCAgID0gX19jcHVfdG9fbGUxNihsMmNhcF9waShzayktPnNjaWQpOworCQlyc3AucmVzdWx0ID0gX19jcHVfdG9fbGUxNihyZXN1bHQpOworCQlyc3Auc3RhdHVzID0gX19jcHVfdG9fbGUxNigwKTsKKwkJbDJjYXBfc2VuZF9jbWQoY29ubiwgbDJjYXBfcGkoc2spLT5pZGVudCwKKwkJCQlMMkNBUF9DT05OX1JTUCwgc2l6ZW9mKHJzcCksICZyc3ApOworCisJCWlmIChsMmNhcF9waShzayktPmxpbmtfbW9kZSAmIEwyQ0FQX0xNX1NFQ1VSRSkKKwkJCWhjaV9jb25uX2NoYW5nZV9saW5rX2tleShoY29uKTsKKworCQliaF91bmxvY2tfc29jayhzayk7CisJfQorCisJcmVhZF91bmxvY2soJmwtPmxvY2spOworCXJldHVybiAwOworfQorCitzdGF0aWMgaW50IGwyY2FwX3JlY3ZfYWN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dldF9kaXIoYikgICAgICAoKGIgJiAweDA0KSA+PiAyKQorI2RlZmluZSBfX2dldF90eXBlKGIpICAgICAoKGIgJiAweGVmKSkKKworI2RlZmluZSBfX3Rlc3RfZWEoYikgICAgICAoKGIgJiAweDAxKSkKKyNkZWZpbmUgX190ZXN0X2NyKGIpICAgICAgKChiICYgMHgwMikpCisjZGVmaW5lIF9fdGVzdF9wZihiKSAgICAgICgoYiAmIDB4MTApKQorCisjZGVmaW5lIF9fYWRkcihjciwgZGxjaSkgICAgICAgKCgoZGxjaSAmIDB4M2YpIDw8IDIpIHwgKGNyIDw8IDEpIHwgMHgwMSkKKyNkZWZpbmUgX19jdHJsKHR5cGUsIHBmKSAgICAgICAoKCh0eXBlICYgMHhlZikgfCAocGYgPDwgNCkpKQorI2RlZmluZSBfX2RsY2koZGlyLCBjaG4pICAgICAgICgoKGNobiAmIDB4MWYpIDw8IDEpIHwgZGlyKQorI2RlZmluZSBfX3Nydl9jaGFubmVsKGRsY2kpICAgIChkbGNpID4+IDEpCisjZGVmaW5lIF9fZGlyKGRsY2kpICAgICAgICAgICAgKGRsY2kgJiAweDAxKQorCisjZGVmaW5lIF9fbGVuOChsZW4pICAgICAgICgoKGxlbikgPDwgMSkgfCAxKQorI2RlZmluZSBfX2xlbjE2KGxlbikgICAgICAoKGxlbikgPDwgMSkKKworLyogTUNDIG1hY3JvcyAqLworI2RlZmluZSBfX21jY190eXBlKGNyLCB0eXBlKSAgICgoKHR5cGUgPDwgMikgfCAoY3IgPDwgMSkgfCAweDAxKSkKKyNkZWZpbmUgX19nZXRfbWNjX3R5cGUoYikgKChiICYgMHhmYykgPj4gMikKKyNkZWZpbmUgX19nZXRfbWNjX2xlbihiKSAgKChiICYgMHhmZSkgPj4gMSkKKworLyogUlBOIG1hY3JvcyAqLworI2RlZmluZSBfX3Jwbl9saW5lX3NldHRpbmdzKGRhdGEsIHN0b3AsIHBhcml0eSkgICgoZGF0YSAmIDB4MykgfCAoKHN0b3AgJiAweDEp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Y29tbV9zZXNzaW9uICpzLCB1OCBkbGNpKQoreworCXN0cnVjdCByZmNvbW1fY21kIGNtZDsKKworCUJUX0RCRygiJXAgZGxjaSAlZCIsIHMsIGRsY2kpOworCisJY21kLmFkZHIgPSBfX2FkZHIocy0+aW5pdGlhdG9yLCBkbGNpKTsKKwljbWQuY3RybCA9IF9fY3RybChSRkNPTU1fU0FCTSwgMSk7CisJY21kLmxlbiAgPSBfX2xlbjgoMCk7CisJY21kLmZjcyAgPSBfX2ZjczIoKHU4ICopICZjbWQpOworCisJcmV0dXJuIHJmY29tbV9zZW5kX2ZyYW1lKHMsICh2b2lkICopICZjbWQsIHNpemVvZihjbWQpKTsKK30KKworc3RhdGljIGludCByZmNvbW1fc2VuZF91YShzdHJ1Y3QgcmZjb21tX3Nlc3Npb24gKnMsIHU4IGRsY2kpCit7CisJc3RydWN0IHJmY29tbV9jbWQgY21kOworCisJQlRfREJHKCIlcCBkbGNpICVkIiwgcywgZGxjaSk7CisKKwljbWQuYWRkciA9IF9fYWRkcighcy0+aW5pdGlhdG9yLCBkbGNpKTsKKwljbWQuY3RybCA9IF9fY3RybChSRkNPTU1fVUEsIDEpOworCWNtZC5sZW4gID0gX19sZW44KDApOworCWNtZC5mY3MgID0gX19mY3MyKCh1OCAqKSAmY21kKTsKKworCXJldHVybiByZmNvbW1fc2VuZF9mcmFtZShzLCAodm9pZCAqKSAmY21kLCBzaXplb2YoY21kKSk7Cit9CisKK3N0YXRpYyBpbnQgcmZjb21tX3NlbmRfZGlzYyhzdHJ1Y3QgcmZjb21tX3Nlc3Npb24gKnMsIHU4IGRsY2kpCit7CisJc3RydWN0IHJmY29tbV9jbWQgY21kOworCisJQlRfREJHKCIlcCBkbGNpICVkIiwgcywgZGxjaSk7CisKKwljbWQuYWRkciA9IF9fYWRkcihzLT5pbml0aWF0b3IsIGRsY2kpOworCWNtZC5jdHJsID0gX19jdHJsKFJGQ09NTV9ESVNDLCAxKTsKKwljbWQubGVuICA9IF9fbGVuOCg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XRpYyBpbnQgIF9faW5pdCByZmNvbW1fcHJvY19pbml0KHZvaWQpCit7CisgICAgICAgIHN0cnVjdCBwcm9jX2Rpcl9lbnRyeSAqcDsKKworCXByb2NfYnRfcmZjb21tID0gcHJvY19ta2RpcigicmZjb21tIiwgcHJvY19idCk7CisJaWYgKHByb2NfYnRfcmZjb21tKSB7CisJCXByb2NfYnRfcmZjb21tLT5vd25lciA9IFRISVNfTU9EVUxFOworCisgICAgICAgIAlwID0gY3JlYXRlX3Byb2NfZW50cnkoImRsYyIsIFNfSVJVR08sIHByb2NfYnRfcmZjb21tKTsKKwkJaWYgKHApCisgICAgICAgIAkJcC0+cHJvY19mb3BzID0gJnJmY29tbV9zZXFfZm9wczsKKwl9CisgICAgICAgIHJldHVybiAwOworfQorCitzdGF0aWMgdm9pZCBfX2V4aXQgcmZjb21tX3Byb2NfY2xlYW51cCh2b2lkKQoreworICAgICAgICByZW1vdmVfcHJvY19lbnRyeSgiZGxjIiwgcHJvY19idF9yZmNvbW0pOworCisJcmVtb3ZlX3Byb2NfZW50cnkoInJmY29tbSIsIHByb2NfYnQpOworfQorCisjZWxzZSAvKiBDT05GSUdfUFJPQ19GUyAqLworCitzdGF0aWMgaW50ICBfX2luaXQgcmZjb21tX3Byb2NfaW5pdCh2b2lkKQoreworICAgICAgICByZXR1cm4gMDsKK30KKworc3RhdGljIHZvaWQgX19leGl0IHJmY29tbV9wcm9jX2NsZWFudXAodm9pZCkKK3sKKyAgICAgICAgcmV0dXJuOworfQorI2VuZGlmIC8qIENPTkZJR19QUk9DX0ZTICovCisKKy8qIC0tLS0gSW5pdGlhbGl6YXRpb24gLS0tLSAqLworc3RhdGljIGludCBfX2luaXQgcmZjb21tX2luaXQodm9pZCkKK3sKKwlsMmNhcF9sb2FkKCk7CisKKwloY2lfcmVnaXN0ZXJfY2IoJnJmY29tbV9jYik7CisKKwlrZXJuZWxfdGhyZWFkKHJmY29tbV9ydW4sIE5VTEwsIENMT05FX0tFUk5FTCk7CisK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2lkIHJmY29tbV9zb2NrX2Nsb3NlKHN0cnVjdCBzb2NrICpzaykKK3sKKwlsb2NrX3NvY2soc2spOworCV9fcmZjb21tX3NvY2tfY2xvc2Uoc2spOworCXJlbGVhc2Vfc29jayhzayk7Cit9CisKK3N0YXRpYyB2b2lkIHJmY29tbV9zb2NrX2luaXQoc3RydWN0IHNvY2sgKnNrLCBzdHJ1Y3Qgc29jayAqcGFyZW50KQoreworCXN0cnVjdCByZmNvbW1fcGluZm8gKnBpID0gcmZjb21tX3BpKHNrKTsKKworCUJUX0RCRygic2sgJXAiLCBzayk7CisKKwlpZiAocGFyZW50KSB7CisJCXNrLT5za190eXBlID0gcGFyZW50LT5za190eXBlOworCQlwaS0+bGlua19tb2RlID0gcmZjb21tX3BpKHBhcmVudCktPmxpbmtfbW9kZTsKKwl9IGVsc2UgeworCQlwaS0+bGlua19tb2RlID0gMDsKKwl9CisKKwlwaS0+ZGxjLT5saW5rX21vZGUgPSBwaS0+bGlua19tb2RlOworfQorCitzdGF0aWMgc3RydWN0IHByb3RvIHJmY29tbV9wcm90byA9IHsKKwkubmFtZQkJPSAiUkZDT01NIiwKKwkub3duZXIJCT0gVEhJU19NT0RVTEUsCisJLm9ial9zaXplCT0gc2l6ZW9mKHN0cnVjdCByZmNvbW1fcGluZm8pCit9OworCitzdGF0aWMgc3RydWN0IHNvY2sgKnJmY29tbV9zb2NrX2FsbG9jKHN0cnVjdCBzb2NrZXQgKnNvY2ssIGludCBwcm90bywgaW50IHByaW8pCit7CisJc3RydWN0IHJmY29tbV9kbGMgKmQ7CisJc3RydWN0IHNvY2sgKnNrOworCisJc2sgPSBza19hbGxvYyhQRl9CTFVFVE9PVEgsIHByaW8sICZyZmNvbW1fcHJvdG8sIDEpOworCWlmICghc2spCisJCXJldHVybiBOVUxMOworCisJc29ja19pbml0X2RhdGEoc29jaywgc2spOworCUlOSVRfTElTVF9IRUFEKCZidF9zayhzayktPmFjY2VwdF9xKTsKKworCWQgPSByZmNvbW1fZG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ZHIsIHNhLT5yY19jaGFubmVsKTsKKwlpZiAoIWVycikKKwkJZXJyID0gYnRfc29ja193YWl0X3N0YXRlKHNrLCBCVF9DT05ORUNURUQsCisJCQkJc29ja19zbmR0aW1lbyhzaywgZmxhZ3MgJiBPX05PTkJMT0NLKSk7CisKKwlyZWxlYXNlX3NvY2soc2spOworCXJldHVybiBlcnI7Cit9CisKK3N0YXRpYyBpbnQgcmZjb21tX3NvY2tfbGlzdGVuKHN0cnVjdCBzb2NrZXQgKnNvY2ssIGludCBiYWNrbG9nKQoreworCXN0cnVjdCBzb2NrICpzayA9IHNvY2stPnNrOworCWludCBlcnIgPSAwOworCisJQlRfREJHKCJzayAlcCBiYWNrbG9nICVkIiwgc2ssIGJhY2tsb2cpOworCisJbG9ja19zb2NrKHNrKTsKKworCWlmIChzay0+c2tfc3RhdGUgIT0gQlRfQk9VTkQpIHsKKwkJZXJyID0gLUVCQURGRDsKKwkJZ290byBkb25lOworCX0KKworCWlmICghcmZjb21tX3BpKHNrKS0+Y2hhbm5lbCkgeworCQliZGFkZHJfdCAqc3JjID0gJmJ0X3NrKHNrKS0+c3JjOworCQl1OCBjaGFubmVsOworCisJCWVyciA9IC1FSU5WQUw7CisKKwkJd3JpdGVfbG9ja19iaCgmcmZjb21tX3NrX2xpc3QubG9jayk7CisKKwkJZm9yIChjaGFubmVsID0gMTsgY2hhbm5lbCA8IDMxOyBjaGFubmVsKyspCisJCQlpZiAoIV9fcmZjb21tX2dldF9zb2NrX2J5X2FkZHIoY2hhbm5lbCwgc3JjKSkgeworCQkJCXJmY29tbV9waShzayktPmNoYW5uZWwgPSBjaGFubmVsOworCQkJCWVyciA9IDA7CisJCQkJYnJlYWs7CisJCQl9CisKKwkJd3JpdGVfdW5sb2NrX2JoKCZyZmNvbW1fc2tfbGlzdC5sb2NrKTsKKworCQlpZiAoZXJyIDwgMCkKKwkJCWdvdG8gZG9uZTsKKwl9CisKKwlzay0+c2tfbWF4X2Fja19iYWNrbG9nID0gYmFja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jZW5kaWYKKworCXJlbGVhc2Vfc29jayhzayk7CisJcmV0dXJuIGVycjsKK30KKworc3RhdGljIGludCByZmNvbW1fc29ja19zaHV0ZG93bihzdHJ1Y3Qgc29ja2V0ICpzb2NrLCBpbnQgaG93KQoreworCXN0cnVjdCBzb2NrICpzayA9IHNvY2stPnNrOworCWludCBlcnIgPSAwOworCisJQlRfREJHKCJzb2NrICVwLCBzayAlcCIsIHNvY2ssIHNrKTsKKworCWlmICghc2spIHJldHVybiAwOworCisJbG9ja19zb2NrKHNrKTsKKwlpZiAoIXNrLT5za19zaHV0ZG93bikgeworCQlzay0+c2tfc2h1dGRvd24gPSBTSFVURE9XTl9NQVNLOworCQlfX3JmY29tbV9zb2NrX2Nsb3NlKHNrKTsKKworCQlpZiAoc29ja19mbGFnKHNrLCBTT0NLX0xJTkdFUikgJiYgc2stPnNrX2xpbmdlcnRpbWUpCisJCQllcnIgPSBidF9zb2NrX3dhaXRfc3RhdGUoc2ssIEJUX0NMT1NFRCwgc2stPnNrX2xpbmdlcnRpbWUpOworCX0KKwlyZWxlYXNlX3NvY2soc2spOworCXJldHVybiBlcnI7Cit9CisKK3N0YXRpYyBpbnQgcmZjb21tX3NvY2tfcmVsZWFzZShzdHJ1Y3Qgc29ja2V0ICpzb2NrKQoreworCXN0cnVjdCBzb2NrICpzayA9IHNvY2stPnNrOworCWludCBlcnI7CisKKwlCVF9EQkcoInNvY2sgJXAsIHNrICVwIiwgc29jaywgc2spOworCisJaWYgKCFzaykKKwkJcmV0dXJuIDA7CisKKwllcnIgPSByZmNvbW1fc29ja19zaHV0ZG93bihzb2NrLCAyKTsKKworCXNvY2tfb3JwaGFuKHNrKTsKKwlyZmNvbW1fc29ja19raWxsKHNrKTsKKwlyZXR1cm4gZXJyOworfQorCisvKiAtLS0tIFJGQ09NTSBjb3JlIGxheWVyIGNhbGxiYWNrcyAtLS0tIAorICoKKyAqIGNhbGxlZCB1bmRlciByZmNvbW1fbG9jaygpCisgKi8KK2ludCByZm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3QJKnR0eTsKKwl3YWl0X3F1ZXVlX2hlYWRfdCAgICAgICB3YWl0OworCXN0cnVjdCB0YXNrbGV0X3N0cnVjdCAgIHdha2V1cF90YXNrOworCisJYXRvbWljX3QgCQl3bWVtX2FsbG9jOworfTsKKworc3RhdGljIExJU1RfSEVBRChyZmNvbW1fZGV2X2xpc3QpOworc3RhdGljIERFRklORV9SV0xPQ0socmZjb21tX2Rldl9sb2NrKTsKKworc3RhdGljIHZvaWQgcmZjb21tX2Rldl9kYXRhX3JlYWR5KHN0cnVjdCByZmNvbW1fZGxjICpkbGMsIHN0cnVjdCBza19idWZmICpza2IpOworc3RhdGljIHZvaWQgcmZjb21tX2Rldl9zdGF0ZV9jaGFuZ2Uoc3RydWN0IHJmY29tbV9kbGMgKmRsYywgaW50IGVycik7CitzdGF0aWMgdm9pZCByZmNvbW1fZGV2X21vZGVtX3N0YXR1cyhzdHJ1Y3QgcmZjb21tX2RsYyAqZGxjLCB1OCB2MjRfc2lnKTsKKworc3RhdGljIHZvaWQgcmZjb21tX3R0eV93YWtldXAodW5zaWduZWQgbG9uZyBhcmcpOworCisvKiAtLS0tIERldmljZSBmdW5jdGlvbnMgLS0tLSAqLworc3RhdGljIHZvaWQgcmZjb21tX2Rldl9kZXN0cnVjdChzdHJ1Y3QgcmZjb21tX2RldiAqZGV2KQoreworCXN0cnVjdCByZmNvbW1fZGxjICpkbGMgPSBkZXYtPmRsYzsKKworCUJUX0RCRygiZGV2ICVwIGRsYyAlcCIsIGRldiwgZGxjKTsKKworCXJmY29tbV9kbGNfbG9jayhkbGMpOworCS8qIERldGFjaCBETEMgaWYgaXQncyBvd25lZCBieSB0aGlzIGRldiAqLworCWlmIChkbGMtPm93bmVyID09IGRldikKKwkJZGxjLT5vd25lciA9IE5VTEw7CisJcmZjb21tX2RsY191bmxvY2soZGxjKTsKKworCXJmY29tbV9kbGNfcHV0KGRsYyk7CisKKwl0dHlfdW5yZWdpc3Rlcl9kZXZpY2UocmZjb21tX3R0eV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RpKTsKKworCWlmICghKGRsID0ga21hbGxvYyhzaXplLCBHRlBfS0VSTkVMKSkpCisJCXJldHVybiAtRU5PTUVNOworCisJZGkgPSBkbC0+ZGV2X2luZm87CisKKwlyZWFkX2xvY2tfYmgoJnJmY29tbV9kZXZfbG9jayk7CisKKwlsaXN0X2Zvcl9lYWNoKHAsICZyZmNvbW1fZGV2X2xpc3QpIHsKKwkJc3RydWN0IHJmY29tbV9kZXYgKmRldiA9IGxpc3RfZW50cnkocCwgc3RydWN0IHJmY29tbV9kZXYsIGxpc3QpOworCQkoZGkgKyBuKS0+aWQgICAgICA9IGRldi0+aWQ7CisJCShkaSArIG4pLT5mbGFncyAgID0gZGV2LT5mbGFnczsKKwkJKGRpICsgbiktPnN0YXRlICAgPSBkZXYtPmRsYy0+c3RhdGU7CisJCShkaSArIG4pLT5jaGFubmVsID0gZGV2LT5jaGFubmVsOworCQliYWNweSgmKGRpICsgbiktPnNyYywgJmRldi0+c3JjKTsKKwkJYmFjcHkoJihkaSArIG4pLT5kc3QsICZkZXYtPmRzdCk7CisJCWlmICgrK24gPj0gZGV2X251bSkKKwkJCWJyZWFrOworCX0KKworCXJlYWRfdW5sb2NrX2JoKCZyZmNvbW1fZGV2X2xvY2spOworCisJZGwtPmRldl9udW0gPSBuOworCXNpemUgPSBzaXplb2YoKmRsKSArIG4gKiBzaXplb2YoKmRpKTsKKworCWVyciA9IGNvcHlfdG9fdXNlcihhcmcsIGRsLCBzaXplKTsKKwlrZnJlZShkbCk7CisKKwlyZXR1cm4gZXJyID8gLUVGQVVMVCA6IDA7Cit9CisKK3N0YXRpYyBpbnQgcmZjb21tX2dldF9kZXZfaW5mbyh2b2lkIF9fdXNlciAqYXJnKQoreworCXN0cnVjdCByZmNvbW1fZGV2ICpkZXY7CisJc3RydWN0IHJmY29tbV9kZXZfaW5mbyBkaTsKKwlpbnQgZXJyID0gMDsKKworCUJUX0RCRygiIik7CisKKwlpZiAoY29weV9mcm9tX3VzZXIoJmRpLCBhc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5VTEw7CisJCWRldi0+dHR5ID0gTlVMTDsKKwkJcmZjb21tX2RsY191bmxvY2soZGV2LT5kbGMpOworCX0KKworCXJmY29tbV9kZXZfcHV0KGRldik7Cit9CisKK3N0YXRpYyBpbnQgcmZjb21tX3R0eV93cml0ZShzdHJ1Y3QgdHR5X3N0cnVjdCAqdHR5LCBjb25zdCB1bnNpZ25lZCBjaGFyICpidWYsIGludCBjb3VudCkKK3sKKwlzdHJ1Y3QgcmZjb21tX2RldiAqZGV2ID0gKHN0cnVjdCByZmNvbW1fZGV2ICopIHR0eS0+ZHJpdmVyX2RhdGE7CisJc3RydWN0IHJmY29tbV9kbGMgKmRsYyA9IGRldi0+ZGxjOworCXN0cnVjdCBza19idWZmICpza2I7CisJaW50IGVyciA9IDAsIHNlbnQgPSAwLCBzaXplOworCisJQlRfREJHKCJ0dHkgJXAgY291bnQgJWQiLCB0dHksIGNvdW50KTsKKworCXdoaWxlIChjb3VudCkgeworCQlzaXplID0gbWluX3QodWludCwgY291bnQsIGRsYy0+bXR1KTsKKworCQlza2IgPSByZmNvbW1fd21hbGxvYyhkZXYsIHNpemUgKyBSRkNPTU1fU0tCX1JFU0VSVkUsIEdGUF9BVE9NSUMpOworCQkKKwkJaWYgKCFza2IpCisJCQlicmVhazsKKworCQlza2JfcmVzZXJ2ZShza2IsIFJGQ09NTV9TS0JfSEVBRF9SRVNFUlZFKTsKKworCQltZW1jcHkoc2tiX3B1dChza2IsIHNpemUpLCBidWYgKyBzZW50LCBzaXplKTsKKworCQlpZiAoKGVyciA9IHJmY29tbV9kbGNfc2VuZChkbGMsIHNrYikpIDwgMCkgeworCQkJa2ZyZWVfc2tiKHNrYik7CisJCQlicmVhazsKKwkJfQorCisJCXNlbnQgICs9IHNpemU7CisJCWNvdW50IC09IHNpemU7CisJfQorCisJcmV0dXJuIHNlbnQgPyBzZW50IDogZXJyOworfQorCitzdGF0aWMgaW50IHJmY29tbV90dHlfd3JpdGVfcm9vbShzdHJ1Y3QgdHR5X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lzdHJ1Y3Qgc29jayAqc2sgPSAoc3RydWN0IHNvY2sgKikgYXJnOworCisJQlRfREJHKCJzb2NrICVwIHN0YXRlICVkIiwgc2ssIHNrLT5za19zdGF0ZSk7CisKKwliaF9sb2NrX3NvY2soc2spOworCXNrLT5za19lcnIgPSBFVElNRURPVVQ7CisJc2stPnNrX3N0YXRlX2NoYW5nZShzayk7CisJYmhfdW5sb2NrX3NvY2soc2spOworCisJc2NvX3NvY2tfa2lsbChzayk7CisJc29ja19wdXQoc2spOworfQorCitzdGF0aWMgdm9pZCBzY29fc29ja19zZXRfdGltZXIoc3RydWN0IHNvY2sgKnNrLCBsb25nIHRpbWVvdXQpCit7CisJQlRfREJHKCJzb2NrICVwIHN0YXRlICVkIHRpbWVvdXQgJWxkIiwgc2ssIHNrLT5za19zdGF0ZSwgdGltZW91dCk7CisJc2tfcmVzZXRfdGltZXIoc2ssICZzay0+c2tfdGltZXIsIGppZmZpZXMgKyB0aW1lb3V0KTsKK30KKworc3RhdGljIHZvaWQgc2NvX3NvY2tfY2xlYXJfdGltZXIoc3RydWN0IHNvY2sgKnNrKQoreworCUJUX0RCRygic29jayAlcCBzdGF0ZSAlZCIsIHNrLCBzay0+c2tfc3RhdGUpOworCXNrX3N0b3BfdGltZXIoc2ssICZzay0+c2tfdGltZXIpOworfQorCitzdGF0aWMgdm9pZCBzY29fc29ja19pbml0X3RpbWVyKHN0cnVjdCBzb2NrICpzaykKK3sKKwlpbml0X3RpbWVyKCZzay0+c2tfdGltZXIpOworCXNrLT5za190aW1lci5mdW5jdGlvbiA9IHNjb19zb2NrX3RpbWVvdXQ7CisJc2stPnNrX3RpbWVyLmRhdGEgPSAodW5zaWduZWQgbG9uZylzazsKK30KKworLyogLS0tLSBTQ08gY29ubmVjdGlvbnMgLS0tLSAqLworc3RhdGljIHN0cnVjdCBzY29fY29ubiAqc2NvX2Nvbm5fYWRkKHN0cnVjdCBoY2lfY29ubiAqaGNvbiwgX191OCBzdGF0dXMpCit7CisJc3RydWN0IGhjaV9kZXYgKmhkZXYgPSBoY29uLT5oZGV2OworCXN0cnVjdCBzY29fY29ubiAqY29ubjsKKworCWlmICgoY29ubiA9IGhjb24tPnNjb19kYXRhKSkKKwkJcmV0dXJuIGNvbm47CisKKwlpZiAoc3RhdHVzKQorCQlyZXR1cm4gY29ubjsKKworCWlmICghKGNvbm4gPSBrbWFsbG9jKHNpemVvZihzdHJ1Y3Qgc2NvX2Nvbm4pLCBHRlBfQVRPTUlDKSkpCisJCXJldHVybiBOVUxMOworCW1lbXNldChjb25uLCAwLCBzaXplb2Yoc3RydWN0IHNjb19jb25uKSk7CisKKwlzcGluX2xvY2tfaW5pdCgmY29ubi0+bG9jayk7CisKKwloY29uLT5zY29fZGF0YSA9IGNvbm47CisJY29ubi0+aGNvbiA9IGhjb247CisKKwljb25uLT5zcmMgPSAmaGRldi0+YmRhZGRyOworCWNvbm4tPmRzdCA9ICZoY29uLT5kc3Q7CisKKwlpZiAoaGRldi0+c2NvX210dSA+IDApCisJCWNvbm4tPm10dSA9IGhkZXYtPnNjb19tdHU7CisJZWxzZQorCQljb25uLT5tdHUgPSA2MDsKKworCUJUX0RCRygiaGNvbiAlcCBjb25uICVwIiwgaGNvbiwgY29ubik7CisJcmV0dXJuIGNvbm47Cit9CisKK3N0YXRpYyBpbmxpbmUgc3RydWN0IHNvY2sgKnNjb19jaGFuX2dldChzdHJ1Y3Qgc2NvX2Nvbm4gKmNvbm4pCit7CisJc3RydWN0IHNvY2sgKnNrID0gTlVMTDsKKwlzY29fY29ubl9sb2NrKGNvbm4pOworCXNrID0gY29ubi0+c2s7CisJc2NvX2Nvbm5fdW5sb2NrKGNvbm4pOworCXJldHVybiBzazsKK30KKworc3RhdGljIGludCBzY29fY29ubl9kZWwoc3RydWN0IGhjaV9jb25uICpoY29uLCBpbnQgZXJyKQoreworCXN0cnVjdCBzY29fY29ubiAqY29ubjsKKwlzdHJ1Y3Qgc29jayAqc2s7CisKKwlpZiAoIShjb25uID0gaGNvbi0+c2NvX2RhdGEpKSAKKwkJcmV0dXJuIDA7CisKKwlCVF9EQkcoImhjb24gJXAgY29ubiAlcCwgZXJyICVkIiwgaGNvbiwgY29ubiwgZXJyKTsKKworCS8qIEtpbGwgc29ja2V0ICovCisJaWYgKChzayA9IHNjb19jaGFuX2dldChjb25uKSkpIHsKKwkJYmhfbG9ja19zb2NrKHNrKTsKKwkJc2NvX3NvY2tfY2xlYXJfdGltZXIoc2spOworCQlzY29fY2hhbl9kZWwoc2ssIGVycik7CisJCWJoX3VubG9ja19zb2NrKHNrKTsKKwkJc2NvX3NvY2tfa2lsbChzayk7CisJfQorCisJaGNvbi0+c2NvX2RhdGEgPSBOVUxMOworCWtmcmVlKGNvbm4pOworCXJldHVybiAwOworfQorCitzdGF0aWMgaW5saW5lIGludCBzY29fY2hhbl9hZGQoc3RydWN0IHNjb19jb25uICpjb25uLCBzdHJ1Y3Qgc29jayAqc2ssIHN0cnVjdCBzb2NrICpwYXJlbnQpCit7CisJaW50IGVyciA9IDA7CisKKwlzY29fY29ubl9sb2NrKGNvbm4pOworCWlmIChjb25uLT5zaykgeworCQllcnIgPSAtRUJVU1k7CisJfSBlbHNlIHsKKwkJX19zY29fY2hhbl9hZGQoY29ubiwgc2ssIHBhcmVudCk7CisJfQorCXNjb19jb25uX3VubG9jayhjb25uKTsKKwlyZXR1cm4gZXJyOworfQorCitzdGF0aWMgaW50IHNjb19jb25uZWN0KHN0cnVjdCBzb2NrICpzaykKK3sKKwliZGFkZHJfdCAqc3JjID0gJmJ0X3NrKHNrKS0+c3JjOworCWJkYWRkcl90ICpkc3QgPSAmYnRfc2soc2spLT5kc3Q7CisJc3RydWN0IHNjb19jb25uICpjb25uOworCXN0cnVjdCBoY2lfY29ubiAqaGNvbjsKKwlzdHJ1Y3QgaGNpX2RldiAgKmhkZXY7CisJaW50IGVyciA9IDA7CisKKwlCVF9EQkcoIiVzIC0+ICVzIiwgYmF0b3N0cihzcmMpLCBiYXRvc3RyKGRzdCkpOwor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pOworCXNvY2tfcHV0KHNrKTsKK30KKworLyogQ2xvc2Ugc29ja2V0LgorICogTXVzdCBiZSBjYWxsZWQgb24gdW5sb2NrZWQgc29ja2V0LgorICovCitzdGF0aWMgdm9pZCBzY29fc29ja19jbG9zZShzdHJ1Y3Qgc29jayAqc2spCit7CisJc3RydWN0IHNjb19jb25uICpjb25uOworCisJc2NvX3NvY2tfY2xlYXJfdGltZXIoc2spOworCisJbG9ja19zb2NrKHNrKTsKKworCWNvbm4gPSBzY29fcGkoc2spLT5jb25uOworCisJQlRfREJHKCJzayAlcCBzdGF0ZSAlZCBjb25uICVwIHNvY2tldCAlcCIsIHNrLCBzay0+c2tfc3RhdGUsIGNvbm4sIHNrLT5za19zb2NrZXQpOworCisJc3dpdGNoIChzay0+c2tfc3RhdGUpIHsKKwljYXNlIEJUX0xJU1RFTjoKKwkJc2NvX3NvY2tfY2xlYW51cF9saXN0ZW4oc2spOworCQlicmVhazsKKworCWNhc2UgQlRfQ09OTkVDVEVEOgorCWNhc2UgQlRfQ09ORklHOgorCWNhc2UgQlRfQ09OTkVDVDoKKwljYXNlIEJUX0RJU0NPTk46CisJCXNjb19jaGFuX2RlbChzaywgRUNPTk5SRVNFVCk7CisJCWJyZWFrOworCisJZGVmYXVsdDoKKwkJc29ja19zZXRfZmxhZyhzaywgU09DS19aQVBQRUQpOworCQlicmVhazsKKwl9OworCisJcmVsZWFzZV9zb2NrKHNrKTsKKworCXNjb19zb2NrX2tpbGwoc2spOworfQorCitzdGF0aWMgdm9pZCBzY29fc29ja19pbml0KHN0cnVjdCBzb2NrICpzaywgc3RydWN0IHNvY2sgKnBhcmVudCkKK3sKKwlCVF9EQkcoInNrICVwIiwgc2spOworCisJaWYgKHBhcmVudCkgCisJCXNrLT5za190eXBlID0gcGFyZW50LT5za190eXBlOworfQorCitzdGF0aWMgc3RydWN0IHByb3RvIHNjb19wcm90byA9IHsKKwkubmFtZQkJPSAiU0NPIiwKKwkub3duZXIJCT0gVEhJU19NT0RV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K3sKKwlzdHJ1Y3Qgc29jayAqc2sgPSBzb2NrLT5zazsKKwlpbnQgZXJyID0gMDsKKworCUJUX0RCRygic2sgJXAgYmFja2xvZyAlZCIsIHNrLCBiYWNrbG9nKTsKKworCWxvY2tfc29jayhzayk7CisKKwlpZiAoc2stPnNrX3N0YXRlICE9IEJUX0JPVU5EIHx8IHNvY2stPnR5cGUgIT0gU09DS19TRVFQQUNLRVQpIHsKKwkJZXJyID0gLUVCQURGRDsKKwkJZ290byBkb25lOworCX0KKworCXNrLT5za19tYXhfYWNrX2JhY2tsb2cgPSBiYWNrbG9nOworCXNrLT5za19hY2tfYmFja2xvZyA9IDA7CisJc2stPnNrX3N0YXRlID0gQlRfTElTVEVOOworCitkb25lOgorCXJlbGVhc2Vfc29jayhzayk7CisJcmV0dXJuIGVycjsKK30KKworc3RhdGljIGludCBzY29fc29ja19hY2NlcHQoc3RydWN0IHNvY2tldCAqc29jaywgc3RydWN0IHNvY2tldCAqbmV3c29jaywgaW50IGZsYWdzKQoreworCURFQ0xBUkVfV0FJVFFVRVVFKHdhaXQsIGN1cnJlbnQpOworCXN0cnVjdCBzb2NrICpzayA9IHNvY2stPnNrLCAqY2g7CisJbG9uZyB0aW1lbzsKKwlpbnQgZXJyID0gMDsKKworCWxvY2tfc29jayhzayk7CisKKwlpZiAoc2stPnNrX3N0YXRlICE9IEJUX0xJU1RFTikgeworCQllcnIgPSAtRUJBREZEOworCQlnb3RvIGRvbmU7CisJfQorCisJdGltZW8gPSBzb2NrX3JjdnRpbWVvKHNrLCBmbGFncyAmIE9fTk9OQkxPQ0spOworCisJQlRfREJHKCJzayAlcCB0aW1lbyAlbGQiLCBzaywgdGltZW8pOworCisJLyogV2FpdCBmb3IgYW4gaW5jb21pbmcgY29ubmVjdGlvbi4gKHdha2Utb25lKS4gKi8KKwlhZGRfd2FpdF9xdWV1ZV9leGNsdXNpdmUoc2stPnNrX3NsZWVwLCAmd2FpdCk7CisJd2hpbGUgKCEoY2ggPSBidF9h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PSAtRU5PVENPTk47CisJCQlicmVhazsKKwkJfQorCisJCWNpbmZvLmhjaV9oYW5kbGUgPSBzY29fcGkoc2spLT5jb25uLT5oY29uLT5oYW5kbGU7CisJCW1lbWNweShjaW5mby5kZXZfY2xhc3MsIHNjb19waShzayktPmNvbm4tPmhjb24tPmRldl9jbGFzcywgMyk7CisKKwkJbGVuID0gbWluX3QodW5zaWduZWQgaW50LCBsZW4sIHNpemVvZihjaW5mbykpOworCQlpZiAoY29weV90b191c2VyKG9wdHZhbCwgKGNoYXIgKikmY2luZm8sIGxlbikpCisJCQllcnIgPSAtRUZBVUxUOworCisJCWJyZWFrOworCisJZGVmYXVsdDoKKwkJZXJyID0gLUVOT1BST1RPT1BUOworCQlicmVhazsKKwl9CisKKwlyZWxlYXNlX3NvY2soc2spOworCXJldHVybiBlcnI7Cit9CisKK3N0YXRpYyBpbnQgc2NvX3NvY2tfcmVsZWFzZShzdHJ1Y3Qgc29ja2V0ICpzb2NrKQoreworCXN0cnVjdCBzb2NrICpzayA9IHNvY2stPnNrOworCWludCBlcnIgPSAwOworCisJQlRfREJHKCJzb2NrICVwLCBzayAlcCIsIHNvY2ssIHNrKTsKKworCWlmICghc2spCisJCXJldHVybiAwOworCisJc2NvX3NvY2tfY2xvc2Uoc2spOworCisJaWYgKHNvY2tfZmxhZyhzaywgU09DS19MSU5HRVIpICYmIHNrLT5za19saW5nZXJ0aW1lKSB7CisJCWxvY2tfc29jayhzayk7CisJCWVyciA9IGJ0X3NvY2tfd2FpdF9zdGF0ZShzaywgQlRfQ0xPU0VELCBzay0+c2tfbGluZ2VydGltZSk7CisJCXJlbGVhc2Vfc29jayhzayk7CisJfQorCisJc29ja19vcnBoYW4oc2spOworCXNjb19zb2NrX2tpbGwoc2spOworCXJldHVybiBlcnI7Cit9CisKK3N0YXRpYyB2b2lkIF9fc2NvX2NoYW5fYWRkKHN0cnVjdCBzY29fY29ubiAqY29ubiwgc3RydWN0IHNvY2sgKnNrLCBzdHJ1Y3Qgc29jayAqcGFyZW50KQoreworCUJUX0RCRygiY29ubiAlcCIsIGNvbm4pOworCisJc2NvX3BpKHNrKS0+Y29ubiA9IGNvbm47CisJY29ubi0+c2sgPSBzazsKKworCWlmIChwYXJlbnQpCisJCWJ0X2FjY2VwdF9lbnF1ZXVlKHBhcmVudCwgc2spOworfQorCisvKiBEZWxldGUgY2hhbm5lbC4gCisgKiBNdXN0IGJlIGNhbGxlZCBvbiB0aGUgbG9ja2VkIHNvY2tldC4gKi8KK3N0YXRpYyB2b2lkIHNjb19jaGFuX2RlbChzdHJ1Y3Qgc29jayAqc2ssIGludCBlcnIpCit7CisJc3RydWN0IHNjb19jb25uICpjb25uOworCisJY29ubiA9IHNjb19waShzayktPmNvbm47CisKKwlCVF9EQkcoInNrICVwLCBjb25uICVwLCBlcnIgJWQiLCBzaywgY29ubiwgZXJyKTsKKworCWlmIChjb25uKSB7IAorCQlzY29fY29ubl9sb2NrKGNvbm4pOworCQljb25uLT5zayA9IE5VTEw7CisJCXNjb19waShzayktPmNvbm4gPSBOVUxMOworCQlzY29fY29ubl91bmxvY2soY29ubik7CisJCWhjaV9jb25uX3B1dChjb25uLT5oY29uKTsKKwl9CisKKwlzay0+c2tfc3RhdGUgPSBCVF9DTE9TRUQ7CisJc2stPnNrX2VyciAgID0gZXJyOworCXNrLT5za19zdGF0ZV9jaGFuZ2Uoc2spOworCisJc29ja19zZXRfZmxhZyhzaywgU09DS19aQVBQRUQpOworfQorCitzdGF0aWMgdm9pZCBzY29fY29ubl9yZWFkeShzdHJ1Y3Qgc2NvX2Nvbm4gKmNvbm4pCit7CisJc3RydWN0IHNvY2sgKnBhcmVudCwgKnNrOworCisJQlRfREJHKCJjb25uICVwIiwgY29ubik7CisKKwlzY29fY29ubl9sb2NrKGNvbm4pOworCisJaWYgKChzayA9IGNvbm4tPnNrKSkgeworCQlzY29fc29ja19jbGVhcl90aW1lcihzayk7CisJCWJoX2xvY2tfc29jayhzayk7CisJCXNrLT5za19zdGF0ZSA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RyKGJkYWRkcikpOworCisJLyogQWx3YXlzIGFjY2VwdCBjb25uZWN0aW9uICovCisJcmV0dXJuIEhDSV9MTV9BQ0NFUFQ7Cit9CisKK3N0YXRpYyBpbnQgc2NvX2Nvbm5lY3RfY2ZtKHN0cnVjdCBoY2lfY29ubiAqaGNvbiwgX191OCBzdGF0dXMpCit7CisJQlRfREJHKCJoY29uICVwIGJkYWRkciAlcyBzdGF0dXMgJWQiLCBoY29uLCBiYXRvc3RyKCZoY29uLT5kc3QpLCBzdGF0dXMpOworCisJaWYgKGhjb24tPnR5cGUgIT0gU0NPX0xJTkspCisJCXJldHVybiAwOworCisJaWYgKCFzdGF0dXMpIHsKKwkJc3RydWN0IHNjb19jb25uICpjb25uOworCisJCWNvbm4gPSBzY29fY29ubl9hZGQoaGNvbiwgc3RhdHVzKTsKKwkJaWYgKGNvbm4pCisJCQlzY29fY29ubl9yZWFkeShjb25uKTsKKwl9IGVsc2UgCisJCXNjb19jb25uX2RlbChoY29uLCBidF9lcnIoc3RhdHVzKSk7CisKKwlyZXR1cm4gMDsKK30KKworc3RhdGljIGludCBzY29fZGlzY29ubl9pbmQoc3RydWN0IGhjaV9jb25uICpoY29uLCBfX3U4IHJlYXNvbikKK3sKKwlCVF9EQkcoImhjb24gJXAgcmVhc29uICVkIiwgaGNvbiwgcmVhc29uKTsKKworCWlmIChoY29uLT50eXBlICE9IFNDT19MSU5LKQorCQlyZXR1cm4gMDsKKworCXNjb19jb25uX2RlbChoY29uLCBidF9lcnIocmVhc29uKSk7CisJcmV0dXJuIDA7Cit9CisKK3N0YXRpYyBpbnQgc2NvX3JlY3Zfc2NvZGF0YShzdHJ1Y3QgaGNpX2Nvbm4gKmhjb24sIHN0cnVjdCBza19idWZmICpza2IpCit7CisJc3RydWN0IHNjb19jb25uICpjb25uID0gaGNvbi0+c2NvX2RhdGE7CisKKwlpZiAoIWNvbm4pCisJCWdvdG8gZHJvcDsKKworCUJUX0RCRygiY29ubiAlcCBsZW4gJWQiLCBjb25uLCBza2ItPmxlbik7CisKKwlpZiAoc2tiLT5sZW4pIHsKKwkJc2NvX3JlY3ZfZnJhbWUoY29ubiwgc2tiKTsKKwkJcmV0dXJuIDA7CisJfQorCitkcm9wOgorCWtmcmVlX3NrYihza2IpOwkKKwlyZXR1cm4gMDsKK30KKworLyogLS0tLSBQcm9jIGZzIHN1cHBvcnQgLS0tLSAqLworI2lmZGVmIENPTkZJR19QUk9DX0ZTCitzdGF0aWMgdm9pZCAqc2NvX3NlcV9zdGFydChzdHJ1Y3Qgc2VxX2ZpbGUgKnNlcSwgbG9mZl90ICpwb3MpCit7CisJc3RydWN0IHNvY2sgKnNrOworCXN0cnVjdCBobGlzdF9ub2RlICpub2RlOworCWxvZmZfdCBsID0gKnBvczsKKworCXJlYWRfbG9ja19iaCgmc2NvX3NrX2xpc3QubG9jayk7CisKKwlza19mb3JfZWFjaChzaywgbm9kZSwgJnNjb19za19saXN0LmhlYWQpCisJCWlmICghbC0tKQorCQkJZ290byBmb3VuZDsKKwlzayA9IE5VTEw7Citmb3VuZDoKKwlyZXR1cm4gc2s7Cit9CisKK3N0YXRpYyB2b2lkICpzY29fc2VxX25leHQoc3RydWN0IHNlcV9maWxlICpzZXEsIHZvaWQgKmUsIGxvZmZfdCAqcG9zKQoreworCXN0cnVjdCBzb2NrICpzayA9IGU7CisJKCpwb3MpKys7CisJcmV0dXJuIHNrX25leHQoc2spOworfQorCitzdGF0aWMgdm9pZCBzY29fc2VxX3N0b3Aoc3RydWN0IHNlcV9maWxlICpzZXEsIHZvaWQgKmUpCit7CisJcmVhZF91bmxvY2tfYmgoJnNjb19za19saXN0LmxvY2spOworfQorCitzdGF0aWMgaW50ICBzY29fc2VxX3Nob3coc3RydWN0IHNlcV9maWxlICpzZXEsIHZvaWQgKmUpCit7CisJc3RydWN0IHNvY2sgKnNrID0gZTsKKwlzZXFfcHJpbnRmKHNlcSwgIiVzICVzICVkXG4iLAorCQkJYmF0b3N0cigmYnRfc2soc2spLT5zcmM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WVfcHVzaF94bWl0KTsKKworCXJldHVybiBORl9TVE9MRU47CisKKyNpZmRlZiBDT05GSUdfTkVURklMVEVSX0RFQlVHCitwcmludF9lcnJvcjoKKwlpZiAoc2tiLT5kZXYgIT0gTlVMTCkgeworCQlwcmludGsoIlslc10iLCBza2ItPmRldi0+bmFtZSk7CisJCWlmIChoYXNfYnJpZGdlX3BhcmVudChza2ItPmRldikpCisJCQlwcmludGsoIlslc10iLCBicmlkZ2VfcGFyZW50KHNrYi0+ZGV2KS0+bmFtZSk7CisJfQorCXByaW50aygiIGhlYWQ6JXAsIHJhdzolcCwgZGF0YTolcFxuIiwgc2tiLT5oZWFkLCBza2ItPm1hYy5yYXcsCisJCQkJCSAgICAgIHNrYi0+ZGF0YSk7CisJcmV0dXJuIE5GX0FDQ0VQVDsKKyNlbmRpZgorfQorCisKKy8qIElQL1NBQk9UQUdFICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworLyogRG9uJ3QgaGFuZCBsb2NhbGx5IGRlc3RpbmVkIHBhY2tldHMgdG8gUEZfSU5FVCg2KS9QUkVfUk9VVElORworICogZm9yIHRoZSBzZWNvbmQgdGltZS4gKi8KK3N0YXRpYyB1bnNpZ25lZCBpbnQgaXBfc2Fib3RhZ2VfaW4odW5zaWduZWQgaW50IGhvb2ssIHN0cnVjdCBza19idWZmICoqcHNrYiwKKyAgIGNvbnN0IHN0cnVjdCBuZXRfZGV2aWNlICppbiwgY29uc3Qgc3RydWN0IG5ldF9kZXZpY2UgKm91dCwKKyAgIGludCAoKm9rZm4pKHN0cnVjdCBza19idWZmICopKQoreworCWlmICgoKnBza2IpLT5uZl9icmlkZ2UgJiYKKwkgICAgISgoKnBza2IpLT5uZl9icmlkZ2UtPm1hc2sgJiBCUk5GX05GX0JSSURHRV9QUkVST1VUSU5HKSkgeworCQlyZXR1cm4gTkZfU1RPUDsKKwl9CisKKwlyZXR1cm4gTkZfQUNDRVBUOworfQorCisvKi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kZXYvbnVsbAorKysgYi9uZXQvYnJpZGdlL25ldGZpbHRlci9NYWtlZmlsZQpAQCAtMCwwICsxLDMyIEBACisjCisjIE1ha2VmaWxlIGZvciB0aGUgbmV0ZmlsdGVyIG1vZHVsZXMgZm9yIExpbmsgTGF5ZXIgZmlsdGVyaW5nIG9uIGEgYnJpZGdlLgorIworCitvYmotJChDT05GSUdfQlJJREdFX05GX0VCVEFCTEVTKSArPSBlYnRhYmxlcy5vCisKKyMgdGFibGVzCitvYmotJChDT05GSUdfQlJJREdFX0VCVF9CUk9VVEUpICs9IGVidGFibGVfYnJvdXRlLm8KK29iai0kKENPTkZJR19CUklER0VfRUJUX1RfRklMVEVSKSArPSBlYnRhYmxlX2ZpbHRlci5vCitvYmotJChDT05GSUdfQlJJREdFX0VCVF9UX05BVCkgKz0gZWJ0YWJsZV9uYXQubworCisjbWF0Y2hlcworb2JqLSQoQ09ORklHX0JSSURHRV9FQlRfODAyXzMpICs9IGVidF84MDJfMy5vCitvYmotJChDT05GSUdfQlJJREdFX0VCVF9BTU9ORykgKz0gZWJ0X2Ftb25nLm8KK29iai0kKENPTkZJR19CUklER0VfRUJUX0FSUCkgKz0gZWJ0X2FycC5vCitvYmotJChDT05GSUdfQlJJREdFX0VCVF9JUCkgKz0gZWJ0X2lwLm8KK29iai0kKENPTkZJR19CUklER0VfRUJUX0xJTUlUKSArPSBlYnRfbGltaXQubworb2JqLSQoQ09ORklHX0JSSURHRV9FQlRfTUFSSykgKz0gZWJ0X21hcmtfbS5vCitvYmotJChDT05GSUdfQlJJREdFX0VCVF9QS1RUWVBFKSArPSBlYnRfcGt0dHlwZS5vCitvYmotJChDT05GSUdfQlJJREdFX0VCVF9TVFApICs9IGVidF9zdHAubworb2JqLSQoQ09ORklHX0JSSURHRV9FQlRfVkxBTikgKz0gZWJ0X3ZsYW4ubworCisjIHRhcmdldHMKK29iai0kKENPTkZJR19CUklER0VfRUJUX0FSUFJFUExZKSArPSBlYnRfYXJwcmVwbHkubworb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vbnN0IHN0cnVjdCBlYnRfdGFibGVfaW5mbyAqaW5mbywgdW5zaWduZWQgaW50IHZhbGlkX2hvb2tzKQoreworCWlmICh2YWxpZF9ob29rcyAmIH5GSUxURVJfVkFMSURfSE9PS1MpCisJCXJldHVybiAtRUlOVkFMOworCXJldHVybiAwOworfQorCitzdGF0aWMgc3RydWN0IGVidF90YWJsZSBmcmFtZV9maWx0ZXIgPQoreyAKKwkubmFtZQkJPSAiZmlsdGVyIiwKKwkudGFibGUJCT0gJmluaXRpYWxfdGFibGUsCisJLnZhbGlkX2hvb2tzCT0gRklMVEVSX1ZBTElEX0hPT0tTLCAKKwkubG9jawkJPSBSV19MT0NLX1VOTE9DS0VELAorCS5jaGVjawkJPSBjaGVjaywKKwkubWUJCT0gVEhJU19NT0RVTEUsCit9OworCitzdGF0aWMgdW5zaWduZWQgaW50CitlYnRfaG9vayAodW5zaWduZWQgaW50IGhvb2ssIHN0cnVjdCBza19idWZmICoqcHNrYiwgY29uc3Qgc3RydWN0IG5ldF9kZXZpY2UgKmluLAorICAgY29uc3Qgc3RydWN0IG5ldF9kZXZpY2UgKm91dCwgaW50ICgqb2tmbikoc3RydWN0IHNrX2J1ZmYgKikpCit7CisJcmV0dXJuIGVidF9kb190YWJsZShob29rLCBwc2tiLCBpbiwgb3V0LCAmZnJhbWVfZmlsdGVyKTsKK30KKworc3RhdGljIHN0cnVjdCBuZl9ob29rX29wcyBlYnRfb3BzX2ZpbHRlcltdID0geworCXsKKwkJLmhvb2sJCT0gZWJ0X2hvb2ssCisJCS5vd25lcgkJPSBUSElTX01PRFVMRSwKKwkJLnBmCQk9IFBGX0JSSURHRSwKKwkJLmhvb2tudW0JPSBORl9CUl9MT0NBTF9JTiwKKwkJLnByaW9yaXR5CT0gTkZfQlJfUFJJX0ZJTFRFUl9CUklER0VELAorCX0sCisJeworCQkuaG9vawkJPSBlYnRfaG9vaywKKwkJLm93bmVyCQk9IFRISVNfTU9EVUxFLAorCQkucGYJCT0gUEZfQl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aW5mby0+ZW50cmllcywgbmV3aW5mby0+ZW50cmllc19zaXplLAorCQkgICBlYnRfY2xlYW51cF9lbnRyeSwgJmkpOworCX0KKwlpZiAoY2xfcykKKwkJdmZyZWUoY2xfcyk7CisJcmV0dXJuIHJldDsKK30KKworLyogY2FsbGVkIHVuZGVyIHdyaXRlX2xvY2sgKi8KK3N0YXRpYyB2b2lkIGdldF9jb3VudGVycyhzdHJ1Y3QgZWJ0X2NvdW50ZXIgKm9sZGNvdW50ZXJzLAorICAgc3RydWN0IGVidF9jb3VudGVyICpjb3VudGVycywgdW5zaWduZWQgaW50IG5lbnRyaWVzKQoreworCWludCBpLCBjcHU7CisJc3RydWN0IGVidF9jb3VudGVyICpjb3VudGVyX2Jhc2U7CisKKwkvKiBjb3VudGVycyBvZiBjcHUgMCAqLworCW1lbWNweShjb3VudGVycywgb2xkY291bnRlcnMsCisJICAgc2l6ZW9mKHN0cnVjdCBlYnRfY291bnRlcikgKiBuZW50cmllcyk7CisJLyogYWRkIG90aGVyIGNvdW50ZXJzIHRvIHRob3NlIG9mIGNwdSAwICovCisJZm9yIChjcHUgPSAxOyBjcHUgPCBudW1fcG9zc2libGVfY3B1cygpOyBjcHUrKykgeworCQljb3VudGVyX2Jhc2UgPSBDT1VOVEVSX0JBU0Uob2xkY291bnRlcnMsIG5lbnRyaWVzLCBjcHUpOworCQlmb3IgKGkgPSAwOyBpIDwgbmVudHJpZXM7IGkrKykgeworCQkJY291bnRlcnNbaV0ucGNudCArPSBjb3VudGVyX2Jhc2VbaV0ucGNudDsKKwkJCWNvdW50ZXJzW2ldLmJjbnQgKz0gY291bnRlcl9iYXNlW2ldLmJjbnQ7CisJCX0KKwl9Cit9CisKKy8qIHJlcGxhY2UgdGhlIHRhYmxlICovCitzdGF0aWMgaW50IGRvX3JlcGxhY2Uodm9pZCBfX3VzZXIgKnVzZXIsIHVuc2lnbmVkIGludCBsZW4pCit7CisJaW50IHJldCwgaSwgY291bnRlcnNpemU7CisJc3RydWN0I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GVycm9ycz8gKi8KKwllcnJvciA9IHNvY2tfZXJyb3Ioc2spOworCWlmIChlcnJvcikKKwkJZ290byBvdXRfZXJyOworCisJaWYgKCFza2JfcXVldWVfZW1wdHkoJnNrLT5za19yZWNlaXZlX3F1ZXVlKSkKKwkJZ290byBvdXQ7CisKKwkvKiBTb2NrZXQgc2h1dCBkb3duPyAqLworCWlmIChzay0+c2tfc2h1dGRvd24gJiBSQ1ZfU0hVVERPV04pCisJCWdvdG8gb3V0X25vZXJyOworCisJLyogU2VxdWVuY2VkIHBhY2tldHMgY2FuIGNvbWUgZGlzY29ubmVjdGVkLgorCSAqIElmIHNvIHdlIHJlcG9ydCB0aGUgcHJvYmxlbQorCSAqLworCWVycm9yID0gLUVOT1RDT05OOworCWlmIChjb25uZWN0aW9uX2Jhc2VkKHNrKSAmJgorCSAgICAhKHNrLT5za19zdGF0ZSA9PSBUQ1BfRVNUQUJMSVNIRUQgfHwgc2stPnNrX3N0YXRlID09IFRDUF9MSVNURU4pKQorCQlnb3RvIG91dF9lcnI7CisKKwkvKiBoYW5kbGUgc2lnbmFscyAqLworCWlmIChzaWduYWxfcGVuZGluZyhjdXJyZW50KSkKKwkJZ290byBpbnRlcnJ1cHRlZDsKKworCWVycm9yID0gMDsKKwkqdGltZW9fcCA9IHNjaGVkdWxlX3RpbWVvdXQoKnRpbWVvX3ApOworb3V0OgorCWZpbmlzaF93YWl0KHNrLT5za19zbGVlcCwgJndhaXQpOworCXJldHVybiBlcnJvcjsKK2ludGVycnVwdGVkOgorCWVycm9yID0gc29ja19pbnRyX2Vycm5vKCp0aW1lb19wKTsKK291dF9lcnI6CisJKmVyciA9IGVycm9yOworCWdvdG8gb3V0Oworb3V0X25vZXJyOgorCSplcnIgPSAwOworCWVycm9yID0gMTsKKwlnb3RvIG91dDsKK30KKworLyoqCisgKglza2JfcmVjdl9kYXRhZ3JhbSAtIFJlY2VpdmUgYSBkYXRhZ3JhbSBza2J1ZmYKKyAqCUBzayAtIHNvY2tldA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Sb3V0aW5lcworCisqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworCisvKiBCb290IHRpbWUgY29uZmlndXJhdGlvbiB0YWJsZSAqLworc3RhdGljIHN0cnVjdCBuZXRkZXZfYm9vdF9zZXR1cCBkZXZfYm9vdF9zZXR1cFtORVRERVZfQk9PVF9TRVRVUF9NQVhdOworCisvKioKKyAqCW5ldGRldl9ib290X3NldHVwX2FkZAktIGFkZCBuZXcgc2V0dXAgZW50cnkKKyAqCUBuYW1lOiBuYW1lIG9mIHRoZSBkZXZpY2UKKyAqCUBtYXA6IGNvbmZpZ3VyZWQgc2V0dGluZ3MgZm9yIHRoZSBkZXZpY2UKKyAqCisgKglBZGRzIG5ldyBzZXR1cCBlbnRyeSB0byB0aGUgZGV2X2Jvb3Rfc2V0dXAgbGlzdC4gIFRoZSBmdW5jdGlvbgorICoJcmV0dXJucyAwIG9uIGVycm9yIGFuZCAxIG9uIHN1Y2Nlc3MuICBUaGlzIGlzIGEgZ2VuZXJpYyByb3V0aW5lIHRvCisgKglhbGwgbmV0ZGV2aWNlcy4KKyAqLworc3RhdGljIGludCBuZXRkZXZfYm9vdF9zZXR1cF9hZGQoY2hhciAqbmFtZSwgc3RydWN0IGlmbWFwICptYXApCit7CisJc3RydWN0IG5ldGRldl9ib290X3NldHVwICpzOworCWludCBpOworCisJcyA9IGRldl9ib290X3NldHVwOworCWZvciAoaSA9IDA7IGkgPCBORVRERVZfQk9PVF9TRVRVUF9NQVg7IGkrKykgeworCQlpZiAoc1tpXS5uYW1lWzBdID09ICdcMCcgfHwgc1tpXS5uYW1lWzBdID09ICcgJykgeworCQkJbWVtc2V0KHNbaV0ubmFtZSwgMCwgc2l6ZW9mKHNbaV0ubmFtZSkpOworCQkJc3RyY3B5KHNbaV0ubmFtZSwgbmFtZSk7CisJCQltZW1jcHkoJnNbaV0ubWFwLCBtYXAsIHNpemVvZihzW2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hdCBib290IHRpbWUgY29uZmlndXJlZCBzZXR0aW5ncyBmb3IgYW55IG5ldGRldmljZS4KKyAqLworaW50IF9faW5pdCBuZXRkZXZfYm9vdF9zZXR1cChjaGFyICpzdHIpCit7CisJaW50IGludHNbNV07CisJc3RydWN0IGlmbWFwIG1hcDsKKworCXN0ciA9IGdldF9vcHRpb25zKHN0ciwgQVJSQVlfU0laRShpbnRzKSwgaW50cyk7CisJaWYgKCFzdHIgfHwgISpzdHIpCisJCXJldHVybiAwOworCisJLyogU2F2ZSBzZXR0aW5ncyAqLworCW1lbXNldCgmbWFwLCAwLCBzaXplb2YobWFwKSk7CisJaWYgKGludHNbMF0gPiAwKQorCQltYXAuaXJxID0gaW50c1sxXTsKKwlpZiAoaW50c1swXSA+IDEpCisJCW1hcC5iYXNlX2FkZHIgPSBpbnRzWzJdOworCWlmIChpbnRzWzBdID4gMikKKwkJbWFwLm1lbV9zdGFydCA9IGludHNbM107CisJaWYgKGludHNbMF0gPiAzKQorCQltYXAubWVtX2VuZCA9IGludHNbNF07CisKKwkvKiBBZGQgbmV3IGVudHJ5IHRvIHRoZSBsaXN0ICovCisJcmV0dXJuIG5ldGRldl9ib290X3NldHVwX2FkZChzdHIsICZtYXApOworfQorCitfX3NldHVwKCJuZXRkZXY9IiwgbmV0ZGV2X2Jvb3Rfc2V0dXApOworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorCisJCQkgICAgRGV2aWNlIEludGVyZmFjZSBTdWJyb3V0aW5lcworCisqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworCisvKioKKyAqCV9fZGV2X2dldF9ieV9uYW1lCS0gZmluZCBhIGRldmljZSBieSBpdHMgbmFtZQorICoJQG5hbWU6IG5hbWUgdG8gZmluZAorICoKKyAqCUZpbmQgYW4gaW50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ICAgICAgInF1ZXVlIHBhY2tldCFcbiIsIGRldi0+bmFtZSk7CisJCX0gZWxzZSB7CisJCQkvKiBSZWN1cnNpb24gaXMgZGV0ZWN0ZWQhIEl0IGlzIHBvc3NpYmxlLAorCQkJICogdW5mb3J0dW5hdGVseSAqLworCQkJaWYgKG5ldF9yYXRlbGltaXQoKSkKKwkJCQlwcmludGsoS0VSTl9DUklUICJEZWFkIGxvb3Agb24gdmlydHVhbCBkZXZpY2UgIgorCQkJCSAgICAgICAiJXMsIGZpeCBpdCB1cmdlbnRseSFcbiIsIGRldi0+bmFtZSk7CisJCX0KKwl9CisKKwlyYyA9IC1FTkVURE9XTjsKKwlsb2NhbF9iaF9lbmFibGUoKTsKKworb3V0X2tmcmVlX3NrYjoKKwlrZnJlZV9za2Ioc2tiKTsKKwlyZXR1cm4gcmM7CitvdXQ6CisJbG9jYWxfYmhfZW5hYmxlKCk7CisJcmV0dXJuIHJjOworfQorCisKKy8qPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKwkJCVJlY2VpdmVyIHJvdXRpbmVzCisgID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ki8KKworaW50IG5ldGRldl9tYXhfYmFja2xvZyA9IDMwMDsKK2ludCB3ZWlnaHRfcCA9IDY0OyAgICAgICAgICAgIC8qIG9sZCBiYWNrbG9nIHdlaWdodCAqLworLyogVGhlc2UgbnVtYmVycyBhcmUgc2VsZWN0ZWQgYmFzZWQgb24gaW50dWl0aW9uIGFuZCBzb21lCisgKiBleHBlcmltZW50YXRpb20sIGlmIHlvdSBoYXZlIG1vcmUgc2NpZW50aWZpYyB3YXkgb2YgZG9pbmcgdGhpcworICogcGxlYXNlIGdvIGFoZWFkIGFuZCBmaXggdGhpbmdzLgorICovCitpbnQgbm9fY29uZ190aHJlc2ggPSAxMDsKK2ludCBub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prZXkyKQoreworCWZsb3dfY29tcGFyZV90ICprMSwgKmsxX2xpbSwgKmsyOworCWNvbnN0IGludCBuX2VsZW0gPSBzaXplb2Yoc3RydWN0IGZsb3dpKSAvIHNpemVvZihmbG93X2NvbXBhcmVfdCk7CisKKwlpZiAoc2l6ZW9mKHN0cnVjdCBmbG93aSkgJSBzaXplb2YoZmxvd19jb21wYXJlX3QpKQorCQlmbG93aV9pc19taXNzaXplZCgpOworCisJazEgPSAoZmxvd19jb21wYXJlX3QgKikga2V5MTsKKwlrMV9saW0gPSBrMSArIG5fZWxlbTsKKworCWsyID0gKGZsb3dfY29tcGFyZV90ICopIGtleTI7CisKKwlkbyB7CisJCWlmICgqazErKyAhPSAqazIrKykKKwkJCXJldHVybiAxOworCX0gd2hpbGUgKGsxIDwgazFfbGltKTsKKworCXJldHVybiAwOworfQorCit2b2lkICpmbG93X2NhY2hlX2xvb2t1cChzdHJ1Y3QgZmxvd2kgKmtleSwgdTE2IGZhbWlseSwgdTggZGlyLAorCQkJZmxvd19yZXNvbHZlX3QgcmVzb2x2ZXIpCit7CisJc3RydWN0IGZsb3dfY2FjaGVfZW50cnkgKmZsZSwgKipoZWFkOworCXVuc2lnbmVkIGludCBoYXNoOworCWludCBjcHU7CisKKwlsb2NhbF9iaF9kaXNhYmxlKCk7CisJY3B1ID0gc21wX3Byb2Nlc3Nvcl9pZCgpOworCisJZmxlID0gTlVMTDsKKwkvKiBQYWNrZXQgcmVhbGx5IGVhcmx5IGluIGluaXQ/ICBNYWtpbmcgZmxvd19jYWNoZV9pbml0IGEKKwkgKiBwcmUtc21wIGluaXRjYWxsIHdvdWxkIHNvbHZlIHRoaXMuICAtLVJSICovCisJaWYgKCFmbG93X3RhYmxlKGNwdSkpCisJCWdvdG8gbm9jYWNoZTsKKworCWlmIChmbG93X2hhc2hfcm5kX3JlY2FsYyhjcHUpKQorCQlmbG93X25ld19oYXNoX3JuZChjcHUpOworCWhhc2ggPSBmbG93X2hhc2hfY29kZShrZXksI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QljdXJfZGFkZHI7CisJaW50CQljb3VudDsKK307CisKK3N0cnVjdCBwa3RnZW5fZGV2IHsKKworCS8qCisJICogVHJ5IHRvIGtlZXAgZnJlcXVlbnQvaW5mcmVxdWVudCB1c2VkIHZhcnMuIHNlcGFyYXRlZC4KKwkgKi8KKworICAgICAgICBjaGFyIGlmbmFtZVszMl07CisgICAgICAgIHN0cnVjdCBwcm9jX2Rpcl9lbnRyeSAqcHJvY19lbnQ7CisgICAgICAgIGNoYXIgcmVzdWx0WzUxMl07CisgICAgICAgIC8qIHByb2MgZmlsZSBuYW1lcyAqLworICAgICAgICBjaGFyIGZuYW1lWzgwXTsKKworICAgICAgICBzdHJ1Y3QgcGt0Z2VuX3RocmVhZCogcGdfdGhyZWFkOyAvKiB0aGUgb3duZXIgKi8KKyAgICAgICAgc3RydWN0IHBrdGdlbl9kZXYgKm5leHQ7IC8qIFVzZWQgZm9yIGNoYWluaW5nIGluIHRoZSB0aHJlYWQncyBydW4tcXVldWUgKi8KKworICAgICAgICBpbnQgcnVubmluZzsgIC8qIGlmIHRoaXMgY2hhbmdlcyB0byBmYWxzZSwgdGhlIHRlc3Qgd2lsbCBzdG9wICovCisgICAgICAgIAorICAgICAgICAvKiBJZiBtaW4gIT0gbWF4LCB0aGVuIHdlIHdpbGwgZWl0aGVyIGRvIGEgbGluZWFyIGl0ZXJhdGlvbiwgb3IKKyAgICAgICAgICogd2Ugd2lsbCBkbyBhIHJhbmRvbSBzZWxlY3Rpb24gZnJvbSB3aXRoaW4gdGhlIHJhbmdlLgorICAgICAgICAgKi8KKyAgICAgICAgX191MzIgZmxhZ3M7ICAgICAKKworICAgICAgICBpbnQgbWluX3BrdF9zaXplOyAgICAvKiA9IEVUSF9aTEVOOyAqLworICAgICAgICBpbnQgbWF4X3BrdF9zaXplOyAgICAvKiA9IEVUSF9aTEVOOyAqLworICAgICAgICBpbnQgbmZyYWdzOworICAgICAgICBfX3UzMiBkZWxheV91czsgICAgLyogRGVmYXVsdCBkZWxheSAqLworICAgICAgICBfX3UzMiBkZWxheV9uczsKKyAgICAgICAgX191NjQgY291bnQ7ICAvKiBEZWZhdWx0IE5vIHBhY2tldHMgdG8gc2VuZCAqLworICAgICAgICBfX3U2NCBzb2ZhcjsgIC8qIEhvdyBtYW55IHBrdHMgd2UndmUgc2VudCBzbyBmYXIgKi8KKyAgICAgICAgX191NjQgdHhfYnl0ZXM7IC8qIEhvdyBtYW55IGJ5dGVzIHdlJ3ZlIHRyYW5zbWl0dGVkICovCisgICAgICAgIF9fdTY0IGVycm9yczsgICAgLyogRXJyb3JzIHdoZW4gdHJ5aW5nIHRvIHRyYW5zbWl0LCBwa3RzIHdpbGwgYmUgcmUtc2VudCAqLworCisgICAgICAgIC8qIHJ1bnRpbWUgY291bnRlcnMgcmVsYXRpbmcgdG8gY2xvbmVfc2tiICovCisgICAgICAgIF9fdTY0IG5leHRfdHhfdXM7ICAgICAgICAgIC8qIHRpbWVzdGFtcCBvZiB3aGVuIHRvIHR4IG5leHQgKi8KKyAgICAgICAgX191MzIgbmV4dF90eF9uczsKKyAgICAgICAgCisgICAgICAgIF9fdTY0IGFsbG9jYXRlZF9za2JzOworICAgICAgICBfX3UzMiBjbG9uZV9jb3VudDsKKwlpbnQgbGFzdF9vazsgICAgICAgICAgIC8qIFdhcyBsYXN0IHNrYiBzZW50PyAKKwkgICAgICAgICAgICAgICAgICAgICAgICAqIE9yIGEgZmFpbGVkIHRyYW5zbWl0IG9mIHNvbWUgc29ydD8gIFRoaXMgd2lsbCBrZWVwCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICogc2VxdWVuY2UgbnVtYmVycyBpbiBvcmRlciwgZm9yIGV4YW1wbGUuCisJCQkJKi8KKyAgICAgICAgX191NjQgc3RhcnRlZF9hdDsgLyogbWljcm8tc2Vjb25kcyAqLworICAgICAgICBfX3U2NCBzdG9wcGVkX2F0OyAvKiBtaWNyby1zZWNvbmRzICovCisgICAgICAgIF9fdTY0IGlkbGVfYWNjOyAvKiBtaWNyby1zZWNvbmRzICovCisgICAgICAgIF9fdTMyIHNlcV9udW07CisgICAgICAgIAorICAgICAgICBpbnQgY2xvbmVfc2tiOyAvKiBVc2UgbXVsdGlwbGUgU0tCcyBkdXJpbmcgcGFja2V0IGdlbi4gIElmIHRoaXMgbnVtYmVyCisgICAgICAgICAgICAgICAgICAgICAgICAgICogaXMgZ3JlYXRlciB0aGFuIDEsIHRoZW4gdGhhdCBtYW55IGNvcHBpZXMgb2YgdGhlIHNhbWUKKyAgICAgICAgICAgICAgICAgICAgICAgICAgKiBwYWNrZXQgd2lsbCBiZSBzZW50IGJlZm9yZSBhIG5ldyBwYWNrZXQgaXMgYWxsb2NhdGVkLgorICAgICAgICAgICAgICAgICAgICAgICAgICAqIEZvciBpbnN0YW5jZSwgaWYgeW91IHdhbnQgdG8gc2VuZCAxMDI0IGlkZW50aWNhbCBwYWNrZXRzCisgICAgICAgICAgICAgICAgICAgICAgICAgICogYmVmb3JlIGNyZWF0aW5nIGEgbmV3IHBhY2tldCwgc2V0IGNsb25lX3NrYiB0byAxMDI0LgorICAgICAgICAgICAgICAgICAgICAgICAgICAqLworICAgICAgICAKKyAgICAgICAgY2hhciBkc3RfbWluW0lQX05BTUVfU1pdOyAvKiBJUCwgaWUgMS4yLjMuNCAqLworICAgICAgICBjaGFyIGRzdF9tYXhbSVBfTkFNRV9TWl07IC8qIElQLCBpZSAxLjIuMy40ICovCisgICAgICAgIGNoYXIgc3JjX21pbltJUF9OQU1FX1NaXTsgLyogSVAsIGllIDEuMi4zLjQgKi8KKyAgICAgICAgY2hhciBzcmNfbWF4W0lQX05BTUVfU1pdOyAvKiBJUCwgaWUgMS4yLjMuNCAqLworCisJc3RydWN0IGluNl9hZGRyICBpbjZfc2FkZHI7CisJc3RydWN0IGluNl9hZGRyICBpbjZfZGFkZHI7CisJc3RydWN0IGluNl9hZGRyICBjdXJfaW42X2RhZGRyOworCXN0cnVjdCBpbjZfYWRkciAgY3VyX2luNl9zYWRkcjsKK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WdoICovCisgICAgICAgIF9fdTMyIGRzdF9tYWNfY291bnQ7IC8qIEhvdyBtYW55IE1BQ3MgdG8gaXRlcmF0ZSB0aHJvdWdoICovCisgICAgICAgIAorICAgICAgICB1bnNpZ25lZCBjaGFyIGRzdF9tYWNbNl07CisgICAgICAgIHVuc2lnbmVkIGNoYXIgc3JjX21hY1s2XTsKKyAgICAgICAgCisgICAgICAgIF9fdTMyIGN1cl9kc3RfbWFjX29mZnNldDsKKyAgICAgICAgX191MzIgY3VyX3NyY19tYWNfb2Zmc2V0OworICAgICAgICBfX3UzMiBjdXJfc2FkZHI7CisgICAgICAgIF9fdTMyIGN1cl9kYWRkcjsKKyAgICAgICAgX191MTYgY3VyX3VkcF9kc3Q7CisgICAgICAgIF9fdTE2IGN1cl91ZHBfc3JjOworICAgICAgICBfX3UzMiBjdXJfcGt0X3NpemU7CisgICAgICAgIAorICAgICAgICBfX3U4IGhoWzE0XTsKKyAgICAgICAgLyogPSB7IAorICAgICAgICAgICAweDAwLCAweDgwLCAweEM4LCAweDc5LCAweEIzLCAweENCLCAKKyAgICAgICAgICAgCisgICAgICAgICAgIFdlIGZpbGwgaW4gU1JDIGFkZHJlc3MgbGF0ZXIKKyAgICAgICAgICAgMHgwMCwgMHgwMCwgMHgwMCwgMHgwMCwgMHgwMCwgMHgwMCwKKyAgICAgICAgICAgMHgwOCwgMHgwMAorICAgICAgICAgICB9OworICAgICAgICAqLworICAgICAgICBfX3UxNiBwYWQ7IC8qIHBhZCBvdXQgdGhlIGhoIHN0cnVjdCB0byBhbiBldmVuIDE2IGJ5dGVzICovCisKKyAgICAgICAgc3RydWN0IHNrX2J1ZmYqIHNrYjsgLyogc2tiIHdlIGFyZSB0byB0cmFuc21pdCBuZXh0LCBtYWlubHkgdXNlZCBmb3Igd2hlbiB3ZQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKiBhcmUgdHJhbnNtaXR0aW5nIHRoZSBzYW1lIG9uZSBtdWx0aXBsZSB0aW1lcworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKi8KKyAgICAgICAgc3RydWN0IG5ldF9kZXZpY2UqIG9kZXY7IC8qIFRoZSBvdXQtZ29pbmcgZGV2aWNlLiAgTm90ZSB0aGF0IHRoZSBkZXZpY2Ugc2hvdWxkCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKiBoYXZlIGl0J3MgcGdfaW5mbyBwb2ludGVyIHBvaW50aW5nIGJhY2sgdG8gdGhpcworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICogZGV2aWNlLiAgVGhpcyB3aWxsIGJlIHNldCB3aGVuIHRoZSB1c2VyIHNwZWNpZmllcworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICogdGhlIG91dC1nb2luZyBkZXZpY2UgbmFtZSAobm90IHdoZW4gdGhlIGluamVjdCBpcworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICogc3RhcnRlZCBhcyBpdCB1c2VkIHRvIGRvLikKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqLworCXN0cnVjdCBmbG93X3N0YXRlICpmbG93czsKKwl1bnNpZ25lZCBjZmxvd3M7ICAgICAgICAgLyogQ29uY3VycmVudCBmbG93cyAoY29uZmlnKSAqLworCXVuc2lnbmVkIGxmbG93OyAgICAgICAgICAvKiBGbG93IGxlbmd0aCAgKGNvbmZpZykgKi8KKwl1bnNpZ25lZCBuZmxvd3M7ICAgICAgICAgLyogYWNjdW11bGF0ZWQgZmxvd3MgKHN0YXRzKSAqLworfTsKKworc3RydWN0IHBrdGdlbl9oZHIgeworICAgICAgICBfX3UzMiBwZ2hfbWFnaWM7CisgICAgICAgIF9fdTMyIHNlcV9udW07CisJX191MzIgdHZfc2VjOworCV9fdTMyIHR2X3VzZWM7Cit9OworCitzdHJ1Y3QgcGt0Z2VuX3RocmVhZCB7CisgICAgICAgIHNwaW5sb2NrX3QgaWZfbG9jazsKKyAgICAgICAgc3RydWN0IHBrdGdlbl9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mV0L2Jyb3dzZS9saWIvc3RhdGljL2ludG1hdGgvaXg4Ni9pbnRtYXRoLmMuaHRtbAorICoKKyAqIENvcHlyaWdodCAxOTk0LCBVbml2ZXJzaXR5IG9mIENhbWJyaWRnZSBDb21wdXRlciBMYWJvcmF0b3J5CisgKiBBbGwgUmlnaHRzIFJlc2VydmVkLgorICoKKyAqLworaW5saW5lIHN0YXRpYyBzNjQgZGl2cmVtZGkzKHM2NCB4LCBzNjQgeSwgaW50IHR5cGUpIAoreworICAgICAgICB1NjQgYSA9ICh4IDwgMCkgPyAteCA6IHg7CisgICAgICAgIHU2NCBiID0gKHkgPCAwKSA/IC15IDogeTsKKyAgICAgICAgdTY0IHJlcyA9IDAsIGQgPSAxOworCisgICAgICAgIGlmIChiID4gMCkgeworICAgICAgICAgICAgICAgIHdoaWxlIChiIDwgYSkgeworICAgICAgICAgICAgICAgICAgICAgICAgYiA8PD0gMTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGQgPDw9IDE7CisgICAgICAgICAgICAgICAgfQorICAgICAgICB9CisgICAgICAgIAorICAgICAgICBkbyB7CisgICAgICAgICAgICAgICAgaWYgKCBhID49IGIgKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBhIC09IGI7CisgICAgICAgICAgICAgICAgICAgICAgICByZXMgKz0gZDsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgYiA+Pj0gMTsKKyAgICAgICAgICAgICAgICBkID4+PSAxOworICAgICAgICB9CisgICAgICAgIHdoaWxlIChkKTsKKworICAgICAgICBpZiAoUEdfRElWID09IHR5cGUpIHsKKyAgICAgICAgICAgICAgICByZXR1cm4gKCgoeCBeIHkpICYgKDFsbDw8NjMpKSA9PSAwKSA/IHJlcyA6IC0oczY0KXJlczsKKyAgICAgICAgfQorICAgICAgICBlbHNlIHsKKyAgICAgICAgICAgICAgICByZXR1cm4gKCh4ICYgKDFsbDw8NjMpKSA9PSAwKSA/IGEgOiAtKHM2NClhOworICAgICAgICB9Cit9CisKKy8qIEVuZCBvZiBoYWNrcyB0byBkZWFsIHdpdGggNjQtYml0IG1hdGggb24geDg2ICovCisKKy8qKiBDb252ZXJ0IHRvIG1pbGlzZWNvbmRzICovCitzdGF0aWMgaW5saW5lIF9fdTY0IHR2X3RvX21zKGNvbnN0IHN0cnVjdCB0aW1ldmFsKiB0dikgCit7CisgICAgICAgIF9fdTY0IG1zID0gdHYtPnR2X3VzZWMgLyAxMDAwOworICAgICAgICBtcyArPSAoX191NjQpdHYtPnR2X3NlYyAqIChfX3U2NCkxMDAwOworICAgICAgICByZXR1cm4gbXM7Cit9CisKKworLyoqIENvbnZlcnQgdG8gbWljcm8tc2Vjb25kcyAqLworc3RhdGljIGlubGluZSBfX3U2NCB0dl90b191cyhjb25zdCBzdHJ1Y3QgdGltZXZhbCogdHYpIAoreworICAgICAgICBfX3U2NCB1cyA9IHR2LT50dl91c2VjOworICAgICAgICB1cyArPSAoX191NjQpdHYtPnR2X3NlYyAqIChfX3U2NCkxMDAwMDAwOworICAgICAgICByZXR1cm4gdXM7Cit9CisKK3N0YXRpYyBpbmxpbmUgX191NjQgcGdfZGl2KF9fdTY0IG4sIF9fdTMyIGJhc2UpIHsKKyAgICAgICAgX191NjQgdG1wID0gbjsKKyAgICAgICAgZG9fZGl2KHRtcCwgYmFzZSk7CisgICAgICAgIC8qIHByaW50aygicGt0Z2VuOiBwZ19kaXYsIG46ICVsbHUgIGJhc2U6ICVkICBydjogJWxsdVxuIiwKKyAgICAgICAgICAgICAgICAgIG4sIGJhc2UsIHRtcCk7ICovCisgICAgICAgIHJldHVybiB0bXA7Cit9CisKK3N0YXRpYyBpbmxpbmUgX191NjQgcGdfZGl2NjQoX191NjQgbiwgX191NjQgYmFzZSkgCit7CisgICAgICAgIF9fdTY0IHRtcCA9IG47CisvKgorICogSG93IGRvIHdlIGtub3cgaWYgdGhlIGFyY2hpdGVjdHJ1cmUgd2UgYXJlIHJ1bm5pbmcgb24KKyAqIHN1cHBvcnRzIGRpd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yb21fdXNlcihkYXRhLCBidWYsIGNvdW50KSkgeworCQllcnIgPS1FRkFVTFQ7CisJCWdvdG8gb3V0X2ZyZWU7CisJfSAgCisJZGF0YVtjb3VudC0xXSA9IDA7IC8qIE1ha2Ugc3RyaW5nICovCisKKwlpZiAoIXN0cmNtcChkYXRhLCAic3RvcCIpKSAKKwkJcGt0Z2VuX3N0b3BfYWxsX3RocmVhZHNfaWZzKCk7CisKKyAgICAgICAgZWxzZSBpZiAoIXN0cmNtcChkYXRhLCAic3RhcnQiKSkgCisJCXBrdGdlbl9ydW5fYWxsX3RocmVhZHMoKTsKKworCWVsc2UgCisJCXByaW50aygicGt0Z2VuOiBVbmtub3duIGNvbW1hbmQ6ICVzXG4iLCBkYXRhKTsKKworCWVyciA9IGNvdW50OworCisgb3V0X2ZyZWU6CisJdmZyZWUgKGRhdGEpOworIG91dDoKKyAgICAgICAgcmV0dXJuIGVycjsKK30KKworc3RhdGljIGludCBwcm9jX2lmX3JlYWQoY2hhciAqYnVmICwgY2hhciAqKnN0YXJ0LCBvZmZfdCBvZmZzZXQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnQgbGVuLCBpbnQgKmVvZiwgdm9pZCAqZGF0YSkKK3sKKwljaGFyICpwOworCWludCBpOworICAgICAgICBzdHJ1Y3QgcGt0Z2VuX2RldiAqcGt0X2RldiA9IChzdHJ1Y3QgcGt0Z2VuX2RldiopKGRhdGEpOworICAgICAgICBfX3U2NCBzYTsKKyAgICAgICAgX191NjQgc3RvcHBlZDsKKyAgICAgICAgX191NjQgbm93ID0gZ2V0Q3VyVXMoKTsKKyAgICAgICAgCisJcCA9IGJ1ZjsKKwlwICs9IHNwcmludGYocCwgIlBhcmFtczogY291bnQgJWxsdSAgbWluX3BrdF9zaXplOiAldSAgbWF4X3BrdF9zaXplOiAldVxuIiwKKwkJICAgICAodW5zaWduZWQgbG9uZyBsb25nKSBwa3RfZGV2LT5jb3VudCwKKwkJICAgICBwa3RfZGV2LT5taW5fcG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BiMSwgYjIsIGIzKTsKKworCX0gCisJZWxzZSAKKwkJcCArPSBzcHJpbnRmKHAsICIgICAgIGRzdF9taW46ICVzICBkc3RfbWF4OiAlc1xuICAgICBzcmNfbWluOiAlcyAgc3JjX21heDogJXNcbiIsCisgICAgICAgICAgICAgICAgICAgICBwa3RfZGV2LT5kc3RfbWluLCBwa3RfZGV2LT5kc3RfbWF4LCBwa3RfZGV2LT5zcmNfbWluLCBwa3RfZGV2LT5zcmNfbWF4KTsKKworICAgICAgICBwICs9IHNwcmludGYocCwgIiAgICAgc3JjX21hYzogIik7CisKKwlpZiAoKHBrdF9kZXYtPnNyY19tYWNbMF0gPT0gMCkgJiYgCisJICAgIChwa3RfZGV2LT5zcmNfbWFjWzFdID09IDApICYmIAorCSAgICAocGt0X2Rldi0+c3JjX21hY1syXSA9PSAwKSAmJiAKKwkgICAgKHBrdF9kZXYtPnNyY19tYWNbM10gPT0gMCkgJiYgCisJICAgIChwa3RfZGV2LT5zcmNfbWFjWzRdID09IDApICYmIAorCSAgICAocGt0X2Rldi0+c3JjX21hY1s1XSA9PSAwKSkgCisKKwkJZm9yIChpID0gMDsgaSA8IDY7IGkrKykgCisJCQlwICs9IHNwcmludGYocCwgIiUwMlglcyIsIHBrdF9kZXYtPm9kZXYtPmRldl9hZGRyW2ldLCBpID09IDUgPyAiICAiIDogIjoiKTsKKworCWVsc2UgCisJCWZvciAoaSA9IDA7IGkgPCA2OyBpKyspIAorCQkJcCArPSBzcHJpbnRmKHAsICIlMDJYJXMiLCBwa3RfZGV2LT5zcmNfbWFjW2ldLCBpID09IDUgPyAiICAiIDogIjoiKTsKKworICAgICAgICBwICs9IHNwcmludGYocCwgImRzdF9tYWM6ICIpOworCWZvciAoaSA9IDA7IGkgPCA2OyBpKyspIAorCQlwICs9IHNwcmludGYocCwgIiUwMlglcyIsIHBrdF9kZXYtPmRzdF9tYWNbaV0sIGkgPT0gNSA/ICJcbiIgOiAiOiIpOworCisgICAgICAgIHAgKz0gc3ByaW50ZihwLCAiICAgICB1ZHBfc3JjX21pbjogJWQgIHVkcF9zcmNfbWF4OiAlZCAgdWRwX2RzdF9taW46ICVkICB1ZHBfZHN0X21heDogJWRcbiIsCisgICAgICAgICAgICAgICAgICAgICBwa3RfZGV2LT51ZHBfc3JjX21pbiwgcGt0X2Rldi0+dWRwX3NyY19tYXgsIHBrdF9kZXYtPnVkcF9kc3RfbWluLAorICAgICAgICAgICAgICAgICAgICAgcGt0X2Rldi0+dWRwX2RzdF9tYXgpOworCisgICAgICAgIHAgKz0gc3ByaW50ZihwLCAiICAgICBzcmNfbWFjX2NvdW50OiAlZCAgZHN0X21hY19jb3VudDogJWQgXG4gICAgIEZsYWdzOiAiLAorICAgICAgICAgICAgICAgICAgICAgcGt0X2Rldi0+c3JjX21hY19jb3VudCwgcGt0X2Rldi0+ZHN0X21hY19jb3VudCk7CisKKworICAgICAgICBpZiAocGt0X2Rldi0+ZmxhZ3MgJiAgRl9JUFY2KSAKKyAgICAgICAgICAgICAgICBwICs9IHNwcmludGYocCwgIklQVjYgICIpOworCisgICAgICAgIGlmIChwa3RfZGV2LT5mbGFncyAmICBGX0lQU1JDX1JORCkgCisgICAgICAgICAgICAgICAgcCArPSBzcHJpbnRmKHAsICJJUFNSQ19STkQgICIpOworCisgICAgICAgIGlmIChwa3RfZGV2LT5mbGFncyAmIEZfSVBEU1RfUk5EKSAKKyAgICAgICAgICAgICAgICBwICs9IHNwcmludGYocCwgIklQRFNUX1JORCAgIik7CisgICAgICAgIAorICAgICAgICBpZiAocGt0X2Rldi0+ZmxhZ3MgJiBGX1RYU0laRV9STkQpIAorICAgICAgICAgICAgICAgIHAgKz0gc3ByaW50ZihwLCAiVFhTSVpFX1JORCAgIik7CisgICAgICAgIAorICAgICAgICBpZiAocGt0X2Rldi0+ZmxhZ3MgJiBGX1VEUFNSQ19STkQpIAorICAgICAgICAgICAgICAgIHAgKz0gc3ByaW50ZihwLCAiVURQU1JDX1JORCAgIik7CisgICAgICAgIAorICAg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cmVzdWx0WzBdKQorCQlwICs9IHNwcmludGYocCwgIlJlc3VsdDogJXNcbiIsIHBrdF9kZXYtPnJlc3VsdCk7CisJZWxzZQorCQlwICs9IHNwcmludGYocCwgIlJlc3VsdDogSWRsZVxuIik7CisJKmVvZiA9IDE7CisKKwlyZXR1cm4gcCAtIGJ1ZjsKK30KKworCitzdGF0aWMgaW50IGNvdW50X3RyYWlsX2NoYXJzKGNvbnN0IGNoYXIgX191c2VyICp1c2VyX2J1ZmZlciwgdW5zaWduZWQgaW50IG1heGxlbikKK3sKKwlpbnQgaTsKKworCWZvciAoaSA9IDA7IGkgPCBtYXhsZW47IGkrKykgeworICAgICAgICAgICAgICAgIGNoYXIgYzsKKyAgICAgICAgICAgICAgICBpZiAoZ2V0X3VzZXIoYywgJnVzZXJfYnVmZmVyW2ldKSkKKyAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAtRUZBVUxUOworICAgICAgICAgICAgICAgIHN3aXRjaCAoYykgeworCQljYXNlICdcIic6CisJCWNhc2UgJ1xuJzoKKwkJY2FzZSAnXHInOgorCQljYXNlICdcdCc6CisJCWNhc2UgJyAnOgorCQljYXNlICc9JzoKKwkJCWJyZWFrOworCQlkZWZhdWx0OgorCQkJZ290byBkb25lOworCQl9OworCX0KK2RvbmU6CisJcmV0dXJuIGk7Cit9CisKK3N0YXRpYyB1bnNpZ25lZCBsb25nIG51bV9hcmcoY29uc3QgY2hhciBfX3VzZXIgKnVzZXJfYnVmZmVyLCB1bnNpZ25lZCBsb25nIG1heGxlbiwgCisJCQkgICAgIHVuc2lnbmVkIGxvbmcgKm51bSkKK3sKKwlpbnQgaSA9IDA7CisJKm51bSA9IDA7CisgIAorCWZvcig7IGkgPCBtYXhsZW47IGkrKykgeworICAgICAgICAgICAgICAgIGNoYXIgYzsKKyAgICAgICAgICAgICAgICBpZiAoZ2V0X3VzZXIoYywgJnVzZXJfYnVmZmVyW2ldKSkKKyAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAtRUZBVUxUOworICAgICAgICAgICAgICAgIGlmICgoYyA+PSAnMCcpICYmIChjIDw9ICc5JykpIHsKKwkJCSpudW0gKj0gMTA7CisJCQkqbnVtICs9IGMgLScwJzsKKwkJfSBlbHNlCisJCQlicmVhazsKKwl9CisJcmV0dXJuIGk7Cit9CisKK3N0YXRpYyBpbnQgc3Rybl9sZW4oY29uc3QgY2hhciBfX3VzZXIgKnVzZXJfYnVmZmVyLCB1bnNpZ25lZCBpbnQgbWF4bGVuKQoreworCWludCBpID0gMDsKKworCWZvcig7IGkgPCBtYXhsZW47IGkrKykgeworICAgICAgICAgICAgICAgIGNoYXIgYzsKKyAgICAgICAgICAgICAgICBpZiAoZ2V0X3VzZXIoYywgJnVzZXJfYnVmZmVyW2ldKSkKKyAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAtRUZBVUxUOworICAgICAgICAgICAgICAgIHN3aXRjaCAoYykgeworCQljYXNlICdcIic6CisJCWNhc2UgJ1xuJzoKKwkJY2FzZSAnXHInOgorCQljYXNlICdcdCc6CisJCWNhc2UgJyAnOgorCQkJZ290byBkb25lX3N0cjsKKwkJCWJyZWFrOworCQlkZWZhdWx0OgorCQkJYnJlYWs7CisJCX07CisJfQorZG9uZV9zdHI6CisKKwlyZXR1cm4gaTsKK30KKworc3RhdGljIGludCBwcm9jX2lmX3dyaXRlKHN0cnVjdCBmaWxlICpmaWxlLCBjb25zdCBjaGFyIF9fdXNlciAqdXNlcl9idWZmZXIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgdW5zaWduZWQgbG9uZyBjb3VudCwgdm9pZCAqZGF0YSkKK3sKKwlpbnQgaSA9IDAsIG1heCwgbGVuOworCWNoYXIgbmFtZVsxNl0sIHZhbHN0clszMl07CisJdW5zaWduZWQgbG9uZyB2YWx1ZSA9IDA7CisgICAgICAgIHN0cnVjdCBwa3RnZW5fZGV2ICpwa3RfZGV2ID0gKHN0cnVjdCBwa3RnZW5fZGV2KikoZGF0YSk7CisgICAgICAgIGNoYXIqIHBnX3Jlc3VsdCA9IE5VTEw7CisgICAgICAgIGludCB0bXAgPSAwOworCWNoYXIgYnVmWzEyOF07CisgICAgICAgIAorICAgICAgICBwZ19yZXN1bHQgPSAmKHBrdF9kZXYtPnJlc3VsdFswXSk7CisgICAgICAgIAorCWlmIChjb3VudCA8IDEpIHsKKwkJcHJpbnRrKCJwa3RnZW46IHdyb25nIGNvbW1hbmQgZm9ybWF0XG4iKTsKKwkJcmV0dXJuIC1FSU5WQUw7CisJfQorICAKKwltYXggPSBjb3VudCAtIGk7CisJdG1wID0gY291bnRfdHJhaWxfY2hhcnMoJnVzZXJfYnVmZmVyW2ldLCBtYXgpOworICAgICAgICBpZiAodG1wIDwgMCkgeyAKKwkJcHJpbnRrKCJwa3RnZW46IGlsbGVnYWwgZm9ybWF0XG4iKTsKKwkJcmV0dXJuIHRtcDsgCisJfQorICAgICAgICBpICs9IHRtcDsKKyAgICAgICAgCisJLyogUmVhZCB2YXJpYWJsZSBuYW1lICovCisKKwlsZW4gPSBzdHJuX2xlbigmdXNlcl9idWZmZXJbaV0sIHNpemVvZihuYW1lKSAtIDEpOworICAgICAgICBpZiAobGVuIDwgMCkgeyByZXR1cm4gbGVuOyB9CisJbWVtc2V0KG5hbWUsIDAsIHNpemVvZihuYW1lKSk7CisJaWYgKGNvcHlfZnJvbV91c2VyKG5hbWUsICZ1c2VyX2J1ZmZlcltpXSwgbGVuKSApCisJCXJldHVybiAtRUZBVUxUOworCWkgKz0gbGVuOworICAKKwltYXggPSBjb3VudCAtaTsKKwlsZW4gPSBjb3VudF90cmFpbF9jaGFycygmdXNlcl9idWZmZXJbaV0sIG1heCk7CisgICAgICAgIGlmIChsZW4gPCAwKSAKKyAgICAgICAgICAgICAgICByZXR1cm4gbGVuOworICAgICAgICAKKwlpICs9IGxlbjsKKworCWlmIChkZWJ1ZykgeworICAgICAgICAgICAgICAgIGNoYXIgdGJbY291bnQgKyAxXTsKKyAgICAgICAgICAgICAgICBpZiAoY29weV9mcm9tX3VzZXIodGIsIHVzZXJfYnVmZmVyLCBjb3VudCkpCisJCQlyZXR1cm4gLUVGQVVMVDsKKyAgICAgICAgICAgICAgICB0Yltjb3VudF0gPSAwOworCQlwcmludGsoInBrdGdlbjogJXMsJWx1ICBidWZmZXIgLTolczotXG4iLCBuYW1lLCBjb3VudCwgdGIpOworICAgICAgICB9CisKKwlpZiAoIXN0cmNtcChuYW1lLCAibWluX3BrdF9zaXplIikpIHsKKwkJbGVuID0gbnVtX2FyZygmdXNlcl9idWZmZXJbaV0sIDEwLCAmdmFsdWUpOworICAgICAgICAgICAgICAgIGlmIChsZW4gPCAwKSB7IHJldHVybiBsZW47IH0KKwkJaSArPSBsZW47CisJCWlmICh2YWx1ZSA8IDE0KzIwKzgpCisJCQl2YWx1ZSA9IDE0KzIwKzg7CisgICAgICAgICAgICAgICAgaWYgKHZhbHVlICE9IHBrdF9kZXYtPm1pbl9wa3Rfc2l6ZSkgeworICAgICAgICAgICAgICAgICAgICAgICAgcGt0X2Rldi0+bWluX3BrdF9zaXplID0gdmFsdWU7CisgICAgICAgICAgICAgICAgICAgICAgICBwa3RfZGV2LT5jdXJfcGt0X3NpemUgPSB2YWx1ZTsKKyAgICAgICAgICAgICAgICB9CisJCXNwcmludGYocGdfcmVzdWx0LCAiT0s6IG1pbl9wa3Rfc2l6ZT0ldSIsIHBrdF9kZXYtPm1pbl9wa3Rfc2l6ZSk7CisJCXJldHVybiBjb3VudDsKKwl9CisKKyAgICAgICAgaWYgKCFzdHJjbXAobmFtZSwgIm1heF9wa3Rfc2l6ZSIpKSB7CisJCWxlbiA9IG51bV9hcmcoJnVzZXJfYnVmZmVyW2ldLCAxMCwgJnZhbHVlKTsKKyAgICAgICAgICAgICAgICBpZiAobGVuIDwgMCkgeyByZXR1cm4gbGVuOyB9CisJCWkgKz0gbGVuOworCQlpZiAodmFsdWUgPCAxNCsyMCs4KQorCQkJdmFsdWUgPSAxNCsyMCs4OworICAgICAgICAgICAgICAgIGlmICh2YWx1ZSAhPSBwa3RfZGV2LT5tYXhfcGt0X3NpemUpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIHBrdF9kZXYtPm1heF9wa3Rfc2l6ZSA9IHZhbHVlOworICAgICAgICAgICAgICAgICAgICAgICAgcGt0X2Rldi0+Y3VyX3BrdF9zaXplID0gdmFsdWU7CisgICAgICAgICAgICAgICAgfQorCQlzcHJpbnRmKHBnX3Jlc3VsdCwgIk9LOiBtYXhfcGt0X3NpemU9JXUiLCBwa3RfZGV2LT5tYXhfcGt0X3NpemUpOworCQlyZXR1cm4gY291bnQ7CisJfQorCisgICAgICAgIC8qIFNob3J0Y3V0IGZvciBtaW4gPSBtYXggKi8KKworCWlmICghc3RyY21wKG5hbWUsICJwa3Rfc2l6ZSIpKSB7CisJCWxlbiA9IG51bV9hcmcoJnVzZXJfYnVmZmVyW2ldLCAxMCwgJnZhbHVlKTsKKyAgICAgICAgICAgICAgICBpZiAobGVuIDwgMCkgeyByZXR1cm4gbGVuOyB9CisJCWkgKz0gbGVuOworCQlpZiAodmFsdWUgPCAxNCsyMCs4KQorCQkJdmFsdWUgPSAxNCsyMCs4OworICAgICAgICAgICAgICAgIGlmICh2YWx1ZSAhPSBwa3RfZGV2LT5taW5fcGt0X3NpemUpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIHBrdF9kZXYtPm1pbl9wa3Rfc2l6ZSA9IHZhbHVlOworICAgICAgICAgICAgICAgICAgICAgICAgcGt0X2Rldi0+bWF4X3BrdF9zaXplID0gdmFsdWU7CisgICAgICAgICAgICAgICAgICAgICAgICBwa3RfZGV2LT5jdXJfcGt0X3NpemUgPSB2YWx1ZTsKKyAgICAgICAgICAgICAgICB9CisJCXNwcmludGYocGdfcmVzdWx0LCAiT0s6IHBrdF9zaXplPSV1IiwgcGt0X2Rldi0+bWluX3BrdF9zaXplKTsKKwkJcmV0dXJuIGNvdW50OworCX0KKworICAgICAgICBpZiAoIXN0cmNtcChuYW1lLCAiZGVidWciKSkg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VsYXk9JXUiLCAxMDAwKnBrdF9kZXYtPmRlbGF5X3VzK3BrdF9kZXYtPmRlbGF5X25zKTsKKwkJcmV0dXJuIGNvdW50OworCX0KKyAJaWYgKCFzdHJjbXAobmFtZSwgInVkcF9zcmNfbWluIikpIHsKKwkJbGVuID0gbnVtX2FyZygmdXNlcl9idWZmZXJbaV0sIDEwLCAmdmFsdWUpOworICAgICAgICAgICAgICAgIGlmIChsZW4gPCAwKSB7IHJldHVybiBsZW47IH0KKwkJaSArPSBsZW47CisgICAgICAgICAgICAgICAgaWYgKHZhbHVlICE9IHBrdF9kZXYtPnVkcF9zcmNfbWluKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBwa3RfZGV2LT51ZHBfc3JjX21pbiA9IHZhbHVlOworICAgICAgICAgICAgICAgICAgICAgICAgcGt0X2Rldi0+Y3VyX3VkcF9zcmMgPSB2YWx1ZTsKKyAgICAgICAgICAgICAgICB9ICAgICAgIAorCQlzcHJpbnRmKHBnX3Jlc3VsdCwgIk9LOiB1ZHBfc3JjX21pbj0ldSIsIHBrdF9kZXYtPnVkcF9zcmNfbWluKTsKKwkJcmV0dXJuIGNvdW50OworCX0KKyAJaWYgKCFzdHJjbXAobmFtZSwgInVkcF9kc3RfbWluIikpIHsKKwkJbGVuID0gbnVtX2FyZygmdXNlcl9idWZmZXJbaV0sIDEwLCAmdmFsdWUpOworICAgICAgICAgICAgICAgIGlmIChsZW4gPCAwKSB7IHJldHVybiBsZW47IH0KKwkJaSArPSBsZW47CisgICAgICAgICAgICAgICAgaWYgKHZhbHVlICE9IHBrdF9kZXYtPnVkcF9kc3RfbWluKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBwa3RfZGV2LT51ZHBfZHN0X21pbiA9IHZhbHVlOworICAgICAgICAgICAgICAgICAgICAgICAgcGt0X2Rldi0+Y3VyX3VkcF9kc3QgPSB2YWx1ZTsKKyAgICAgICAgICAgICAgICB9CisJCXNwcmludGYocGdfcmVzdWx0LCAiT0s6IHVkcF9kc3RfbWluPSV1IiwgcGt0X2Rldi0+dWRwX2RzdF9taW4pOworCQlyZXR1cm4gY291bnQ7CisJfQorIAlpZiAoIXN0cmNtcChuYW1lLCAidWRwX3NyY19tYXgiKSkgeworCQlsZW4gPSBudW1fYXJnKCZ1c2VyX2J1ZmZlcltpXSwgMTAsICZ2YWx1ZSk7CisgICAgICAgICAgICAgICAgaWYgKGxlbiA8IDApIHsgcmV0dXJuIGxlbjsgfQorCQlpICs9IGxlbjsKKyAgICAgICAgICAgICAgICBpZiAodmFsdWUgIT0gcGt0X2Rldi0+dWRwX3NyY19tYXgpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIHBrdF9kZXYtPnVkcF9zcmNfbWF4ID0gdmFsdWU7CisgICAgICAgICAgICAgICAgICAgICAgICBwa3RfZGV2LT5jdXJfdWRwX3NyYyA9IHZhbHVlOworICAgICAgICAgICAgICAgIH0KKwkJc3ByaW50ZihwZ19yZXN1bHQsICJPSzogdWRwX3NyY19tYXg9JXUiLCBwa3RfZGV2LT51ZHBfc3JjX21heCk7CisJCXJldHVybiBjb3VudDsKKwl9CisgCWlmICghc3RyY21wKG5hbWUsICJ1ZHBfZHN0X21heCIpKSB7CisJCWxlbiA9IG51bV9hcmcoJnVzZXJfYnVmZmVyW2ldLCAxMCwgJnZhbHVlKTsKKyAgICAgICAgICAgICAgICBpZiAobGVuIDwgMCkgeyByZXR1cm4gbGVuOyB9CisJCWkgKz0gbGVuOworICAgICAgICAgICAgICAgIGlmICh2YWx1ZSAhPSBwa3RfZGV2LT51ZHBfZHN0X21heCkgeworICAgICAgICAgICAgICAgICAgICAgICAgcGt0X2Rldi0+dWRwX2RzdF9tYXggPSB2YWx1ZTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHBrdF9kZXYtPmN1cl91ZHBfZHN0ID0gdmFsdWU7CisgICAgICAgICAgICAgICAgfQorCQlzcHJpbnRmKHBnX3Jlc3VsdCwgIk9LOiB1ZHBfZHN0X21heD0ldSIsIHBrdF9kZXYtPnVkcF9kc3RfbWF4KTsKKwkJcmV0dXJuIGNvdW50OworCX0KKwlpZiAoIXN0cmNtcChuYW1lLCAiY2xvbmVfc2tiIikpIHsKKwkJbGVuID0gbnVtX2FyZygmdXNlcl9idWZmZXJbaV0sIDEwLCAmdmFsdWUpOworICAgICAgICAgICAgICAgIGlmIChsZW4gPCAwKSB7IHJldHVybiBsZW47IH0KKwkJaSArPSBsZW47CisgICAgICAgICAgICAgICAgcGt0X2Rldi0+Y2xvbmVfc2tiID0gdmFsdWU7CisJCisJCXNwcmludGYocGdfcmVzdWx0LCAiT0s6IGNsb25lX3NrYj0lZCIsIHBrdF9kZXYtPmNsb25lX3NrYik7CisJCXJldHVybiBjb3VudDsKKwl9CisJaWYgKCFzdHJjbXAobmFtZSwgImNvdW50IikpIHsKKwkJbGVuID0gbnVtX2FyZygmdXNlcl9idWZmZXJbaV0sIDEwLCAmdmFsdWUpOworICAgICAgICAgICAgICAgIGlmIChsZW4gPCAwKSB7IHJldHVybiBsZW47IH0KKwkJaSArPSBsZW47CisJCXBrdF9kZXYtPmNvdW50ID0gdmFsdWU7CisJCXNwcmludGYocGdfcmVzdWx0LCAiT0s6IGNvdW50PSVsbHUiLAorCQkJKHVuc2lnbmVkIGxvbmcgbG9uZykgcGt0X2Rldi0+Y291bnQpOworCQlyZXR1cm4gY291bnQ7CisJfQorCWlmICghc3RyY21wKG5hbWUsICJzcmNfbWFjX2NvdW50IikpIHsKKwkJbGVuID0gbnVtX2FyZygmdXNlcl9idWZmZXJbaV0sIDEwLCAmdmFsdWUpOworICAgICAgICAgICAgICAgIGlmIChsZW4gPCAwKSB7IHJldHVybiBsZW47IH0KKwkJaSArPSBsZW47CisJCWlmIChwa3RfZGV2LT5zcmNfbWFjX2NvdW50ICE9IHZhbHVlKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBwa3RfZGV2LT5zcmNfbWFjX2NvdW50ID0gdmFsdWU7CisgICAgICAgICAgICAgICAgICAgICAgICBwa3RfZGV2LT5jdXJfc3JjX21hY19vZmZzZXQgPSAwOworICAgICAgICAgICAgICAgIH0KKwkJc3ByaW50ZihwZ19yZXN1bHQsICJPSzogc3JjX21hY19jb3VudD0lZCIsIHBrdF9kZXYtPnNyY19tYWNfY291bnQpOworCQlyZXR1cm4gY291bnQ7CisJfQorCWlmICghc3RyY21wKG5hbWUsICJkc3RfbWFjX2NvdW50IikpIHsKKwkJbGVuID0gbnVtX2FyZygmdXNlcl9idWZmZXJbaV0sIDEwLCAmdmFsdWUpOworICAgICAgICAgICAgICAgIGlmIChsZW4gPCAwKSB7IHJldHVybiBsZW47IH0KKwkJaSArPSBsZW47CisJCWlmIChwa3RfZGV2LT5kc3RfbWFjX2NvdW50ICE9IHZhbHVlKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBwa3RfZGV2LT5kc3RfbWFjX2NvdW50ID0gdmFsdWU7CisgICAgICAgICAgICAgICAgICAgICAgICBwa3RfZGV2LT5jdXJfZHN0X21hY19vZmZzZXQgPSAwOworICAgICAgICAgICAgICAgIH0KKwkJc3ByaW50ZihwZ19yZXN1bHQsICJPSzogZHN0X21hY19jb3VudD0lZCIsIHBrdF9kZXYtPmRzdF9tYWNfY291bnQpOworCQlyZXR1cm4gY291bnQ7CisJfQorCWlmICghc3RyY21wKG5hbWUsICJmbGFnIikpIHsKKyAgICAgICAgICAgICAgICBjaGFyIGZbMzJdOworICAgICAgICAgICAgICAgIG1lbXNldChmLCAwLCAzMik7CisJCWxlbiA9IHN0cm5fbGVuKCZ1c2VyX2J1ZmZlcltpXSwgc2l6ZW9mKGYpIC0gMSk7CisgICAgICAgICAgICAgICAgaWYgKGxlbiA8IDApIHsgcmV0dXJuIGxlbjsgfQorCQlpZiAoY29weV9mcm9tX3VzZXIoZiwgJnVzZXJfYnVmZmVyW2ldLCBsZW4pKQorCQkJcmV0dXJuIC1FRkFVTFQ7CisJCWkgKz0gbGVuOworICAgICAgICAgICAgICAgIGlmIChzdHJjbXAoZiwgIklQU1JDX1JORCIpID09IDApIAorICAgICAgICAgICAgICAgICAgICAgICAgcGt0X2Rldi0+ZmxhZ3MgfD0gRl9JUFNSQ19STkQ7CisgICAgICAgICAgICAgICAgCisgICAgICAgICAgICAgICAgZWxzZSBpZiAoc3RyY21wKGYsICIhSVBTUkNfUk5EIikgPT0gMCkgCisgICAgICAgICAgICAgICAgICAgICAgICBwa3RfZGV2LT5mbGFncyAmPSB+Rl9JUFNSQ19STkQ7CisgICAgICAgICAgICAgICAgCisgICAgICAgICAgICAgICAgZWxzZSBpZiAoc3RyY21wKGYsICJUWFNJWkVfUk5EIikgPT0gMCkgCisgICAgICAgICAgICAgICAgICAgICAgICBwa3RfZGV2LT5mbGFncyB8PSBGX1RYU0laRV9STkQ7CisgICAgICAgICAgICAgICAgCisgICAgICAgICAgICAgICAgZWxzZSBpZiAoc3RyY21wKGYsICIhVFhTSVpFX1JORCIpID09IDApIAorICAgICAgICAgICAgICAgICAgICAgICAgcGt0X2Rldi0+ZmxhZ3MgJj0gfkZfVFhTSVpFX1JORDsKKyAgICAgICAgICAgICAgICAKKyAgICAgICAgICAgICAgICBlbHNlIGlmIChzdHJjbXAoZiwgIklQRFNUX1JORCIpID09IDApIAorICAgICAgICAgICAgICAgICAgICAgICAgcGt0X2Rldi0+ZmxhZ3MgfD0gRl9JUERTVF9STkQ7CisgICAgICAgICAgICAgICAgCisgICAgICAgICAgICAgICAgZWxzZSBpZiAoc3RyY21wKGYsICIhSVBEU1RfUk5EIikgPT0gMCkgCisgICAgICAgICAgICAgICAgICAgICAgICBwa3RfZGV2LT5mbGFncyAmPSB+Rl9JUERTVF9STkQ7CisgICAgICAgICAgICAgICAgCisgICAgICAgICAgICAgICAgZWxzZSBpZiAoc3RyY21wKGYsICJVRFBTUkNfUk5EIikgPT0gMCkgCisgICAgICAgICAgICAgICAgICAgICAgICBwa3RfZGV2LT5mbGFncyB8PSBGX1VEUFNSQ19STkQ7CisgICAgICAgICAgICAgICAgCisgICAgICAgICAgICAgICAgZWxzZSBpZiAoc3RyY21wKGYsICIhVURQU1JDX1JORCIpID09IDApIAorICAgICAgICAgICAgICAgICAgICAgICAgcGt0X2Rldi0+ZmxhZ3MgJj0gfkZfVURQU1JDX1JORDsKKyAgICAgICAgICAgICAgICAKKyAgICAgICAgICAgICAgICBlbHNlIGlmIChzdHJjbXAoZiwgIlVEUERTVF9STkQiKSA9PSAwKSAKKyAgICAgICAgICAgICAgICAgICAgICAgIHBrdF9kZXYtPmZsYWdzIHw9IEZfVURQRFNUX1JORDsKKyAgICAgICAgICAgICAgICAKKyAgICAgICAgICAgICAgICBlbHNlIGlmIChzdHJjbXAoZiwgIiFVRFBEU1RfUk5EIikgPT0gMCkgCisgICAgICAgICAgICAgICAgICAgICAgICBwa3RfZGV2LT5mbGFncyAmPSB+Rl9VRFBEU1RfUk5EOworICAgICAgICAgICAgICAgIAorICAgICAgICAgICAgICAgIGVsc2UgaWYgKHN0cmNtcChmLCAiTUFDU1JDX1JORCIpID09IDApIAorICAgICAgICAgICAgICAgICAgICAgICAgcGt0X2Rldi0+ZmxhZ3MgfD0gRl9NQUNTUkNfUk5EOworICAgICAgICAgICAgICAgIAorICAgICAgICAgICAgICAgIGVsc2UgaWYgKHN0cmNtcChmLCAiIU1BQ1NSQ19STkQiKSA9PSAwKSAKKyAgICAgICAgICAgICAgICAgICAgICAgIHBrdF9kZXYtPmZsYWdzICY9IH5GX01BQ1NSQ19STkQ7CisgICAgICAgICAgICAgICAgCisgICAgICAgICAgICAgICAgZWxzZSBpZiAoc3RyY21wKGYsICJNQUNEU1RfUk5EIikgPT0gMCkgCisgICAgICAgICAgICAgICAgICAgICAgICBwa3RfZGV2LT5mbGFncyB8PSBGX01BQ0RTVF9STkQ7CisgICAgICAgICAgICAgICAgCisgICAgICAgICAgICAgICAgZWxzZSBpZiAoc3RyY21wKGYsICIhTUFDRFNUX1JORCIpID09IDApIAorICAgICAgICAgICAgICAgICAgICAgICAgcGt0X2Rldi0+ZmxhZ3MgJj0gfkZfTUFDRFNUX1JORDsKKyAgICAgICAgICAgICAgICAKKyAgICAgICAgICAgICAgICBlbHNlIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIHNwcmludGYocGdfcmVzdWx0LCAiRmxhZyAtOiVzOi0gdW5rbm93blxuQXZhaWxhYmxlIGZsYWdzLCAocHJlcGVuZCAhIHRvIHVuLXNldCBmbGFnKTpcbiVzIiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIklQU1JDX1JORCwgSVBEU1RfUk5ELCBUWFNJWkVfUk5ELCBVRFBTUkNfUk5ELCBVRFBEU1RfUk5ELCBNQUNTUkNfUk5ELCBNQUNEU1RfUk5EXG4iKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjb3VudDsKKyAgICAgICAgICAgICAgICB9CisJCXNwcmludGYocGdfcmVzdWx0LCAiT0s6IGZsYWdzPTB4JXgiLCBwa3RfZGV2LT5mbGFncyk7CisJCXJldHVybiBjb3VudDsKKwl9CisJaWYgKCFzdHJjbXAobmFtZSwgImRzdF9taW4iKSB8fCAhc3RyY21wKG5hbWUsICJkc3QiKSkgeworCQlsZW4gPSBzdHJuX2xlbigmdXNlcl9idWZmZXJbaV0sIHNpemVvZihwa3RfZGV2LT5kc3RfbWluKSAtIDEpOworICAgICAgICAgICAgICAgIGlmIChsZW4gPCAwKSB7IHJldHVybiBsZW47IH0KKworICAgICAgICAgICAgICAgIGlmIChjb3B5X2Zyb21fdXNlcihidWYsICZ1c2VyX2J1ZmZlcltpXSwgbGVuKSkKKwkJCXJldHVybiAtRUZBVUxUOworICAgICAgICAgICAgICAgIGJ1ZltsZW5dID0gMDsKKyAgICAgICAgICAgICAgICBpZiAoc3RyY21wKGJ1ZiwgcGt0X2Rldi0+ZHN0X21pbikgIT0gMCkgeworICAgICAgICAgICAgICAgICAgICAgICAgbWVtc2V0KHBrdF9kZXYtPmRzdF9taW4sIDAsIHNpemVvZihwa3RfZGV2LT5kc3RfbWluKSk7CisgICAgICAgICAgICAgICAgICAgICAgICBzdHJuY3B5KHBrdF9kZXYtPmRzdF9taW4sIGJ1ZiwgbGVuKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHBrdF9kZXYtPmRhZGRyX21pbiA9IGluX2F0b24ocGt0X2Rldi0+ZHN0X21pbik7CisgICAgICAgICAgICAgICAgICAgICAgICBwa3RfZGV2LT5jdXJfZGFkZHIgPSBwa3RfZGV2LT5kYWRkcl9taW47CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIGlmKGRlYnVnKQorICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnRrKCJwa3RnZW46IGRzdF9taW4gc2V0IHRvOiAlc1xuIiwgcGt0X2Rldi0+ZHN0X21pbik7CisgICAgICAgICAgICAgICAgaSArPSBsZW47CisJCXNwcmludGYocGdfcmVzdWx0LCAiT0s6IGRzdF9taW49JXMiLCBwa3RfZGV2LT5kc3RfbWluKTsKKwkJcmV0dXJuIGNvdW50OworCX0KKwlpZiAoIXN0cmNtcChuYW1lLCAiZHN0X21heCIpKSB7CisJCWxlbiA9IHN0cm5fbGVuKCZ1c2VyX2J1ZmZlcltpXSwgc2l6ZW9mKHBrdF9kZXYtPmRzdF9tYXgpIC0gMSk7CisgICAgICAgICAgICAgICAgaWYgKGxlbiA8IDApIHsgcmV0dXJuIGxlbjsgfQorCisgICAgICAgICAgICAgICAgaWYgKGNvcHlfZnJvbV91c2VyKGJ1ZiwgJnVzZXJfYnVmZmVyW2ldLCBsZW4pKQorCQkJcmV0dXJuIC1FRkFVTFQ7CisKKyAgICAgICAgICAgICAgICBidWZbbGVuXSA9IDA7CisgICAgICAgICAgICAgICAgaWYgKHN0cmNtcChidWYsIHBrdF9kZXYtPmRzdF9tYXgpICE9IDApIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIG1lbXNldChwa3RfZGV2LT5kc3RfbWF4LCAwLCBzaXplb2YocGt0X2Rldi0+ZHN0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gICAgICAgICAgICAgICBpZihkZWJ1ZykgCisJCQlwcmludGsoInBrdGdlbjogZHN0NiBzZXQgdG86ICVzXG4iLCBidWYpOworCisgICAgICAgICAgICAgICAgaSArPSBsZW47CisJCXNwcmludGYocGdfcmVzdWx0LCAiT0s6IGRzdDY9JXMiLCBidWYpOworCQlyZXR1cm4gY291bnQ7CisJfQorCWlmICghc3RyY21wKG5hbWUsICJkc3Q2X21pbiIpKSB7CisJCWxlbiA9IHN0cm5fbGVuKCZ1c2VyX2J1ZmZlcltpXSwgc2l6ZW9mKGJ1ZikgLSAxKTsKKyAgICAgICAgICAgICAgICBpZiAobGVuIDwgMCkgcmV0dXJuIGxlbjsgCisKKwkJcGt0X2Rldi0+ZmxhZ3MgfD0gRl9JUFY2OworCisgICAgICAgICAgICAgICAgaWYgKGNvcHlfZnJvbV91c2VyKGJ1ZiwgJnVzZXJfYnVmZmVyW2ldLCBsZW4pKQorCQkJcmV0dXJuIC1FRkFVTFQ7CisgICAgICAgICAgICAgICAgYnVmW2xlbl0gPSAwOworCisJCXNjYW5faXA2KGJ1ZiwgcGt0X2Rldi0+bWluX2luNl9kYWRkci5zNl9hZGRyKTsKKwkJZm10X2lwNihidWYsICBwa3RfZGV2LT5taW5faW42X2RhZGRyLnM2X2FkZHIpOworCisJCWlwdjZfYWRkcl9jb3B5KCZwa3RfZGV2LT5jdXJfaW42X2RhZGRyLCAmcGt0X2Rldi0+bWluX2luNl9kYWRkcik7CisgICAgICAgICAgICAgICAgaWYoZGVidWcpIAorCQkJcHJpbnRrKCJwa3RnZW46IGRzdDZfbWluIHNldCB0bzogJXNcbiIsIGJ1Zik7CisKKyAgICAgICAgICAgICAgICBpICs9IGxlbjsKKwkJc3ByaW50ZihwZ19yZXN1bHQsICJPSzogZHN0Nl9taW49JXMiLCBidWYpOworCQlyZXR1cm4gY291bnQ7CisJfQorCWlmICghc3RyY21wKG5hbWUsICJkc3Q2X21heCIpKSB7CisJCWxlbiA9IHN0cm5fbGVuKCZ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YoYnVmLCAgcGt0X2Rldi0+aW42X3NhZGRyLnM2X2FkZHIpOworCisJCWlwdjZfYWRkcl9jb3B5KCZwa3RfZGV2LT5jdXJfaW42X3NhZGRyLCAmcGt0X2Rldi0+aW42X3NhZGRyKTsKKworICAgICAgICAgICAgICAgIGlmKGRlYnVnKSAKKwkJCXByaW50aygicGt0Z2VuOiBzcmM2IHNldCB0bzogJXNcbiIsIGJ1Zik7CisJCQorICAgICAgICAgICAgICAgIGkgKz0gbGVuOworCQlzcHJpbnRmKHBnX3Jlc3VsdCwgIk9LOiBzcmM2PSVzIiwgYnVmKTsKKwkJcmV0dXJuIGNvdW50OworCX0KKwlpZiAoIXN0cmNtcChuYW1lLCAic3JjX21pbiIpKSB7CisJCWxlbiA9IHN0cm5fbGVuKCZ1c2VyX2J1ZmZlcltpXSwgc2l6ZW9mKHBrdF9kZXYtPnNyY19taW4pIC0gMSk7CisgICAgICAgICAgICAgICAgaWYgKGxlbiA8IDApIHsgcmV0dXJuIGxlbjsgfQorICAgICAgICAgICAgICAgIGlmIChjb3B5X2Zyb21fdXNlcihidWYsICZ1c2VyX2J1ZmZlcltpXSwgbGVuKSkKKwkJCXJldHVybiAtRUZBVUxUOworICAgICAgICAgICAgICAgIGJ1ZltsZW5dID0gMDsKKyAgICAgICAgICAgICAgICBpZiAoc3RyY21wKGJ1ZiwgcGt0X2Rldi0+c3JjX21pbikgIT0gMCkgeworICAgICAgICAgICAgICAgICAgICAgICAgbWVtc2V0KHBrdF9kZXYtPnNyY19taW4sIDAsIHNpemVvZihwa3RfZGV2LT5zcmNfbWluKSk7CisgICAgICAgICAgICAgICAgICAgICAgICBzdHJuY3B5KHBrdF9kZXYtPnNyY19taW4sIGJ1ZiwgbGVuKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHBrdF9kZXYtPnNhZGRyX21pbiA9IGluX2F0b24ocGt0X2Rldi0+c3JjX21pbik7CisgICAgICAgICAgICAgICAgICAgICAgICBwa3RfZGV2LT5jdXJfc2FkZHIgPSBwa3RfZGV2LT5zYWRkcl9taW47CisgICAgICAgICAgICAgICAgfQorCQlpZihkZWJ1ZykKKwkJCXByaW50aygicGt0Z2VuOiBzcmNfbWluIHNldCB0bzogJXNcbiIsIHBrdF9kZXYtPnNyY19taW4pOworCQlpICs9IGxlbjsKKwkJc3ByaW50ZihwZ19yZXN1bHQsICJPSzogc3JjX21pbj0lcyIsIHBrdF9kZXYtPnNyY19taW4pOworCQlyZXR1cm4gY291bnQ7CisJfQorCWlmICghc3RyY21wKG5hbWUsICJzcmNfbWF4IikpIHsKKwkJbGVuID0gc3Rybl9sZW4oJnVzZXJfYnVmZmVyW2ldLCBzaXplb2YocGt0X2Rldi0+c3JjX21heCkgLSAxKTsKKyAgICAgICAgICAgICAgICBpZiAobGVuIDwgMCkgeyByZXR1cm4gbGVuOyB9CisgICAgICAgICAgICAgICAgaWYgKGNvcHlfZnJvbV91c2VyKGJ1ZiwgJnVzZXJfYnVmZmVyW2ldLCBsZW4pKQorCQkJcmV0dXJuIC1FRkFVTFQ7CisgICAgICAgICAgICAgICAgYnVmW2xlbl0gPSAwOworICAgICAgICAgICAgICAgIGlmIChzdHJjbXAoYnVmLCBwa3RfZGV2LT5zcmNfbWF4KSAhPSAwKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBtZW1zZXQocGt0X2Rldi0+c3JjX21heCwgMCwgc2l6ZW9mKHBrdF9kZXYtPnNyY19tYXgpKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHN0cm5jcHkocGt0X2Rldi0+c3JjX21heCwgYnVmLCBsZW4pOworICAgICAgICAgICAgICAgICAgICAgICAgcGt0X2Rldi0+c2FkZHJfbWF4ID0gaW5fYXRvbihwa3RfZGV2LT5zcmNfbWF4KTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHBrdF9kZXYtPmN1cl9zYWRkciA9IHBrdF9kZXYtPnNhZGRyX21heDsKKyAgICAgICAgICAgICAgICB9CisJCWlmKGRlYnVnKQorCQkJcHJpbnR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AgICAgIGlmIChsZW4gPCAwKSB7IHJldHVybiBsZW47IH0KKwkJaSArPSBsZW47CisJCXBrdF9kZXYtPmxmbG93ID0gdmFsdWU7CisJCXNwcmludGYocGdfcmVzdWx0LCAiT0s6IGZsb3dsZW49JXUiLCBwa3RfZGV2LT5sZmxvdyk7CisJCXJldHVybiBjb3VudDsKKwl9CisgICAgICAgIAorCXNwcmludGYocGt0X2Rldi0+cmVzdWx0LCAiTm8gc3VjaCBwYXJhbWV0ZXIgXCIlc1wiIiwgbmFtZSk7CisJcmV0dXJuIC1FSU5WQUw7Cit9CisKK3N0YXRpYyBpbnQgcHJvY190aHJlYWRfcmVhZChjaGFyICpidWYgLCBjaGFyICoqc3RhcnQsIG9mZl90IG9mZnNldCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnQgbGVuLCBpbnQgKmVvZiwgdm9pZCAqZGF0YSkKK3sKKwljaGFyICpwOworICAgICAgICBzdHJ1Y3QgcGt0Z2VuX3RocmVhZCAqdCA9IChzdHJ1Y3QgcGt0Z2VuX3RocmVhZCopKGRhdGEpOworICAgICAgICBzdHJ1Y3QgcGt0Z2VuX2RldiAqcGt0X2RldiA9IE5VTEw7CisKKworICAgICAgICBpZiAoIXQpIHsKKyAgICAgICAgICAgICAgICBwcmludGsoInBrdGdlbjogRVJST1I6IGNvdWxkIG5vdCBmaW5kIHRocmVhZCBpbiBwcm9jX3RocmVhZF9yZWFkXG4iKTsKKyAgICAgICAgICAgICAgICByZXR1cm4gLUVJTlZBTDsKKyAgICAgICAgfQorCisJcCA9IGJ1ZjsKKwlwICs9IHNwcmludGYocCwgIk5hbWU6ICVzICBtYXhfYmVmb3JlX3NvZnRpcnE6ICVkXG4iLAorICAgICAgICAgICAgICAgICAgICAgdC0+bmFtZSwgdC0+bWF4X2JlZm9yZV9zb2Z0aXJxKTsKKworICAgICAgICBwICs9IHNwcmludGYocCwgIlJ1bm5pbmc6ICIpOworICAgICAgICAKKyAgICAgICAgaWZfbG9j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ICghc3RyY21wKG5hbWUsICJhZGRfZGV2aWNlIikpIHsKKyAgICAgICAgICAgICAgICBjaGFyIGZbMzJdOworICAgICAgICAgICAgICAgIG1lbXNldChmLCAwLCAzMik7CisJCWxlbiA9IHN0cm5fbGVuKCZ1c2VyX2J1ZmZlcltpXSwgc2l6ZW9mKGYpIC0gMSk7CisgICAgICAgICAgICAgICAgaWYgKGxlbiA8IDApIHsgCisJCQlyZXQgPSBsZW47IAorCQkJZ290byBvdXQ7CisJCX0KKwkJaWYoIGNvcHlfZnJvbV91c2VyKGYsICZ1c2VyX2J1ZmZlcltpXSwgbGVuKSApCisJCQlyZXR1cm4gLUVGQVVMVDsKKwkJaSArPSBsZW47CisJCXRocmVhZF9sb2NrKCk7CisgICAgICAgICAgICAgICAgcGt0Z2VuX2FkZF9kZXZpY2UodCwgZik7CisJCXRocmVhZF91bmxvY2soKTsKKyAgICAgICAgICAgICAgICByZXQgPSBjb3VudDsKKyAgICAgICAgICAgICAgICBzcHJpbnRmKHBnX3Jlc3VsdCwgIk9LOiBhZGRfZGV2aWNlPSVzIiwgZik7CisJCWdvdG8gb3V0OworCX0KKworICAgICAgICBpZiAoIXN0cmNtcChuYW1lLCAicmVtX2RldmljZV9hbGwiKSkgeworCQl0aHJlYWRfbG9jaygpOworCQl0LT5jb250cm9sIHw9IFRfUkVNREVWOworCQl0aHJlYWRfdW5sb2NrKCk7CisJCWN1cnJlbnQtPnN0YXRlID0gVEFTS19JTlRFUlJVUFRJQkxFOworCQlzY2hlZHVsZV90aW1lb3V0KEhaLzgpOyAgLyogUHJvcGFnYXRlIHRocmVhZC0+Y29udHJvbCAgKi8KKwkJcmV0ID0gY291bnQ7CisgICAgICAgICAgICAgICAgc3ByaW50ZihwZ19yZXN1bHQsICJPSzogcmVtX2RldmljZV9hbGwiKTsKKwkJZ290byBvdXQ7CisJfQorCisgICAgICAgIGlmICghc3RyY21wKG5hbWUsICJtYXhfYmVmb3JlX3NvZnRpcnEiKSkgeworICAgICAgICAgICAgICAgIGxlbiA9IG51bV9hcmcoJnVzZXJfYnVmZmVyW2ldLCAxMCwgJnZhbHVlKTsKKwkJdGhyZWFkX2xvY2soKTsKKyAgICAgICAgICAgICAgICB0LT5tYXhfYmVmb3JlX3NvZnRpcnEgPSB2YWx1ZTsKKwkJdGhyZWFkX3VubG9jaygpOworICAgICAgICAgICAgICAgIHJldCA9IGNvdW50OworICAgICAgICAgICAgICAgIHNwcmludGYocGdfcmVzdWx0LCAiT0s6IG1heF9iZWZvcmVfc29mdGlycT0lbHUiLCB2YWx1ZSk7CisJCWdvdG8gb3V0OworCX0KKworCXJldCA9IC1FSU5WQUw7Cisgb3V0OgorCisJcmV0dXJuIHJldDsKK30KKworc3RhdGljIGludCBjcmVhdGVfcHJvY19kaXIodm9pZCkKK3sKKyAgICAgICAgaW50ICAgICBsZW47CisgICAgICAgIC8qICBkb2VzIHByb2NfZGlyIGFscmVhZHkgZXhpc3RzICovCisgICAgICAgIGxlbiA9IHN0cmxlbihQR19QUk9DX0RJUik7CisKKyAgICAgICAgZm9yIChwZ19wcm9jX2RpciA9IHByb2NfbmV0LT5zdWJkaXI7IHBnX3Byb2NfZGlyOyBwZ19wcm9jX2Rpcj1wZ19wcm9jX2Rpci0+bmV4dCkgeworICAgICAgICAgICAgICAgIGlmICgocGdfcHJvY19kaXItPm5hbWVsZW4gPT0gbGVuKSAmJgorCQkgICAgKCEgbWVtY21wKHBnX3Byb2NfZGlyLT5uYW1lLCBQR19QUk9DX0RJUiwgbGVuKSkpIAorICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIH0KKyAgICAgICAgCisgICAgICAgIGlmICghcGdfcHJvY19kaXIpIAorICAgICAgICAgICAgICAgIHBnX3Byb2NfZGlyID0gY3JlYXRlX3Byb2NfZW50cnkoUEdfUFJPQ19ESVIsIFNfSUZESVIsIHByb2NfbmV0KTsKKyAgICAgICAgCisgICAgICAgIGlmICghcGdfcHJvY19kaXIpIAorICAgICAgICAgICAgIC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9kZXYpIAorICAgICAgICAgICAgICAgIHBrdGdlbl9zZXR1cF9kZXYocGt0X2Rldik7CisgICAgICAgIAorICAgICAgICBpZiAoIXBrdF9kZXYtPm9kZXYpIHsKKyAgICAgICAgICAgICAgICBwcmludGsoInBrdGdlbjogRVJST1I6IHBrdF9kZXYtPm9kZXYgPT0gTlVMTCBpbiBzZXR1cF9pbmplY3QuXG4iKTsKKyAgICAgICAgICAgICAgICBzcHJpbnRmKHBrdF9kZXYtPnJlc3VsdCwgIkVSUk9SOiBwa3RfZGV2LT5vZGV2ID09IE5VTEwgaW4gc2V0dXBfaW5qZWN0LlxuIik7CisgICAgICAgICAgICAgICAgcmV0dXJuOworICAgICAgICB9CisgICAgICAgIAorICAgICAgICAvKiBEZWZhdWx0IHRvIHRoZSBpbnRlcmZhY2UncyBtYWMgaWYgbm90IGV4cGxpY2l0bHkgc2V0LiAqLworCisJaWYgKChwa3RfZGV2LT5zcmNfbWFjWzBdID09IDApICYmIAorCSAgICAocGt0X2Rldi0+c3JjX21hY1sxXSA9PSAwKSAmJiAKKwkgICAgKHBrdF9kZXYtPnNyY19tYWNbMl0gPT0gMCkgJiYgCisJICAgIChwa3RfZGV2LT5zcmNfbWFjWzNdID09IDApICYmIAorCSAgICAocGt0X2Rldi0+c3JjX21hY1s0XSA9PSAwKSAmJiAKKwkgICAgKHBrdF9kZXYtPnNyY19tYWNbNV0gPT0gMCkpIHsKKworCSAgICAgICBtZW1jcHkoJihwa3RfZGV2LT5oaFs2XSksIHBrdF9kZXYtPm9kZXYtPmRldl9hZGRyLCA2KTsKKyAgICAgICB9CisgICAgICAgIC8qIFNldCB1cCBEZXN0IE1BQyAqLworICAgICAgICBtZW1jcHkoJihwa3RfZGV2LT5oaFswXSksIHBrdF9kZXYtPmRzdF9tYWMsIDYpOworCisgICAgICAgIC8qIFNldCB1cCBwa3Qgc2l6ZSAqLworICAgICAgICBwa3RfZGV2LT5jdXJfcGt0X3NpemUgPSBwa3RfZGV2LT5taW5fcG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ICAgICAgICAgICAgICAgIGVsc2UgeworICAgICAgICAgICAgICAgICAgICAgICAgbWMgPSBwa3RfZGV2LT5jdXJfc3JjX21hY19vZmZzZXQrKzsKKyAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwa3RfZGV2LT5jdXJfc3JjX21hY19vZmZzZXQgPiBwa3RfZGV2LT5zcmNfbWFjX2NvdW50KSAKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGt0X2Rldi0+Y3VyX3NyY19tYWNfb2Zmc2V0ID0gMDsKKyAgICAgICAgICAgICAgICB9CisKKyAgICAgICAgICAgICAgICB0bXAgPSBwa3RfZGV2LT5zcmNfbWFjWzVdICsgKG1jICYgMHhGRik7CisgICAgICAgICAgICAgICAgcGt0X2Rldi0+aGhbMTFdID0gdG1wOworICAgICAgICAgICAgICAgIHRtcCA9IChwa3RfZGV2LT5zcmNfbWFjWzRdICsgKChtYyA+PiA4KSAmIDB4RkYpICsgKHRtcCA+PiA4KSk7CisgICAgICAgICAgICAgICAgcGt0X2Rldi0+aGhbMTBdID0gdG1wOworICAgICAgICAgICAgICAgIHRtcCA9IChwa3RfZGV2LT5zcmNfbWFjWzNdICsgKChtYyA+PiAxNikgJiAweEZGKSArICh0bXAgPj4gOCkpOworICAgICAgICAgICAgICAgIHBrdF9kZXYtPmhoWzldID0gdG1wOworICAgICAgICAgICAgICAgIHRtcCA9IChwa3RfZGV2LT5zcmNfbWFjWzJdICsgKChtYyA+PiAyNCkgJiAweEZGKSArICh0bXAgPj4gOCkpOworICAgICAgICAgICAgICAgIHBrdF9kZXYtPmhoWzhdID0gdG1wOworICAgICAgICAgICAgICAgIHRtcCA9IChwa3RfZGV2LT5zcmNfbWFjWzFdICsgKHRtcCA+PiA4KSk7CisgICAgICAgICAgICAgICAgcGt0X2Rldi0+aGhbN10gPSB0bXA7ICAgICAgICAKKyAgICAgICAgfQorCisgICAgICAgIC8qICBEZWFsIHdpdGggRGVzdGluYXRpb24gTUFDICovCisgICAgICAgIGlmIChwa3RfZGV2LT5kc3RfbWFjX2NvdW50ID4gMSkgeworICAgICAgICAgICAgICAgIF9fdTMyIG1jOworICAgICAgICAgICAgICAgIF9fdTMyIHRtcDsKKworICAgICAgICAgICAgICAgIGlmIChwa3RfZGV2LT5mbGFncyAmIEZfTUFDRFNUX1JORCkgCisgICAgICAgICAgICAgICAgICAgICAgICBtYyA9IHBrdGdlbl9yYW5kb20oKSAlIChwa3RfZGV2LT5kc3RfbWFjX2NvdW50KTsKKworICAgICAgICAgICAgICAgIGVsc2UgeworICAgICAgICAgICAgICAgICAgICAgICAgbWMgPSBwa3RfZGV2LT5jdXJfZHN0X21hY19vZmZzZXQrKzsKKyAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwa3RfZGV2LT5jdXJfZHN0X21hY19vZmZzZXQgPiBwa3RfZGV2LT5kc3RfbWFjX2NvdW50KSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBrdF9kZXYtPmN1cl9kc3RfbWFjX29mZnNldCA9IDA7CisgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgfQorCisgICAgICAgICAgICAgICAgdG1wID0gcGt0X2Rldi0+ZHN0X21hY1s1XSArIChtYyAmIDB4RkYpOworICAgICAgICAgICAgICAgIHBrdF9kZXYtPmhoWzVdID0gdG1wOworICAgICAgICAgICAgICAgIHRtcCA9IChwa3RfZGV2LT5kc3RfbWFjWzRdICsgKChtYyA+PiA4KSAmIDB4RkYpICsgKHRtcCA+PiA4KSk7CisgICAgICAgICAgICAgICAgcGt0X2Rldi0+aGhbNF0gPSB0bXA7CisgICAgICAgICAgICAgICAgdG1wID0gKHBrdF9kZXYtPmRzdF9tYWNbM10gKyAoKG1jID4+IDE2KSAmIDB4RkYpICsgKHRtcCA+PiA4KSk7CisgICAgICAgICAgICAgICAgcGt0X2Rldi0+aGhbM10gPSB0bXA7CisgICAgICAgICAgICAgICAgdG1wID0gKHBrdF9kZXYtPmRzdF9tYWNbMl0gKyAoKG1jID4+IDI0KSAmIDB4RkYpICsgKHRtcCA+PiA4KSk7CisgICAgICAgICAgICAgICAgcGt0X2Rldi0+aGhbMl0gPSB0bXA7CisgICAgICAgICAgICAgICAgdG1wID0gKHBrdF9kZXYtPmRzdF9tYWNbMV0gKyAodG1wID4+IDgpKTsKKyAgICAgICAgICAgICAgICBwa3RfZGV2LT5oaFsxXSA9IHRtcDsgICAgICAgIAorICAgICAgICB9CisKKyAgICAgICAgaWYgKHBrdF9kZXYtPnVkcF9zcmNfbWluIDwgcGt0X2Rldi0+dWRwX3NyY19tYXgpIHsKKyAgICAgICAgICAgICAgICBpZiAocGt0X2Rldi0+ZmxhZ3MgJiBGX1VEUFNSQ19STkQpIAorICAgICAgICAgICAgICAgICAgICAgICAgcGt0X2Rldi0+Y3VyX3VkcF9zcmMgPSAoKHBrdGdlbl9yYW5kb20oKSAlIChwa3RfZGV2LT51ZHBfc3JjX21heCAtIHBrdF9kZXYtPnVkcF9zcmNfbWluKSkgKyBwa3RfZGV2LT51ZHBfc3JjX21pbik7CisKKyAgICAgICAgICAgICAgICBlbHNlIHsKKwkJCXBrdF9kZXYtPmN1cl91ZHBfc3JjKys7CisJCQlpZiAocGt0X2Rldi0+Y3VyX3VkcF9zcmMgPj0gcGt0X2Rldi0+dWRwX3NyY19tYXgpCisJCQkJcGt0X2Rldi0+Y3VyX3VkcF9zcmMgPSBwa3RfZGV2LT51ZHBfc3JjX21pbjsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgIH0KKworICAgICAgICBpZiAocGt0X2Rldi0+dWRwX2RzdF9taW4gPCBwa3RfZGV2LT51ZHBfZHN0X21heCkgeworICAgICAgICAgICAgICAgIGlmIChwa3RfZGV2LT5mbGFncyAmIEZfVURQRFNUX1JORCkgeworICAgICAgICAgICAgICAgICAgICAgICAgcGt0X2Rldi0+Y3VyX3VkcF9kc3QgPSAoKHBrdGdlbl9yYW5kb20oKSAlIChwa3RfZGV2LT51ZHBfZHN0X21heCAtIHBr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ZXYtPm1pbl9pbjZfZGFkZHIuczZfYWRkcjMyWzNdID09IDApOworCQllbHNlIHsKKwkJCWludCBpOworCisJCQkvKiBPbmx5IHJhbmRvbSBkZXN0aW5hdGlvbnMgeWV0ICovCisKKwkJCWZvcihpPTA7IGkgPCA0OyBpKyspIHsKKwkJCQlwa3RfZGV2LT5jdXJfaW42X2RhZGRyLnM2X2FkZHIzMltpXSA9CisJCQkJCSgocGt0Z2VuX3JhbmRvbSgpIHwKKwkJCQkJICBwa3RfZGV2LT5taW5faW42X2RhZGRyLnM2X2FkZHIzMltpXSkgJgorCQkJCQkgcGt0X2Rldi0+bWF4X2luNl9kYWRkci5zNl9hZGRyMzJbaV0pOworCQkJfQorIAkJfQorCX0KKworICAgICAgICBpZiAocGt0X2Rldi0+bWluX3BrdF9zaXplIDwgcGt0X2Rldi0+bWF4X3BrdF9zaXplKSB7CisgICAgICAgICAgICAgICAgX191MzIgdDsKKyAgICAgICAgICAgICAgICBpZiAocGt0X2Rldi0+ZmxhZ3MgJiBGX1RYU0laRV9STkQpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIHQgPSAoKHBrdGdlbl9yYW5kb20oKSAlIChwa3RfZGV2LT5tYXhfcGt0X3NpemUgLSBwa3RfZGV2LT5taW5fcGt0X3NpemUpKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICArIHBrdF9kZXYtPm1pbl9wa3Rfc2l6ZSk7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIGVsc2UgeworCQkJdCA9IHBrdF9kZXYtPmN1cl9wa3Rfc2l6ZSArIDE7CisJCQlpZiAodCA+IHBrdF9kZXYtPm1heF9wa3Rfc2l6ZSkgCisJCQkJdCA9IHBrdF9kZXYtPm1pbl9wa3Rfc2l6ZTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgcGt0X2Rldi0+Y3VyX3BrdF9zaXplID0gdDsKKyAgICAgICAgfQorCisJcGt0X2Rldi0+Zmxvd3NbZmxv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HBhY2tldHMgdG9vID8gKi8KKyAgICAgICAgaWYgKHBnaCkgeworICAgICAgICAgICAgICBzdHJ1Y3QgdGltZXZhbCB0aW1lc3RhbXA7CisJICAgICAgCisJICAgICAgcGdoLT5wZ2hfbWFnaWMgPSBodG9ubChQS1RHRU5fTUFHSUMpOworCSAgICAgIHBnaC0+c2VxX251bSAgID0gaHRvbmwocGt0X2Rldi0+c2VxX251bSk7CisJICAgICAgCisJICAgICAgZG9fZ2V0dGltZW9mZGF5KCZ0aW1lc3RhbXApOworCSAgICAgIHBnaC0+dHZfc2VjICAgID0gaHRvbmwodGltZXN0YW1wLnR2X3NlYyk7CisJICAgICAgcGdoLT50dl91c2VjICAgPSBodG9ubCh0aW1lc3RhbXAudHZfdXNlYyk7CisgICAgICAgIH0KKyAgICAgICAgcGt0X2Rldi0+c2VxX251bSsrOworICAgICAgICAKKwlyZXR1cm4gc2tiOworfQorCitzdGF0aWMgaW5saW5lIHN0cnVjdCBza19idWZmICpmaWxsX3BhY2tldChzdHJ1Y3QgbmV0X2RldmljZSAqb2RldiwgCisJCQkJICAgc3RydWN0IHBrdGdlbl9kZXYgKnBrdF9kZXYpCit7CisJaWYocGt0X2Rldi0+ZmxhZ3MgJiBGX0lQVjYpIAorCQlyZXR1cm4gZmlsbF9wYWNrZXRfaXB2NihvZGV2LCBwa3RfZGV2KTsKKwllbHNlCisJCXJldHVybiBmaWxsX3BhY2tldF9pcHY0KG9kZXYsIHBrdF9kZXYpOworfQorCitzdGF0aWMgdm9pZCBwa3RnZW5fY2xlYXJfY291bnRlcnMoc3RydWN0IHBrdGdlbl9kZXYgKnBrdF9kZXYpIAoreworICAgICAgICBwa3RfZGV2LT5zZXFfbnVtID0gMTsKKyAgICAgICAgcGt0X2Rldi0+aWRsZV9hY2MgPSAwOworCXBrdF9kZXYtPnNvZmFyID0gMDsKKyAgICAgICAgcGt0X2Rldi0+dHhfYnl0ZXMgPSAwOworICAgICAgICBwa3RfZGV2LT5lcnJvcnMgPSAw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mxvY2sodCk7CisJaWYoc3RhcnRlZCkgdC0+Y29udHJvbCAmPSB+KFRfU1RPUCk7Cit9CisKK3N0YXRpYyB2b2lkIHBrdGdlbl9zdG9wX2FsbF90aHJlYWRzX2lmcyh2b2lkKQoreworICAgICAgICBzdHJ1Y3QgcGt0Z2VuX3RocmVhZCAqdCA9IHBrdGdlbl90aHJlYWRzOworCisJUEdfREVCVUcocHJpbnRrKCJwa3RnZW46IGVudGVyaW5nIHBrdGdlbl9zdG9wX2FsbF90aHJlYWRzLlxuIikpOworCisJdGhyZWFkX2xvY2soKTsKKwl3aGlsZSh0KSB7CisJCXBrdGdlbl9zdG9wKHQpOworCQl0ID0gdC0+bmV4dDsKKwl9CisgICAgICAgdGhyZWFkX3VubG9jaygpOworfQorCitzdGF0aWMgaW50IHRocmVhZF9pc19ydW5uaW5nKHN0cnVjdCBwa3RnZW5fdGhyZWFkICp0ICkKK3sKKyAgICAgICAgc3RydWN0IHBrdGdlbl9kZXYgKm5leHQ7CisgICAgICAgIGludCByZXMgPSAwOworCisgICAgICAgIGZvcihuZXh0PXQtPmlmX2xpc3Q7IG5leHQ7IG5leHQ9bmV4dC0+bmV4dCkgeyAKKwkJaWYobmV4dC0+cnVubmluZykgeworCQkJcmVzID0gMTsKKwkJCWJyZWFrOworCQl9CisgICAgICAgIH0KKyAgICAgICAgcmV0dXJuIHJlczsKK30KKworc3RhdGljIGludCBwa3RnZW5fd2FpdF90aHJlYWRfcnVuKHN0cnVjdCBwa3RnZW5fdGhyZWFkICp0ICkKK3sKKyAgICAgICAgaWZfbG9jayh0KTsKKworICAgICAgICB3aGlsZSh0aHJlYWRfaXNfcnVubmluZyh0KSkgeworCisgICAgICAgICAgICAgICAgaWZfdW5sb2NrKHQpOworCisJCW1zbGVlcF9pbnRlcnJ1cHRpYmxlKDEwMCk7IAorCisgICAgICAgICAgICAgICAgaWYgKHNpZ25hbF9wZW5kaW5nKGN1cnJlbnQpKSAKKyAgICAgICAgICAgICAgICAgICAgICAgIGdvdG8gc2lnbmFsOworICAgICAgICAgICAgICAgIGlmX2xvY2sodCk7CisgICAgICAgIH0KKyAgICAgICAgaWZfdW5sb2NrKHQpOworICAgICAgICByZXR1cm4gMTsKKyBzaWduYWw6CisgICAgICAgIHJldHVybiAwOworfQorCitzdGF0aWMgaW50IHBrdGdlbl93YWl0X2FsbF90aHJlYWRzX3J1bih2b2lkKQoreworCXN0cnVjdCBwa3RnZW5fdGhyZWFkICp0ID0gcGt0Z2VuX3RocmVhZHM7CisJaW50IHNpZyA9IDE7CisJCisJd2hpbGUgKHQpIHsKKwkJc2lnID0gcGt0Z2VuX3dhaXRfdGhyZWFkX3J1bih0KTsKKwkJaWYoIHNpZyA9PSAwICkgYnJlYWs7CisJCXRocmVhZF9sb2NrKCk7CisJCXQ9dC0+bmV4dDsKKwkJdGhyZWFkX3VubG9jaygpOworCX0KKwlpZihzaWcgPT0gMCkgeworCQl0aHJlYWRfbG9jaygpOworCQl3aGlsZSAodCkgeworCQkJdC0+Y29udHJvbCB8PSAoVF9TVE9QKTsKKwkJCXQ9dC0+bmV4dDsKKwkJfQorCQl0aHJlYWRfdW5sb2NrKCk7CisJfQorCXJldHVybiBzaWc7Cit9CisKK3N0YXRpYyB2b2lkIHBrdGdlbl9ydW5fYWxsX3RocmVhZHModm9pZCkKK3sKKyAgICAgICAgc3RydWN0IHBrdGdlbl90aHJlYWQgKnQgPSBwa3RnZW5fdGhyZWFkczsKKworCVBHX0RFQlVHKHByaW50aygicGt0Z2VuOiBlbnRlcmluZyBwa3RnZW5fcnVuX2FsbF90aHJlYWRzLlxuIikpOworCisJdGhyZWFkX2xvY2soKTsKKworCXdoaWxlKHQpIHsKKwkJdC0+Y29udHJvbCB8PSAoVF9SVU4pOworCQl0ID0gdC0+bmV4dDsKKwl9CisJdGhyZWFkX3VubG9jaygpOworCisJY3VycmVudC0+c3RhdGUgPSBUQVNLX0lOVEVSUlVQVElCTEU7CisJc2NoZWR1bGVfdGltZW91dChIWi84KTsgIC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gICAgICAKKyAgICAgICBicHMgPSBwcHMgKiA4ICogcGt0X2Rldi0+Y3VyX3BrdF9zaXplOworCisgICAgICAgbWJwcyA9IGJwczsKKyAgICAgICBkb19kaXYobWJwcywgMTAwMDAwMCk7CisgICAgICAgcCArPSBzcHJpbnRmKHAsICIgICVsbHVwcHMgJWxsdU1iL3NlYyAoJWxsdWJwcykgZXJyb3JzOiAlbGx1IiwKKyAgICAgICAgICAgICAgICAgICAgKHVuc2lnbmVkIGxvbmcgbG9uZykgcHBzLCAKKwkJICAgICh1bnNpZ25lZCBsb25nIGxvbmcpIG1icHMsIAorCQkgICAgKHVuc2lnbmVkIGxvbmcgbG9uZykgYnBzLCAKKwkJICAgICh1bnNpZ25lZCBsb25nIGxvbmcpIHBrdF9kZXYtPmVycm9ycyk7Cit9CisgCisKKy8qIFNldCBzdG9wcGVkLWF0IHRpbWVyLCByZW1vdmUgZnJvbSBydW5uaW5nIGxpc3QsIGRvIGNvdW50ZXJzICYgc3RhdGlzdGljcyAqLworCitzdGF0aWMgaW50IHBrdGdlbl9zdG9wX2RldmljZShzdHJ1Y3QgcGt0Z2VuX2RldiAqcGt0X2RldikgCit7CisJCisgICAgICAgIGlmICghcGt0X2Rldi0+cnVubmluZykgeworICAgICAgICAgICAgICAgIHByaW50aygicGt0Z2VuOiBpbnRlcmZhY2U6ICVzIGlzIGFscmVhZHkgc3RvcHBlZFxuIiwgcGt0X2Rldi0+aWZuYW1lKTsKKyAgICAgICAgICAgICAgICByZXR1cm4gLUVJTlZBTDsKKyAgICAgICAgfQorCisgICAgICAgIHBrdF9kZXYtPnN0b3BwZWRfYXQgPSBnZXRDdXJVcygpOworICAgICAgICBwa3RfZGV2LT5ydW5uaW5nID0gMDsKKworCXNob3dfcmVzdWx0cyhwa3RfZGV2LCBza2Jfc2hpbmZvKHBrdF9kZXYtPnNrYiktPm5yX2ZyYWdzKTsKKworCWlmIChwa3RfZGV2LT5za2IpIAorCQlrZnJlZV9za2IocGt0X2Rldi0+c2tiKTsKKworCXBrdF9kZXYtPnNrYiA9IE5VTEw7CisJCisgICAgICAgIHJldHVybiAwOworfQorCitzdGF0aWMgc3RydWN0IHBrdGdlbl9kZXYgKm5leHRfdG9fcnVuKHN0cnVjdCBwa3RnZW5fdGhyZWFkICp0ICkKK3sKKwlzdHJ1Y3QgcGt0Z2VuX2RldiAqbmV4dCwgKmJlc3QgPSBOVUxMOworICAgICAgICAKKwlpZl9sb2NrKHQpOworCisJZm9yKG5leHQ9dC0+aWZfbGlzdDsgbmV4dCA7IG5leHQ9bmV4dC0+bmV4dCkgeworCQlpZighbmV4dC0+cnVubmluZykgY29udGludWU7CisJCWlmKGJlc3QgPT0gTlVMTCkgYmVzdD1uZXh0OworCQllbHNlIGlmICggbmV4dC0+bmV4dF90eF91cyA8IGJlc3QtPm5leHRfdHhfdXMpIAorCQkJYmVzdCA9ICBuZXh0OworCX0KKwlpZl91bmxvY2sodCk7CisgICAgICAgIHJldHVybiBiZXN0OworfQorCitzdGF0aWMgdm9pZCBwa3RnZW5fc3RvcChzdHJ1Y3QgcGt0Z2VuX3RocmVhZCAqdCkgeworICAgICAgICBzdHJ1Y3QgcGt0Z2VuX2RldiAqbmV4dCA9IE5VTEw7CisKKwlQR19ERUJVRyhwcmludGsoInBrdGdlbjogZW50ZXJpbmcgcGt0Z2VuX3N0b3AuXG4iKSk7CisKKyAgICAgICAgaWZfbG9jayh0KTsKKworICAgICAgICBmb3IobmV4dD10LT5pZl9saXN0OyBuZXh0OyBuZXh0PW5leHQtPm5leHQpCisgICAgICAgICAgICAgICAgcGt0Z2VuX3N0b3BfZGV2aWNlKG5leHQpOworCisgICAgICAgIGlmX3VubG9jayh0KTsKK30KKworc3RhdGljIHZvaWQgcGt0Z2VuX3JlbV9hbGxfaWZzKHN0cnVjdCBwa3RnZW5fdGhyZWFkICp0KSAKK3sKKyAgICAgICAgc3RydWN0IHBrdGdlbl9kZXYgKmN1ciwgKm5leHQgPSBOVUxMOworICAgICAgICAKKyAgICAg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Z0aXJxOworICAgICAgICB1MzIgdHhfc2luY2Vfc29mdGlycSA9IDA7CisKKwlkYWVtb25pemUoInBrdGdlbi8lZCIsIGNwdSk7CisKKyAgICAgICAgLyogQmxvY2sgYWxsIHNpZ25hbHMgZXhjZXB0IFNJR0tJTEwsIFNJR1NUT1AgYW5kIFNJR1RFUk0gKi8KKworICAgICAgICBzcGluX2xvY2tfaXJxKCZjdXJyZW50LT5zaWdoYW5kLT5zaWdsb2NrKTsKKyAgICAgICAgdG1wc2lnID0gY3VycmVudC0+YmxvY2tlZDsKKyAgICAgICAgc2lnaW5pdHNldGludigmY3VycmVudC0+YmxvY2tlZCwgCisgICAgICAgICAgICAgICAgICAgICAgc2lnbWFzayhTSUdLSUxMKSB8IAorICAgICAgICAgICAgICAgICAgICAgIHNpZ21hc2soU0lHU1RPUCl8IAorICAgICAgICAgICAgICAgICAgICAgIHNpZ21hc2soU0lHVEVSTSkpOworCisgICAgICAgIHJlY2FsY19zaWdwZW5kaW5nKCk7CisgICAgICAgIHNwaW5fdW5sb2NrX2lycSgmY3VycmVudC0+c2lnaGFuZC0+c2lnbG9jayk7CisKKwkvKiBNaWdyYXRlIHRvIHRoZSByaWdodCBDUFUgKi8KKwlzZXRfY3B1c19hbGxvd2VkKGN1cnJlbnQsIGNwdW1hc2tfb2ZfY3B1KGNwdSkpOworICAgICAgICBpZiAoc21wX3Byb2Nlc3Nvcl9pZCgpICE9IGNwdSkKKyAgICAgICAgICAgICAgICBCVUcoKTsKKworCWluaXRfd2FpdHF1ZXVlX2hlYWQoJnQtPnF1ZXVlKTsKKworCXQtPmNvbnRyb2wgJj0gfihUX1RFUk1JTkFURSk7CisJdC0+Y29udHJvbCAmPSB+KFRfUlVOKTsKKwl0LT5jb250cm9sICY9IH4oVF9TVE9QKTsKKwl0LT5jb250cm9sICY9IH4oVF9SRU1ERVYpOworCisgICAgICAgIHQtPnBpZCA9IGN1cnJlbnQtPnBpZDsgICAgICAgIAorCisgICAgICAgIFBHX0RFQ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PnF1ZXVlKSwgJndhaXQpOworCQl9CisKKyAgICAgICAgICAgICAgICAvKiAKKwkJICogQmFjayBmcm9tIHNsZWVwLCBlaXRoZXIgZHVlIHRvIHRoZSB0aW1lb3V0IG9yIHNpZ25hbC4KKwkJICogV2UgY2hlY2sgaWYgd2UgaGF2ZSBhbnkgInBvc3RlZCIgd29yayBmb3IgdXMuCisJCSAqLworCisgICAgICAgICAgICAgICAgaWYgKHQtPmNvbnRyb2wgJiBUX1RFUk1JTkFURSB8fCBzaWduYWxfcGVuZGluZyhjdXJyZW50KSkgCisgICAgICAgICAgICAgICAgICAgICAgICAvKiB3ZSByZWNlaXZlZCBhIHJlcXVlc3QgdG8gdGVybWluYXRlIG91cnNlbGYgKi8KKyAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOworCQkKKworCQlpZih0LT5jb250cm9sICYgVF9TVE9QKSB7CisJCQlwa3RnZW5fc3RvcCh0KTsKKwkJCXQtPmNvbnRyb2wgJj0gfihUX1NUT1ApOworCQl9CisKKwkJaWYodC0+Y29udHJvbCAmIFRfUlVOKSB7CisJCQlwa3RnZW5fcnVuKHQpOworCQkJdC0+Y29udHJvbCAmPSB+KFRfUlVOKTsKKwkJfQorCisJCWlmKHQtPmNvbnRyb2wgJiBUX1JFTURFVikgeworCQkJcGt0Z2VuX3JlbV9hbGxfaWZzKHQpOworCQkJdC0+Y29udHJvbCAmPSB+KFRfUkVNREVWKTsKKwkJfQorCisJCWlmIChuZWVkX3Jlc2NoZWQoKSkgCisJCQlzY2hlZHVsZSgpOworICAgICAgICB9IAorCisgICAgICAgIFBHX0RFQlVHKHByaW50aygicGt0Z2VuOiAlcyBzdG9wcGluZyBhbGwgZGV2aWNlXG4iLCB0LT5uYW1lKSk7CisgICAgICAgIHBrdGdlbl9zdG9wKHQpOworCisgICAgICAgIFBHX0RFQlVHKHByaW50aygicGt0Z2VuOiAlcyByZW1vdmluZyBhbGwgZGV2aWNlXG4iLCB0LT5uYW1lKSk7CisgICAgICAgIHBrdGdlbl9yZW1fYWxsX2lmcyh0KTsKKworICAgICAgICBQR19ERUJVRyhwcmludGsoInBrdGdlbjogJXMgcmVtb3ZpbmcgdGhyZWFkLlxuIiwgdC0+bmFtZSkpOworICAgICAgICBwa3RnZW5fcmVtX3RocmVhZCh0KTsKK30KKworc3RhdGljIHN0cnVjdCBwa3RnZW5fZGV2ICpwa3RnZW5fZmluZF9kZXYoc3RydWN0IHBrdGdlbl90aHJlYWQgKnQsIGNvbnN0IGNoYXIqIGlmbmFtZSkgCit7CisgICAgICAgIHN0cnVjdCBwa3RnZW5fZGV2ICpwa3RfZGV2ID0gTlVMTDsKKyAgICAgICAgaWZfbG9jayh0KTsKKworICAgICAgICBmb3IocGt0X2Rldj10LT5pZl9saXN0OyBwa3RfZGV2OyBwa3RfZGV2ID0gcGt0X2Rldi0+bmV4dCApIHsKKyAgICAgICAgICAgICAgICBpZiAoc3RyY21wKHBrdF9kZXYtPmlmbmFtZSwgaWZuYW1lKSA9PSAwKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgIH0KKworICAgICAgICBpZl91bmxvY2sodCk7CisJUEdfREVCVUcocHJpbnRrKCJwa3RnZW46IGZpbmRfZGV2KCVzKSByZXR1cm5pbmcgJXBcbiIsIGlmbmFtZSxwa3RfZGV2KSk7CisgICAgICAgIHJldHVybiBwa3RfZGV2OworfQorCisvKiAKKyAqIEFkZHMgYSBkZXYgYXQgZnJvbnQgb2YgaWZfbGlzdC4gCisgKi8KKworc3RhdGljIGludCBhZGRfZGV2X3RvX3RocmVhZChzdHJ1Y3QgcGt0Z2VuX3RocmVhZCAqdCwgc3RydWN0IHBrdGdlbl9kZXYgKnBrdF9kZXYpIAoreworCWludCBydiA9IDA7CisJCisgICAgICAgIGlmX2xvY2sodCk7CisKKyAgICAgICAgaWYgKHBrdF9kZXYtPnBnX3RocmVhZCkgeworICAgICAgICAgICAgICAgIHByaW50aygicGt0Z2V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GF0ZSkpOworCQlpZiAocGt0X2Rldi0+Zmxvd3MgPT0gTlVMTCkgeworCQkJa2ZyZWUocGt0X2Rldik7CisJCQlyZXR1cm4gLUVOT01FTTsKKwkJfQorCQltZW1zZXQocGt0X2Rldi0+Zmxvd3MsIDAsIE1BWF9DRkxPV1Mqc2l6ZW9mKHN0cnVjdCBmbG93X3N0YXRlKSk7CisKKwkJcGt0X2Rldi0+bWluX3BrdF9zaXplID0gRVRIX1pMRU47CisgICAgICAgICAgICAgICAgcGt0X2Rldi0+bWF4X3BrdF9zaXplID0gRVRIX1pMRU47CisgICAgICAgICAgICAgICAgcGt0X2Rldi0+bmZyYWdzID0gMDsKKyAgICAgICAgICAgICAgICBwa3RfZGV2LT5jbG9uZV9za2IgPSBwZ19jbG9uZV9za2JfZDsKKyAgICAgICAgICAgICAgICBwa3RfZGV2LT5kZWxheV91cyA9IHBnX2RlbGF5X2QgLyAxMDAwOworICAgICAgICAgICAgICAgIHBrdF9kZXYtPmRlbGF5X25zID0gcGdfZGVsYXlfZCAlIDEwMDA7CisgICAgICAgICAgICAgICAgcGt0X2Rldi0+Y291bnQgPSBwZ19jb3VudF9kOworICAgICAgICAgICAgICAgIHBrdF9kZXYtPnNvZmFyID0gMDsKKyAgICAgICAgICAgICAgICBwa3RfZGV2LT51ZHBfc3JjX21pbiA9IDk7IC8qIHNpbmsgcG9ydCAqLworICAgICAgICAgICAgICAgIHBrdF9kZXYtPnVkcF9zcmNfbWF4ID0gOTsKKyAgICAgICAgICAgICAgICBwa3RfZGV2LT51ZHBfZHN0X21pbiA9IDk7CisgICAgICAgICAgICAgICAgcGt0X2Rldi0+dWRwX2RzdF9tYXggPSA5OworCisgICAgICAgICAgICAgICAgc3RybmNweShwa3RfZGV2LT5pZm5hbWUsIGlmbmFtZSwgMzEpOworICAgICAgICAgICAgICAgIHNwcmludGYocGt0X2Rldi0+Zm5hbWUsICJuZXQvJXMvJXMiLCBQR19QUk9DX0RJUiwgaWZuYW1lKTsKKworICAgICAgICAgICAgICAgIGlmICghIHBrdGdlbl9zZXR1cF9kZXYocGt0X2RldikpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIHByaW50aygicGt0Z2VuOiBFUlJPUjogcGt0Z2VuX3NldHVwX2RldiBmYWlsZWQuXG4iKTsKKwkJCWlmIChwa3RfZGV2LT5mbG93cykKKwkJCQl2ZnJlZShwa3RfZGV2LT5mbG93cyk7CisgICAgICAgICAgICAgICAgICAgICAgICBrZnJlZShwa3RfZGV2KTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAtRU5PREVWOworICAgICAgICAgICAgICAgIH0KKworICAgICAgICAgICAgICAgIHBrdF9kZXYtPnByb2NfZW50ID0gY3JlYXRlX3Byb2NfZW50cnkocGt0X2Rldi0+Zm5hbWUsIDA2MDAsIE5VTEwpOworICAgICAgICAgICAgICAgIGlmICghcGt0X2Rldi0+cHJvY19lbnQpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIHByaW50aygicGt0Z2VuOiBjYW5ub3QgY3JlYXRlICVzIHByb2NmcyBlbnRyeS5cbiIsIHBrdF9kZXYtPmZuYW1lKTsKKwkJCWlmIChwa3RfZGV2LT5mbG93cykKKwkJCQl2ZnJlZShwa3RfZGV2LT5mbG93cyk7CisgICAgICAgICAgICAgICAgICAgICAgICBrZnJlZShwa3RfZGV2KTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAtRUlOVkFMOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBwa3RfZGV2LT5wcm9jX2VudC0+cmVhZF9wcm9jID0gcHJvY19pZl9yZWFkOworICAgICAgICAgICAgICAgIHBrdF9kZXYtPnByb2NfZW50LT53cml0ZV9wcm9jID0gcHJvY19pZl93cml0ZTsKKyAgICAgICAgICAgICAgICBwa3RfZGV2LT5wcm9jX2VudC0+ZGF0YSA9ICh2b2lkKikocGt0X2Rldik7CisJCXBrdF9kZXYtPnByb2NfZW50LT5vd25lciA9IFRISVNfTU9EVUxFOworCisgICAgICAgICAgICAgICAgcmV0dXJuIGFkZF9kZXZfdG9fdGhyZWFkKHQsIHBrdF9kZXYpOworICAgICAgICB9CisgICAgICAgIGVsc2UgeworICAgICAgICAgICAgICAgIHByaW50aygicGt0Z2VuOiBFUlJPUjogaW50ZXJmYWNlIGFscmVhZHkgdXNlZC5cbiIpOworICAgICAgICAgICAgICAgIHJldHVybiAtRUJVU1k7CisgICAgICAgIH0KK30KKworc3RhdGljIHN0cnVjdCBwa3RnZW5fdGhyZWFkICpwa3RnZW5fZmluZF90aHJlYWQoY29uc3QgY2hhciogbmFtZSkgCit7CisgICAgICAgIHN0cnVjdCBwa3RnZW5fdGhyZWFkICp0ID0gTlVMTDsKKworICAgICAgIHRocmVhZF9sb2NrKCk7CisKKyAgICAgICAgdCA9IHBrdGdlbl90aHJlYWRzOworICAgICAgICB3aGlsZSAodCkgeworICAgICAgICAgICAgICAgIGlmIChzdHJjbXAodC0+bmFtZSwgbmFtZSkgPT0gMCkgCisgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKKworICAgICAgICAgICAgICAgIHQgPSB0LT5uZXh0OworICAgICAgICB9CisgICAgICAgIHRocmVhZF91bmxvY2soKTsKKyAgICAgICAgcmV0dXJuIHQ7Cit9CisKK3N0YXRpYyBpbnQgcGt0Z2VuX2NyZWF0ZV90aHJlYWQoY29uc3QgY2hhciogbmFtZSwgaW50IGNwdSkgCit7CisgICAgICAgIHN0cnVjdCBwa3RnZW5fdGhyZWFkICp0ID0gTlVMTDsKKworICAgICAgICBpZiAoc3RybGVuKG5hbWUpID4gMzEpIHsKKyAgICAgICAgICAgICAgICBwcmludGsoInBrdGdlbjogRVJST1I6ICBUaHJlYWQgbmFtZSBjYW5ub3QgYmUgbW9yZSB0aGFuIDMxIGNoYXJhY3RlcnMuXG4iKTsKKyAgICAgICAgICAgICAgICByZXR1cm4gLUVJTlZBTDsKKyAgICAgICAgfQorICAgICAgICAKKyAgICAgICAgaWYgKHBrdGdlbl9maW5kX3RocmVhZChuYW1lKSkgeworICAgICAgICAgICAgICAgIHByaW50aygicGt0Z2VuOiBFUlJPUjogdGhyZWFkOiAlcyBhbHJlYWR5IGV4aXN0c1xuIiwgbmFtZSk7CisgICAgICAgICAgICAgICAgcmV0dXJuIC1FSU5WQUw7CisgICAgICAgIH0KKworICAgICAgICB0ID0gKHN0cnVjdCBwa3RnZW5fdGhyZWFkKikoa21hbGxvYyhzaXplb2Yoc3RydWN0IHBrdGdlbl90aHJlYWQpLCBHRlBfS0VSTkVMKSk7CisgICAgICAgIGlmICghdCkgeworICAgICAgICAgICAgICAgIHByaW50aygicGt0Z2VuOiBFUlJPUjogb3V0IG9mIG1lbW9yeSwgY2FuJ3QgY3JlYXRlIG5ldyB0aHJlYWQuXG4iKTsKKyAgICAgICAgICAgICAgICByZXR1cm4gLUVOT01FTTsKKyAgICAgICAgfQorCisgICAgICAgIG1lbXNldCh0LCAwLCBzaXplb2Yoc3RydWN0IHBrdGdlbl90aHJlYWQpKTsKKyAgICAgICAgc3RyY3B5KHQtPm5hbWUsIG5hbWUpOworICAgICAgICBzcGluX2xvY2tfaW5pdCgmdC0+aWZfbG9jayk7CisJdC0+Y3B1ID0gY3B1OworICAgICAgICAKKyAgICAgICAgc3ByaW50Zih0LT5mbmFtZSwgIm5ldC8lcy8lcyIsIFBHX1BST0NfRElSLCB0LT5uYW1lKTsKKyAgICAgICAgdC0+cHJvY19lbnQgPSBjcmVhdGVfcHJvY19lbnRyeSh0LT5mbmFtZSwgMDYwMCwgTlVMTCk7CisgICAgICAgIGlmICghdC0+cHJvY19lbnQpIHsKKyAgICAgICAgICAgICAgICBwcmludGsoInBrdGdlbjogY2Fubm90IGNyZWF0ZSAlcyBwcm9jZnMgZW50cnkuXG4iLCB0LT5mbmFtZSk7CisgICAgICAgICAgICAgICAga2ZyZWUodCk7CisgICAgICAgICAgICAgICAgcmV0dXJuIC1FSU5WQUw7CisgICAgICAgIH0KKyAgICAgICAgdC0+cHJvY19lbnQtPn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wlwcmludGsodmVyc2lvbik7CisKKyAgICAgICAgbW9kdWxlX2ZuYW1lWzBdID0gMDsKKworCWNyZWF0ZV9wcm9jX2RpcigpOworCisgICAgICAgIHNwcmludGYobW9kdWxlX2ZuYW1lLCAibmV0LyVzL3BnY3RybCIsIFBHX1BST0NfRElSKTsKKyAgICAgICAgbW9kdWxlX3Byb2NfZW50ID0gY3JlYXRlX3Byb2NfZW50cnkobW9kdWxlX2ZuYW1lLCAwNjAwLCBOVUxMKTsKKyAgICAgICAgaWYgKCFtb2R1bGVfcHJvY19lbnQpIHsKKyAgICAgICAgICAgICAgICBwcmludGsoInBrdGdlbjogRVJST1I6IGNhbm5vdCBjcmVhdGUgJXMgcHJvY2ZzIGVudHJ5LlxuIiwgbW9kdWxlX2ZuYW1lKTsKKyAgICAgICAgICAgICAgICByZXR1cm4gLUVJTlZBTDsKKyAgICAgICAgfQorCisgICAgICAgIG1vZHVsZV9wcm9jX2VudC0+cHJvY19mb3BzID0gICZwa3RnZW5fZm9wczsKKyAgICAgICAgbW9kdWxlX3Byb2NfZW50LT5kYXRhID0gTlVMTDsKKworCS8qIFJlZ2lzdGVyIHVzIHRvIHJlY2VpdmUgbmV0ZGV2aWNlIGV2ZW50cyAqLworCXJlZ2lzdGVyX25ldGRldmljZV9ub3RpZmllcigmcGt0Z2VuX25vdGlmaWVyX2Jsb2NrKTsKKyAgICAgICAgCisJZm9yIChjcHUgPSAwOyBjcHUgPCBOUl9DUFVTIDsgY3B1KyspIHsKKwkJY2hhciBidWZbMzBdOworCisJCWlmICghY3B1X29ubGluZShjcHUpKQorCQkJY29udGludWU7CisKKyAgICAgICAgICAgICAgICBzcHJpbnRmKGJ1ZiwgImtwa3RnZW5kXyVpIiwgY3B1KTsKKyAgICAgICAgICAgICAgICBwa3RnZW5fY3JlYXRlX3RocmVhZChidWYsIGNwdSk7CisgICAgICAgIH0KKyAgICAgICAgcmV0dXJuIDA7ICAgICAgICAKK30KKworc3RhdGljIHZvaWQgX19leGl0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1NOREJVRjoKKwkJCXYudmFsID0gc2stPnNrX3NuZGJ1ZjsKKwkJCWJyZWFrOworCQkKKwkJY2FzZSBTT19SQ1ZCVUY6CisJCQl2LnZhbCA9IHNrLT5za19yY3ZidWY7CisJCQlicmVhazsKKworCQljYXNlIFNPX1JFVVNFQUREUjoKKwkJCXYudmFsID0gc2stPnNrX3JldXNlOworCQkJYnJlYWs7CisKKwkJY2FzZSBTT19LRUVQQUxJVkU6CisJCQl2LnZhbCA9ICEhc29ja19mbGFnKHNrLCBTT0NLX0tFRVBPUEVOKTsKKwkJCWJyZWFrOworCisJCWNhc2UgU09fVFlQRToKKwkJCXYudmFsID0gc2stPnNrX3R5cGU7CQkgIAkJCisJCQlicmVhazsKKworCQljYXNlIFNPX0VSUk9SOgorCQkJdi52YWwgPSAtc29ja19lcnJvcihzayk7CisJCQlpZih2LnZhbD09MCkKKwkJCQl2LnZhbCA9IHhjaGcoJnNrLT5za19lcnJfc29mdCwgMCk7CisJCQlicmVhazsKKworCQljYXNlIFNPX09PQklOTElORToKKwkJCXYudmFsID0gISFzb2NrX2ZsYWcoc2ssIFNPQ0tfVVJHSU5MSU5FKTsKKwkJCWJyZWFrOworCQorCQljYXNlIFNPX05PX0NIRUNLOgorCQkJdi52YWwgPSBzay0+c2tfbm9fY2hlY2s7CisJCQlicmVhazsKKworCQljYXNlIFNPX1BSSU9SSVRZOgorCQkJdi52YWwgPSBzay0+c2tfcHJpb3JpdHk7CisJCQlicmVhazsKKwkJCisJCWNhc2UgU09fTElOR0VSOgkKKwkJCWx2CQk9IHNpemVvZih2LmxpbmcpOworCQkJdi5saW5nLmxfb25vZmYJPSAhIXNvY2tfZmxhZyhzaywgU09DS19MSU5HRVIpOworIAkJCXYubGluZy5sX2xpbmdlcgk9IHNrLT5za19saW5nZXJ0aW1lIC8gSFo7CisJCQlicmVhazsKKwkJCQkJCisJCWNhc2UgU09fQlNEQ09NUEFUOgorCQkJc29ja193YXJuX29ic29sZXRlX2JzZGlzbSgi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0UsICZzay0+c2tfc29ja2V0LT5mbGFncyk7CisJCWVyciA9IC1FQUdBSU47CisJCWlmICghdGltZW8pCisJCQlnb3RvIGZhaWx1cmU7CisJCWlmIChzaWduYWxfcGVuZGluZyhjdXJyZW50KSkKKwkJCWdvdG8gaW50ZXJydXB0ZWQ7CisJCXRpbWVvID0gc29ja193YWl0X2Zvcl93bWVtKHNrLCB0aW1lbyk7CisJfQorCisJc2tiX3NldF9vd25lcl93KHNrYiwgc2spOworCXJldHVybiBza2I7CisKK2ludGVycnVwdGVkOgorCWVyciA9IHNvY2tfaW50cl9lcnJubyh0aW1lbyk7CitmYWlsdXJlOgorCSplcnJjb2RlID0gZXJyOworCXJldHVybiBOVUxMOworfQorCitzdHJ1Y3Qgc2tfYnVmZiAqc29ja19hbGxvY19zZW5kX3NrYihzdHJ1Y3Qgc29jayAqc2ssIHVuc2lnbmVkIGxvbmcgc2l6ZSwgCisJCQkJICAgIGludCBub2Jsb2NrLCBpbnQgKmVycmNvZGUpCit7CisJcmV0dXJuIHNvY2tfYWxsb2Nfc2VuZF9wc2tiKHNrLCBzaXplLCAwLCBub2Jsb2NrLCBlcnJjb2RlKTsKK30KKworc3RhdGljIHZvaWQgX19sb2NrX3NvY2soc3RydWN0IHNvY2sgKnNrKQoreworCURFRklORV9XQUlUKHdhaXQpOworCisJZm9yKDs7KSB7CisJCXByZXBhcmVfdG9fd2FpdF9leGNsdXNpdmUoJnNrLT5za19sb2NrLndxLCAmd2FpdCwKKwkJCQkJVEFTS19VTklOVEVSUlVQVElCTEUpOworCQlzcGluX3VubG9ja19iaCgmc2stPnNrX2xvY2suc2xvY2spOworCQlzY2hlZHVsZSgpOworCQlzcGluX2xvY2tfYmgoJnNrLT5za19sb2NrLnNsb2NrKTsKKwkJaWYoIXNvY2tfb3duZWRfYnlfdXNlcihzaykpCisJCQlicmVhazsKKwl9CisJZmluaXNoX3dhaXQoJnNrLT5za19sb2NrLndxLCAmd2FpdCk7Cit9CisKK3N0YXRpYyB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wlzay0+c2tfcGVlcmNyZWQucGlkIAk9CTA7CisJc2stPnNrX3BlZXJjcmVkLnVpZAk9CS0xOworCXNrLT5za19wZWVyY3JlZC5naWQJPQktMTsKKwlzay0+c2tfd3JpdGVfcGVuZGluZwk9CTA7CisJc2stPnNrX3Jjdmxvd2F0CQk9CTE7CisJc2stPnNrX3JjdnRpbWVvCQk9CU1BWF9TQ0hFRFVMRV9USU1FT1VUOworCXNrLT5za19zbmR0aW1lbwkJPQlNQVhfU0NIRURVTEVfVElNRU9VVDsKKworCXNrLT5za19zdGFtcC50dl9zZWMgICAgID0gLTFMOworCXNrLT5za19zdGFtcC50dl91c2VjICAgID0gLTFMOworCisJYXRvbWljX3NldCgmc2stPnNrX3JlZmNudCwgMSk7Cit9CisKK3ZvaWQgZmFzdGNhbGwgbG9ja19zb2NrKHN0cnVjdCBzb2NrICpzaykKK3sKKwltaWdodF9zbGVlcCgpOworCXNwaW5fbG9ja19iaCgmKHNrLT5za19sb2NrLnNsb2NrKSk7CisJaWYgKHNrLT5za19sb2NrLm93bmVyKQorCQlfX2xvY2tfc29jayhzayk7CisJc2stPnNrX2xvY2sub3duZXIgPSAodm9pZCAqKTE7CisJc3Bpbl91bmxvY2tfYmgoJihzay0+c2tfbG9jay5zbG9jaykpOworfQorCitFWFBPUlRfU1lNQk9MKGxvY2tfc29jayk7CisKK3ZvaWQgZmFzdGNhbGwgcmVsZWFzZV9zb2NrKHN0cnVjdCBzb2NrICpzaykKK3sKKwlzcGluX2xvY2tfYmgoJihzay0+c2tfbG9jay5zbG9jaykpOworCWlmIChzay0+c2tfYmFja2xvZy50YWlsKQorCQlfX3JlbGVhc2Vfc29jayhzayk7CisJc2stPnNrX2xvY2sub3duZXIgPSBOVUxMOworICAgICAgICBpZiAod2FpdHF1ZXVlX2FjdGl2ZSgmKHNrLT5za19sb2NrLndxKSkpCisJCXdha2VfdXAoJihzay0+c2tfbG9jay53cSkpOworCXNwaW5fdW5sb2NrX2JoKCYoc2stPnNrX2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9faW50ZXJydXB0ZWQ7CisJCWNsZWFyX2JpdChTT0NLX0FTWU5DX05PU1BBQ0UsICZzay0+c2tfc29ja2V0LT5mbGFncyk7CisJCWlmIChza19zdHJlYW1fbWVtb3J5X2ZyZWUoc2spICYmICF2bV93YWl0KQorCQkJYnJlYWs7CisKKwkJc2V0X2JpdChTT0NLX05PU1BBQ0UsICZzay0+c2tfc29ja2V0LT5mbGFncyk7CisJCXNrLT5za193cml0ZV9wZW5kaW5nKys7CisJCXNrX3dhaXRfZXZlbnQoc2ssICZjdXJyZW50X3RpbWVvLCBza19zdHJlYW1fbWVtb3J5X2ZyZWUoc2spICYmCisJCQkJCQkgIHZtX3dhaXQpOworCQlzay0+c2tfd3JpdGVfcGVuZGluZy0tOworCisJCWlmICh2bV93YWl0KSB7CisJCQl2bV93YWl0IC09IGN1cnJlbnRfdGltZW87CisJCQljdXJyZW50X3RpbWVvID0gKnRpbWVvX3A7CisJCQlpZiAoY3VycmVudF90aW1lbyAhPSBNQVhfU0NIRURVTEVfVElNRU9VVCAmJgorCQkJICAgIChjdXJyZW50X3RpbWVvIC09IHZtX3dhaXQpIDwgMCkKKwkJCQljdXJyZW50X3RpbWVvID0gMDsKKwkJCXZtX3dhaXQgPSAwOworCQl9CisJCSp0aW1lb19wID0gY3VycmVudF90aW1lbzsKKwl9CitvdXQ6CisJZmluaXNoX3dhaXQoc2stPnNrX3NsZWVwLCAmd2FpdCk7CisJcmV0dXJuIGVycjsKKworZG9fZXJyb3I6CisJZXJyID0gLUVQSVBFOworCWdvdG8gb3V0OworZG9fbm9uYmxvY2s6CisJZXJyID0gLUVBR0FJTjsKKwlnb3RvIG91dDsKK2RvX2ludGVycnVwdGVkOgorCWVyciA9IHNvY2tfaW50cl9lcnJubygqdGltZW9fcCk7CisJZ290byBvdXQ7Cit9CisKK0VYUE9SVF9TWU1CT0woc2tfc3RyZWFtX3dhaXRfbWVtb3J5KTsKKwordm9pZCBza19zdHJlYW1fcmZyZWUoc3RydWN0IHN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Rk9SIEEgUEFSVElDVUxBUiBQVVJQT1NFLiAgU2VlIHRoZQorICAgIEdOVSBHZW5lcmFsIFB1YmxpYyBMaWNlbnNlIGZvciBtb3JlIGRldGFpbHMuCisKK0hJU1RPUlk6CisKK1ZlcnNpb24gICAgICAgICAgIEtlcm5lbCAgICAgRGF0ZSAgICAgICBBdXRob3IvQ29tbWVudHMKKy0tLS0tLS0gICAgICAgICAgIC0tLS0tLSAgICAgLS0tLSAgICAgICAtLS0tLS0tLS0tLS0tLS0KK1ZlcnNpb24gMC4wLjEgICAgIDIuMC4zMCAgICAwMS1kaWMtOTcJRWR1YXJkbyBNYXJjZWxvIFNlcnJhdAorCQkJCQkoZW1zZXJyYXRAZ2VvY2l0aWVzLmNvbSkKKworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEZpcnN0IERldmVsb3BtZW50IG9mIERFQ25ldCBTb2NrZXQgTGEtCisJCQkJCXllciBmb3IgTGludXguIE9ubHkgc3VwcG9ydHMgb3V0Z29pbmcKKwkJCQkJY29ubmVjdGlvbnMuCisKK1ZlcnNpb24gMC4wLjIJICAyLjEuMTA1ICAgMjAtanVuLTk4ICAgUGF0cmljayBKLiBDYXVsZmllbGQKKwkJCQkJKHBhdHJpY2tAcGFuZGguZGVtb24uY28udWspCisKKwkJCQkJUG9ydCB0byBuZXcga2VybmVsIGRldmVsb3BtZW50IHZlcnNpb24uCisKK1ZlcnNpb24gMC4wLjMgICAgIDIuMS4xMDYgICAyNS1qdW4tOTggICBFZHVhcmRvIE1hcmNlbG8gU2VycmF0CisJCQkJCShlbXNlcnJhdEBnZW9jaXRpZXMuY29tKQorCQkJCQlfCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQWRkZWQgc3VwcG9ydCBmb3IgaW5jb21pbmcgY29ubmVjdGlvbnMKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzbyB3ZSBjYW4gc3RhcnQgZGV2ZWxvcGluZyBzZXJ2ZXIgYXBwcworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9uIExpbnV4LgorCQkJCQktCisJCQkJCU1vZHVsZSBTdXBwb3J0CitWZXJzaW9uIDAuMC40ICAgICAyLjEuMTA5ICAgMjEtanVsLTk4ICAgRWR1YXJkbyBNYXJjZWxvIFNlcnJhdAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKGVtc2VycmF0QGdlb2NpdGllcy5jb20pCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBfCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQWRkZWQgc3VwcG9ydCBmb3IgWDExUjYuNC4gTm93IHdlIGNhbiAKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1c2UgREVDbmV0IHRyYW5zcG9ydCBmb3IgWCBvbiBMaW51eCEhIQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLQorVmVyc2lvbiAwLjAuNSAgICAyLjEuMTEwICAgMDEtYXVnLTk4ICAgRWR1YXJkbyBNYXJjZWxvIFNlcnJhdAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKGVtc2VycmF0QGdlb2NpdGllcy5jb20pCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBSZW1vdmVkIGJ1Z3Mgb24gZmxvdyBjb250cm9sCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBSZW1vdmVkIGJ1Z3Mgb24gaW5jb21pbmcgYWNjZXNzZGF0YQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb3JkZXIKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC0KK1ZlcnNpb24gMC4wLjYgICAgMi4xLjExMCAgIDA3LWF1Zy05OCAgIEVkdWFyZG8gTWFyY2VsbyBTZXJyYXQKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRuX3JlY3Ztc2cgZml4ZXMKKworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFBhdHJpY2sgSi4gQ2F1bGZpZWxkCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkbl9iaW5kIGZpeGVzCisqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworCisjaW5jbHVkZSA8bGludXgvY29uZmlnLmg+CisjaW5jbHVkZSA8bGludXgvbW9kdWxlLmg+CisjaW5jbHVkZSA8bGludXgvZXJybm8uaD4KKyNpbmNsdWRlIDxsaW51eC90eXBlcy5oPgorI2luY2x1ZGUgPGxpbnV4L3NsYWIuaD4KKyNpbmNsdWRlIDxsaW51eC9zb2NrZXQuaD4KKyNpbmNsdWRlIDxsaW51eC9pbi5oPgorI2luY2x1ZGUgPGxpbnV4L2tlcm5lbC5oPgorI2luY2x1ZGUgPGxpbnV4L3NjaGVkLmg+CisjaW5jbHVkZSA8bGludXgvdGltZXIuaD4KKyNpbmNsdWRlIDxsaW51eC9zdHJpbmcuaD4KKyNpbmNsdWRlIDxsaW51eC9zb2NraW9zLmg+CisjaW5jbHVkZSA8bGludXgvbmV0Lmg+CisjaW5jbHVkZSA8bGludXgvbmV0ZGV2aWNlLmg+CisjaW5jbHVkZSA8bGludXgvaW5ldC5oPgorI2luY2x1ZGUgPGxpbnV4L3JvdXRlLmg+CisjaW5jbHVkZSA8bGludXgvbmV0ZmlsdGVyLmg+CisjaW5jbHVkZSA8bGludXgvc2VxX2ZpbGUuaD4KKyNpbmNsdWRlIDxuZXQvc29jay5oPgorI2luY2x1ZGUgPG5ldC90Y3AuaD4KKyNpbmNsdWRlIDxuZXQvZmxvdy5oPgorI2luY2x1ZGUgPGFzbS9zeXN0ZW0uaD4KKyNpbmNsdWRlIDxhc20vaW9jdGxzLmg+C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0OworCisJaWYgKHNvY2spCisJCXNvY2stPm9wcyA9ICZkbl9wcm90b19vcHM7CisJc29ja19pbml0X2RhdGEoc29jaywgc2spOworCisJc2stPnNrX2JhY2tsb2dfcmN2ID0gZG5fbnNwX2JhY2tsb2dfcmN2OworCXNrLT5za19kZXN0cnVjdCAgICA9IGRuX2Rlc3RydWN0OworCXNrLT5za19ub19jaGVjayAgICA9IDE7CisJc2stPnNrX2ZhbWlseSAgICAgID0gUEZfREVDbmV0OworCXNrLT5za19wcm90b2NvbCAgICA9IDA7CisJc2stPnNrX2FsbG9jYXRpb24gID0gZ2ZwOworCisJLyogSW5pdGlhbGl6YXRpb24gb2YgREVDbmV0IFNlc3Npb24gQ29udHJvbCBQb3J0CQkqLworCXNjcCA9IEROX1NLKHNrKTsKKwlzY3AtPnN0YXRlCT0gRE5fTzsJCS8qIE9wZW4JCQkqLworCXNjcC0+bnVtZGF0CT0gMTsJCS8qIE5leHQgZGF0YSBzZWcgdG8gdHgJKi8KKwlzY3AtPm51bW90aAk9IDE7CQkvKiBOZXh0IG90aCBkYXRhIHRvIHR4ICAqLworCXNjcC0+YWNreG10X2RhdCA9IDA7CQkvKiBMYXN0IGRhdGEgc2VnIGFjaydlZCAqLworCXNjcC0+YWNreG10X290aCA9IDA7CQkvKiBMYXN0IG90aCBkYXRhIGFjaydlZCAqLworCXNjcC0+YWNrcmN2X2RhdCA9IDA7CQkvKiBIaWdoZXN0IGRhdGEgYWNrIHJlY3YqLworCXNjcC0+YWNrcmN2X290aCA9IDA7CQkvKiBMYXN0IG90aCBkYXRhIGFjayByZWMqLworICAgICAgICBzY3AtPmZsb3dyZW1fc3cgPSBETl9TRU5EOworCXNjcC0+Zmxvd2xvY19zdyA9IEROX1NFTkQ7CisJc2NwLT5mbG93cmVtX2RhdCA9IDA7CisJc2NwLT5mbG93cmVtX290aCA9IDE7CisJc2NwLT5mbG93bG9jX2RhdCA9IDA7CisJc2NwLT5mbG93bG9jX290aCA9IDE7CisJc2NwLT5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FkZHJsZW4sIGludCBmbGFncykKK3sKKwlzdHJ1Y3Qgc29ja2FkZHJfZG4gKmFkZHIgPSAoc3RydWN0IHNvY2thZGRyX2RuICopdWFkZHI7CisJc3RydWN0IHNvY2sgKnNrID0gc29jay0+c2s7CisJaW50IGVycjsKKwlsb25nIHRpbWVvID0gc29ja19zbmR0aW1lbyhzaywgZmxhZ3MgJiBPX05PTkJMT0NLKTsKKworCWxvY2tfc29jayhzayk7CisJZXJyID0gX19kbl9jb25uZWN0KHNrLCBhZGRyLCBhZGRybGVuLCAmdGltZW8sIDApOworCXJlbGVhc2Vfc29jayhzayk7CisKKwlyZXR1cm4gZXJyOworfQorCitzdGF0aWMgaW5saW5lIGludCBkbl9jaGVja19zdGF0ZShzdHJ1Y3Qgc29jayAqc2ssIHN0cnVjdCBzb2NrYWRkcl9kbiAqYWRkciwgaW50IGFkZHJsZW4sIGxvbmcgKnRpbWVvLCBpbnQgZmxhZ3MpCit7CisJc3RydWN0IGRuX3NjcCAqc2NwID0gRE5fU0soc2spOworCisJc3dpdGNoKHNjcC0+c3RhdGUpIHsKKwkJY2FzZSBETl9SVU46CisJCQlyZXR1cm4gMDsKKwkJY2FzZSBETl9DUjoKKwkJCXJldHVybiBkbl9jb25maXJtX2FjY2VwdChzaywgdGltZW8sIHNrLT5za19hbGxvY2F0aW9uKTsKKwkJY2FzZSBETl9DSToKKwkJY2FzZSBETl9DQzoKKwkJCXJldHVybiBkbl93YWl0X3J1bihzaywgdGltZW8pOworCQljYXNlIEROX086CisJCQlyZXR1cm4gX19kbl9jb25uZWN0KHNrLCBhZGRyLCBhZGRybGVuLCB0aW1lbywgZmxhZ3MpOworCX0KKworCXJldHVybiAtRUlOVkFMOworfQorCisKK3N0YXRpYyB2b2lkIGRuX2FjY2Vzc19jb3B5KHN0cnVjdCBza19idWZmICpza2IsIHN0cnVjdCBhY2Nlc3NkYXRhX2RuICphY2MpCit7CisgICAgICAgIHVuc2lnbmVkIGNoYXIgKnB0ciA9IHNr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rYl9jYiAqY2I7CisJdW5zaWduZWQgY2hhciBtZW51dmVyOworCWludCBlcnIgPSAwOworCXVuc2lnbmVkIGNoYXIgdHlwZTsKKwlsb25nIHRpbWVvID0gc29ja19yY3Z0aW1lbyhzaywgZmxhZ3MgJiBPX05PTkJMT0NLKTsKKworCWxvY2tfc29jayhzayk7CisKKyAgICAgICAgaWYgKHNrLT5za19zdGF0ZSAhPSBUQ1BfTElTVEVOIHx8IEROX1NLKHNrKS0+c3RhdGUgIT0gRE5fTykgeworCQlyZWxlYXNlX3NvY2soc2spOworCQlyZXR1cm4gLUVJTlZBTDsKKwl9CisKKwlza2IgPSBza2JfZGVxdWV1ZSgmc2stPnNrX3JlY2VpdmVfcXVldWUpOworCWlmIChza2IgPT0gTlVMTCkgeworCQlza2IgPSBkbl93YWl0X2Zvcl9jb25uZWN0KHNrLCAmdGltZW8pOworCQlpZiAoSVNfRVJSKHNrYikpIHsKKwkJCXJlbGVhc2Vfc29jayhzayk7CisJCQlyZXR1cm4gUFRSX0VSUihza2IpOworCQl9CisJfQorCisJY2IgPSBETl9TS0JfQ0Ioc2tiKTsKKwlzay0+c2tfYWNrX2JhY2tsb2ctLTsKKwluZXdzayA9IGRuX2FsbG9jX3NvY2sobmV3c29jaywgc2stPnNrX2FsbG9jYXRpb24pOworCWlmIChuZXdzayA9PSBOVUxMKSB7CisJCXJlbGVhc2Vfc29jayhzayk7CisJCWtmcmVlX3NrYihza2IpOworCQlyZXR1cm4gLUVOT0JVRlM7CisJfQorCXJlbGVhc2Vfc29jayhzayk7CisKKwlkc3RfcmVsZWFzZSh4Y2hnKCZuZXdzay0+c2tfZHN0X2NhY2hlLCBza2ItPmRzdCkpOworCXNrYi0+ZHN0ID0gTlVMTDsKKworICAgICAgICBETl9TSyhuZXdzayktPnN0YXRlICAgICAgICA9IEROX0NSOworCUROX1NLKG5ld3NrKS0+YWRkcnJlbSAgICAgID0gY2ItPnNyY19wb3J0OworCUROX1NLKG5ld3NrKS0+c2VydmljZ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BiYWNrbG9nKQoreworCXN0cnVjdCBzb2NrICpzayA9IHNvY2stPnNrOworCWludCBlcnIgPSAtRUlOVkFMOworCisJbG9ja19zb2NrKHNrKTsKKworCWlmIChzb2NrX2ZsYWcoc2ssIFNPQ0tfWkFQUEVEKSkKKwkJZ290byBvdXQ7CisKKwlpZiAoKEROX1NLKHNrKS0+c3RhdGUgIT0gRE5fTykgfHwgKHNrLT5za19zdGF0ZSA9PSBUQ1BfTElTVEVOKSkKKwkJZ290byBvdXQ7CisKKwlzay0+c2tfbWF4X2Fja19iYWNrbG9nID0gYmFja2xvZzsKKwlzay0+c2tfYWNrX2JhY2tsb2cgICAgID0gMDsKKwlzay0+c2tfc3RhdGUgICAgICAgICAgID0gVENQX0xJU1RFTjsKKwllcnIgICAgICAgICAgICAgICAgID0gMDsKKwlkbl9yZWhhc2hfc29jayhzayk7CisKK291dDoKKwlyZWxlYXNlX3NvY2soc2spOworCisgICAgICAgIHJldHVybiBlcnI7Cit9CisKKworc3RhdGljIGludCBkbl9zaHV0ZG93bihzdHJ1Y3Qgc29ja2V0ICpzb2NrLCBpbnQgaG93KQoreworCXN0cnVjdCBzb2NrICpzayA9IHNvY2stPnNrOworCXN0cnVjdCBkbl9zY3AgKnNjcCA9IEROX1NLKHNrKTsKKwlpbnQgZXJyID0gLUVOT1RDT05OOworCisJbG9ja19zb2NrKHNrKTsKKworCWlmIChzb2NrLT5zdGF0ZSA9PSBTU19VTkNPTk5FQ1RFRCkKKwkJZ290byBvdXQ7CisKKwllcnIgPSAwOworCWlmIChzb2NrLT5zdGF0ZSA9PSBTU19ESVNDT05ORUNUSU5HKQorCQlnb3RvIG91dDsKKworCWVyciA9IC1FSU5WQUw7CisJaWYgKHNjcC0+c3RhdGUgPT0gRE5fTykKKwkJZ290byBvdXQ7CisKKwlpZiAoaG93ICE9IFNIVVRET1dOX01BU0spCisJCWdvdG8gb3V0OworCisJc2stPnNrX3NodXRkb3duID0gaG93OworCWRuX2Rlc3Ryb3lfc29j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iam5hbWVbaV07CisJCQkJaWYgKElTX05PVF9QUklOVEFCTEUoYnVmW2ldKSkKKwkJCQkJYnVmW2ldID0gJy4nOworCQkJfQorCQkJYnVmW2ldID0gMDsKKyAgICAJfQorfQorCitzdGF0aWMgY2hhciAqZG5fc3RhdGUyYXNjKHVuc2lnbmVkIGNoYXIgc3RhdGUpCit7CisJc3dpdGNoKHN0YXRlKSB7CisJCWNhc2UgRE5fTzoKKwkJCXJldHVybiAiT1BFTiI7CisJCWNhc2UgRE5fQ1I6CisJCQlyZXR1cm4gIiAgQ1IiOworCQljYXNlIEROX0RSOgorCQkJcmV0dXJuICIgIERSIjsKKwkJY2FzZSBETl9EUkM6CisJCQlyZXR1cm4gIiBEUkMiOworCQljYXNlIEROX0NDOgorCQkJcmV0dXJuICIgIENDIjsKKwkJY2FzZSBETl9DSToKKwkJCXJldHVybiAiICBDSSI7CisJCWNhc2UgRE5fTlI6CisJCQlyZXR1cm4gIiAgTlIiOworCQljYXNlIEROX05DOgorCQkJcmV0dXJuICIgIE5DIjsKKwkJY2FzZSBETl9DRDoKKwkJCXJldHVybiAiICBDRCI7CisJCWNhc2UgRE5fUko6CisJCQlyZXR1cm4gIiAgUkoiOworCQljYXNlIEROX1JVTjoKKwkJCXJldHVybiAiIFJVTiI7CisJCWNhc2UgRE5fREk6CisJCQlyZXR1cm4gIiAgREkiOworCQljYXNlIEROX0RJQzoKKwkJCXJldHVybiAiIERJQyI7CisJCWNhc2UgRE5fRE46CisJCQlyZXR1cm4gIiAgRE4iOworCQljYXNlIEROX0NMOgorCQkJcmV0dXJuICIgIENMIjsKKwkJY2FzZSBETl9DTjoKKwkJCXJldHVybiAiICBDTiI7CisJfQorCisJcmV0dXJuICI/Pz8/IjsKK30KKworc3RhdGljIGlubGluZSB2b2lkIGRuX3NvY2tldF9mb3JtYXRfZW50cnkoc3RydWN0IHNlcV9maWxlICpzZXEsIHN0cnVjdCBzb2NrICpzaykKK3sKKwlzdHJ1Y3QgZG5fc2NwICp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C0wLDAgKzEsMTQ4MSBAQAorLyoKKyAqIERFQ25ldCAgICAgICBBbiBpbXBsZW1lbnRhdGlvbiBvZiB0aGUgREVDbmV0IHByb3RvY29sIHN1aXRlIGZvciB0aGUgTElOVVgKKyAqICAgICAgICAgICAgICBvcGVyYXRpbmcgc3lzdGVtLiAgREVDbmV0IGlzIGltcGxlbWVudGVkIHVzaW5nIHRoZSAgQlNEIFNvY2tldAorICogICAgICAgICAgICAgIGludGVyZmFjZSBhcyB0aGUgbWVhbnMgb2YgY29tbXVuaWNhdGlvbiB3aXRoIHRoZSB1c2VyIGxldmVsLgorICoKKyAqICAgICAgICAgICAgICBERUNuZXQgRGV2aWNlIExheWVyCisgKgorICogQXV0aG9yczogICAgIFN0ZXZlIFdoaXRlaG91c2UgPFN0ZXZlV0BBQ00ub3JnPgorICogICAgICAgICAgICAgIEVkdWFyZG8gTWFyY2VsbyBTZXJyYXQgPGVtc2VycmF0QGdlb2NpdGllcy5jb20+CisgKgorICogQ2hhbmdlczoKKyAqICAgICAgICAgIFN0ZXZlIFdoaXRlaG91c2UgOiBEZXZpY2VzIG5vdyBzZWUgaW5jb21pbmcgZnJhbWVzIHNvIHRoZXkKKyAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYW4gbWFyayBvbiB3aG8gaXQgY2FtZSBmcm9tLgorICogICAgICAgICAgU3RldmUgV2hpdGVob3VzZSA6IEZpeGVkIGJ1ZyBpbiBjcmVhdGluZyBuZWlnaGJvdXJzLiBFYWNoIG5laWdoYm91cgorICogICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbiBub3cgaGF2ZSBhIGRldmljZSBzcGVjaWZpYyBzZXR1cCBmdW5jLgorICogICAgICAgICAgU3RldmUgV2hpdGVob3VzZSA6IEFkZGVkIC9wcm9jL3N5cy9uZXQvZGVjbmV0L2NvbmYvPGRldj4vCisgKiAgICAgICAgICBTdGV2ZSBXaGl0ZWhvdXNlIDogRml4ZWQgYnVnIHdoaWNoIHNvbWV0a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Rldi0+aWZhX2xpc3QgPT0gTlVMTCkgeworCQkJCWRuX2ZpYl9kaXNhYmxlX2FkZHIoaWZhLT5pZmFfZGV2LT5kZXYsIDEpOworCQkJfSBlbHNlIHsKKwkJCQlkbl9ydF9jYWNoZV9mbHVzaCgtMSk7CisJCQl9CisJCQlicmVhazsKKwl9CisJcmV0dXJuIE5PVElGWV9ET05FOworfQorCitpbnQgZG5fZmliX3N5bmNfZG93bihkbl9hZGRyZXNzIGxvY2FsLCBzdHJ1Y3QgbmV0X2RldmljZSAqZGV2LCBpbnQgZm9yY2UpCit7CisgICAgICAgIGludCByZXQgPSAwOworICAgICAgICBpbnQgc2NvcGUgPSBSVF9TQ09QRV9OT1dIRVJFOworCisgICAgICAgIGlmIChmb3JjZSkKKyAgICAgICAgICAgICAgICBzY29wZSA9IC0xOworCisgICAgICAgIGZvcl9maWJfaW5mbygpIHsKKyAgICAgICAgICAgICAgICAvKiAKKyAgICAgICAgICAgICAgICAgKiBUaGlzIG1ha2VzIG5vIHNlbnNlIGZvciBERUNuZXQuLi4uIHdlIHdpbGwgYWxtb3N0CisgICAgICAgICAgICAgICAgICogY2VydGFpbmx5IGhhdmUgbW9yZSB0aGFuIG9uZSBsb2NhbCBhZGRyZXNzIHRoZSBzYW1lCisgICAgICAgICAgICAgICAgICogb3ZlciBhbGwgb3VyIGludGVyZmFjZXMuIEl0IG5lZWRzIHRoaW5raW5nIGFib3V0CisgICAgICAgICAgICAgICAgICogc29tZSBtb3JlLgorICAgICAgICAgICAgICAgICAqLworICAgICAgICAgICAgICAgIGlmIChsb2NhbCAmJiBmaS0+ZmliX3ByZWZzcmMgPT0gbG9jYWwpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIGZpLT5maWJfZmxhZ3MgfD0gUlROSF9GX0RFQUQ7CisgICAgICAgICAgICAgICAgICAgICAgICByZXQrKzsKKyAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGRldiAmJiBmaS0+ZmliX25ocykgeworICAgICAgICAgICAgICAgICAgICAgICAgaW50IGRlYWQgPSAwOworCisgICAgICAgICAgICAgICAgICAgICAgICBjaGFuZ2VfbmV4dGhvcHMoZmkpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG5oLT5uaF9mbGFncyZSVE5IX0ZfREVBRCkKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWFkKys7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsc2UgaWYgKG5oLT5uaF9kZXYgPT0gZGV2ICYmCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuaC0+bmhfc2NvcGUgIT0gc2NvcGUpIHsKKwkJCQkJc3Bpbl9sb2NrX2JoKCZkbl9maWJfbXVsdGlwYXRoX2xvY2spOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5oLT5uaF9mbGFncyB8PSBSVE5IX0ZfREVBRDsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaS0+ZmliX3Bvd2VyIC09IG5oLT5uaF9wb3dlcjsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuaC0+bmhfcG93ZXIgPSAwOworCQkJCQlzcGluX3VubG9ja19iaCgmZG5fZmliX211bHRpcGF0aF9sb2NrKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWFkKys7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgICAgIH0gZW5kZm9yX25leHRob3BzKGZpKQorICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRlYWQgPT0gZmktPmZpYl9uaHMpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZmktPmZpYl9mbGFncyB8PSBSVE5IX0ZfREVBRDsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0Kys7CisgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgfQorICAgICAgICB9IGVuZGZvcl9maWJfaW5mbygpOworICAgICAgICByZXR1cm4gcmV0OworfQorCisKK2ludCBkbl9maWJfc3luY191cChzdHJ1Y3QgbmV0X2RldmljZSAqZGV2KQoreworICAgICAgICBpbnQgcmV0ID0gMDsKKworICAgICAgICBpZiAoIShkZXYtPmZsYWdzJklGRl9VUCkpCisgICAgICAgICAgICAgICAgcmV0dXJuIDA7CisKKyAgICAgICAgZm9yX2ZpYl9pbmZvKCkgeworICAgICAgICAgICAgICAgIGludCBhbGl2ZSA9IDA7CisKKyAgICAgICAgICAgICAgICBjaGFuZ2VfbmV4dGhvcHMoZmkpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIGlmICghKG5oLT5uaF9mbGFncyZSVE5IX0ZfREVBRCkpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYWxpdmUrKzsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CisgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgICAgICBpZiAobmgtPm5oX2RldiA9PSBOVUxMIHx8ICEobmgtPm5oX2Rldi0+ZmxhZ3MmSUZGX1VQKSkKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CisgICAgICAgICAgICAgICAgICAgICAgICBpZiAobmgtPm5oX2RldiAhPSBkZXYgfHwgZGV2LT5kbl9wdHIgPT0gTlVMTCkKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CisgICAgICAgICAgICAgICAgICAgICAgICBhbGl2ZSsrOworCQkJc3Bpbl9sb2NrX2JoKCZkbl9maWJfbXVsdGlwYXRoX2xvY2spOworICAgICAgICAgICAgICAgICAgICAgICAgbmgtPm5oX3Bvd2VyID0gMDsKKyAgICAgICAgICAgICAgICAgICAgICAgIG5oLT5uaF9mbGFncyAmPSB+UlROSF9GX0RFQUQ7CisJCQlzcGluX3VubG9ja19iaCgmZG5fZmliX211bHRpcGF0aF9sb2NrKTsKKyAgICAgICAgICAgICAgICB9IGVuZGZvcl9uZXh0aG9wcyhmaSk7CisKKyAgICAgICAgICAgICAgICBpZiAoYWxpdmUgPiAwKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBmaS0+ZmliX2ZsYWdzICY9IH5SVE5IX0ZfREVBRDsKKyAgICAgICAgICAgICAgICAgICAgICAgIHJldCsrOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgfSBlbmRmb3JfZmliX2luZm8oKTsKKyAgICAgICAgcmV0dXJuIHJldDsKK30KKwordm9pZCBkbl9maWJfZmx1c2godm9pZCkKK3sKKyAgICAgICAgaW50IGZsdXNoZWQgPSAwOworICAgICAgICBzdHJ1Y3QgZG5fZmliX3RhYmxlICp0YjsKKyAgICAgICAgaW50IGlkOworCisgICAgICAgIGZvcihpZCA9IFJUX1RBQkxFX01BWDsgaWQgPiAwOyBpZC0tKSB7CisgICAgICAgICAgICAgICAgaWYgKCh0YiA9IGRuX2ZpYl9nZXRfdGFibGUoaWQsIDApKSA9PSBOVUxMKQorICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CisgICAgICAgICAgICAgICAgZmx1c2hlZCArPSB0Yi0+Zmx1c2godGIpOworICAgICAgICB9CisKKyAgICAgICAgaWYgKGZsdXNoZWQpCisgICAgICAgICAgICAgICAgZG5fcnRfY2FjaGVfZmx1c2goLTEpOworfQorCitzdGF0aWMgc3RydWN0IG5vdGlmaWVyX2Jsb2NrIGRuX2ZpYl9kbmFkZHJfbm90aWZpZXIgPSB7CisJLm5vdGlmaWVyX2NhbGwgPSBkbl9maWJfZG5hZGRyX2V2ZW50LAorfTsKKwordm9pZCBfX2V4aXQgZG5fZmliX2NsZWFudXAodm9pZCkKK3sKKwlkbl9maWJfdGFibGVfY2xlYW51cCgpOworCWRuX2ZpYl9ydWxlc19jbGVhbnVwKCk7CisKKwl1bnJlZ2lzdGVy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lIFdoaXRlaG91c2UgICAgIDogRml4ZWQgcm91dGVyIGxpc3Rpbmcgcm91dGluZQorICogICAgIFN0ZXZlIFdoaXRlaG91c2UgICAgIDogQWRkZWQgZXJyb3JfcmVwb3J0IGZ1bmN0aW9ucworICogICAgIFN0ZXZlIFdoaXRlaG91c2UgICAgIDogQWRkZWQgZGVmYXVsdCByb3V0ZXIgZGV0ZWN0aW9uCisgKiAgICAgU3RldmUgV2hpdGVob3VzZSAgICAgOiBIb3AgY291bnRzIGluIG91dGdvaW5nIG1lc3NhZ2VzCisgKiAgICAgU3RldmUgV2hpdGVob3VzZSAgICAgOiBGaXhlZCBzcmMvZHN0IGluIG91dGdvaW5nIG1lc3NhZ2VzIHNvCisgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3J3YXJkaW5nIG5vdyBzdGFuZHMgYSBnb29kIGNoYW5jZSBvZgorICogICAgICAgICAgICAgICAgICAgICAgICAgICAgd29ya2luZy4KKyAqICAgICBTdGV2ZSBXaGl0ZWhvdXNlICAgICA6IEZpeGVkIG5laWdoYm91ciBzdGF0ZXMgKGZvciBub3cgYW55d2F5KS4KKyAqICAgICBTdGV2ZSBXaGl0ZWhvdXNlICAgICA6IE1hZGUgZXJyb3JfcmVwb3J0IGZ1bmN0aW9ucyBkdW1taWVzLiBUaGlzCisgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpcyBub3QgdGhlIHJpZ2h0IHBsYWNlIHRvIHJldHVybiBza2JzLgorICogICAgIFN0ZXZlIFdoaXRlaG91c2UgICAgIDogQ29udmVydCB0byBzZXFfZmlsZQorICoKKyAqLworCisjaW5jbHVkZSA8bGludXgvY29uZmlnLmg+CisjaW5jbHVkZSA8bGludXgvbmV0Lmg+CisjaW5jbHVkZSA8bGludXgvbW9kdWxlLmg+CisjaW5jbHVkZSA8bGludXgvc29ja2V0Lmg+CisjaW5jbHVkZSA8bGludXgvaWZfYXJwLmg+CisjaW5jbHVkZSA8bGludXgvaWZfZXRoZXIuaD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cmF0ZWxpbWl0KCkpCisgICAgICAgICAgICAgICAgICAgICAgICAJcHJpbnRrKEtFUk5fQ1JJVCAiZG5fc2hvcnRfb3V0cHV0OiBubyBtZW1vcnlcbiIpOworICAgICAgICAgICAgICAgICAgICAgICAga2ZyZWVfc2tiKHNrYik7CisgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gLUVOT0JVRlM7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIGtmcmVlX3NrYihza2IpOworICAgICAgICAgICAgICAgIHNrYiA9IHNrYjI7CisJCWlmIChuZXRfcmF0ZWxpbWl0KCkpCisgICAgICAgICAgICAgICAgCXByaW50ayhLRVJOX0lORk8gImRuX3Nob3J0X291dHB1dDogSW5jcmVhc2luZyBoZWFkcm9vbVxuIik7CisgICAgICAgIH0KKworCWRhdGEgPSBza2JfcHVzaChza2IsIHNpemVvZihzdHJ1Y3QgZG5fc2hvcnRfcGFja2V0KSArIDIpOworCSooKHVuc2lnbmVkIHNob3J0ICopZGF0YSkgPSBkbl9odG9ucyhza2ItPmxlbiAtIDIpOworCXNwID0gKHN0cnVjdCBkbl9zaG9ydF9wYWNrZXQgKikoZGF0YSsyKTsKKworCXNwLT5tc2dmbGcgICAgID0gRE5fUlRfUEtUX1NIT1JUfChjYi0+cnRfZmxhZ3MmKEROX1JUX0ZfUlFSfEROX1JUX0ZfUlRTKSk7CisJc3AtPmRzdG5vZGUgICAgPSBjYi0+ZHN0OworCXNwLT5zcmNub2RlICAgID0gY2ItPnNyYzsKKwlzcC0+Zm9yd2FyZCAgICA9IGNiLT5ob3BzICYgMHgzZjsKKworCXNrYi0+bmgucmF3ID0gc2tiLT5kYXRhOworCisJcmV0dXJuIE5GX0hPT0soUEZfREVDbmV0LCBORl9ETl9QT1NUX1JPVVRJTkcsIHNrYiwgTlVMTCwgbmVpZ2gtPmRldiwgZG5fbmVpZ2hfb3V0cHV0X3BhY2tldCk7Cit9CisKKy8qCisgKiBQaGFzZSAzIG91dHB1dC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lIDwgKm1pbikpCisJCQltaW4gPSBiYXNlOworCQliYXNlICs9IDc7IC8qIGZpbmQgbmV4dCBwcmlvcml0eSAqLworCX0KKworCWlmICghbWluKQorCQlyZXR1cm4gTlVMTDsKKworCXJldHVybiAoKm1pbiA8IHByaW9yaXR5KSA/IChtaW4gLSA2KSA6IE5VTEw7Cit9CisKK3N0cnVjdCBlbGlzdF9jYl9zdGF0ZSB7CisJc3RydWN0IG5ldF9kZXZpY2UgKmRldjsKKwl1bnNpZ25lZCBjaGFyICpwdHI7CisJdW5zaWduZWQgY2hhciAqcnM7CisJaW50IHQsIG47Cit9OworCitzdGF0aWMgdm9pZCBuZWlnaF9lbGlzdF9jYihzdHJ1Y3QgbmVpZ2hib3VyICpuZWlnaCwgdm9pZCAqX2luZm8pCit7CisJc3RydWN0IGVsaXN0X2NiX3N0YXRlICpzID0gX2luZm87CisJc3RydWN0IGRuX2RldiAqZG5fZGI7CisJc3RydWN0IGRuX25laWdoICpkbjsKKworCWlmIChuZWlnaC0+ZGV2ICE9IHMtPmRldikKKwkJcmV0dXJuOworCisJZG4gPSAoc3RydWN0IGRuX25laWdoICopIG5laWdoOworCWlmICghKGRuLT5mbGFncyAmIChETl9OREZMQUdfUjF8RE5fTkRGTEFHX1IyKSkpCisJCXJldHVybjsKKworCWRuX2RiID0gKHN0cnVjdCBkbl9kZXYgKikgcy0+ZGV2LT5kbl9wdHI7CisJaWYgKGRuX2RiLT5wYXJtcy5mb3J3YXJkaW5nID09IDEgJiYgKGRuLT5mbGFncyAmIEROX05ERkxBR19SMikpCisJCXJldHVybjsKKworCWlmIChzLT50ID09IHMtPm4pCisJCXMtPnJzID0gZG5fZmluZF9zbG90KHMtPnB0ciwgcy0+biwgZG4tPnByaW9yaXR5KTsKKwllbHNlCisJCXMtPnQrKzsKKwlpZiAocy0+cnMgPT0gTlVMTCkKKwkJcmV0dXJuOworCisJZG5fZG4yZXRoKHMtPnJzLCBkbi0+YWRkcik7CisJcy0+cnMgKz0gNjs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gKilwdHIpOworCisJaWYgKChzY3AtPnN0YXRlID09IEROX0NJKSB8fCAoc2NwLT5zdGF0ZSA9PSBETl9DRCkpIHsKKwkJc2NwLT5wZXJzaXN0ID0gMDsKKyAgICAgICAgICAgICAgICBzY3AtPmFkZHJyZW0gPSBjYi0+c3JjX3BvcnQ7CisgICAgICAgICAgICAgICAgc2stPnNrX3N0YXRlID0gVENQX0VTVEFCTElTSEVEOworICAgICAgICAgICAgICAgIHNjcC0+c3RhdGUgPSBETl9SVU47CisJCXNjcC0+c2VydmljZXNfcmVtID0gY2ItPnNlcnZpY2VzOworCQlzY3AtPmluZm9fcmVtID0gY2ItPmluZm87CisJCXNjcC0+c2Vnc2l6ZV9yZW0gPSBjYi0+c2Vnc2l6ZTsKKworCQlpZiAoKHNjcC0+c2VydmljZXNfcmVtICYgTlNQX0ZDX01BU0spID09IE5TUF9GQ19OT05FKQorCQkJc2NwLT5tYXhfd2luZG93ID0gZGVjbmV0X25vX2ZjX21heF9jd25kOworCisJCWlmIChza2ItPmxlbiA+IDApIHsKKwkJCXVuc2lnbmVkIGNoYXIgZGxlbiA9ICpza2ItPmRhdGE7CisJCQlpZiAoKGRsZW4gPD0gMTYpICYmIChkbGVuIDw9IHNrYi0+bGVuKSkgeworCQkJCXNjcC0+Y29ubmRhdGFfaW4ub3B0X29wdGwgPSBkbGVuOworCQkJCW1lbWNweShzY3AtPmNvbm5kYXRhX2luLm9wdF9kYXRhLCBza2ItPmRhdGEgKyAxLCBkbGVuKTsKKwkJCX0KKwkJfQorICAgICAgICAgICAgICAgIGRuX25zcF9zZW5kX2xpbmsoc2ssIEROX05PQ0hBTkdFLCAwKTsKKyAgICAgICAgICAgICAgICBpZiAoIXNvY2tfZmxhZyhzaywgU09DS19ERUFEKSkKKyAgICAgICAgICAgICAgICAJc2stPnNrX3N0YXRlX2NoYW5nZShzayk7CisgICAgICAgIH0KKworb3V0OgorICAgICAgICBrZnJlZV9za2Ioc2tiKTsKK30KKworc3RhdGljIHZv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gICAgICAgICAgICBTdGV2ZSBXaGl0ZWhvdXNlIDogRml4ZXMgdG8gYWxsb3cgImludHJhLWV0aGVybmV0IiBhbmQKKyAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgInJldHVybi10by1zZW5kZXIiIGJpdHMgb24gb3V0Z29pbmcKKyAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFja2V0cy4KKyAqCQlTdGV2ZSBXaGl0ZWhvdXNlIDogVGltZW91dHMgZm9yIGNhY2hlZCByb3V0ZXMuCisgKiAgICAgICAgICAgICAgU3RldmUgV2hpdGVob3VzZSA6IFVzZSBkc3QgY2FjaGUgZm9yIGlucHV0IHJvdXRlcyB0b28uCisgKiAgICAgICAgICAgICAgU3RldmUgV2hpdGVob3VzZSA6IEZpeGVkIGVycm9yIHZhbHVlcyBpbiBkbl9zZW5kX3NrYi4KKyAqICAgICAgICAgICAgICBTdGV2ZSBXaGl0ZWhvdXNlIDogUmV3b3JrIHJvdXRpbmcgZnVuY3Rpb25zIHRvIGJldHRlciBmaXQKKyAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgREVDbmV0IHJvdXRpbmcgZGVzaWduCisgKiAgICAgICAgICAgICAgQWxleGV5IEt1em5ldHNvdiA6IE5ldyBTTVAgbG9ja2luZworICogICAgICAgICAgICAgIFN0ZXZlIFdoaXRlaG91c2UgOiBNb3JlIFNNUCBsb2NraW5nIGNoYW5nZXMgJiBkbl9jYWNoZV9kdW1wKCkKKyAqICAgICAgICAgICAgICBTdGV2ZSBXaGl0ZWhvdXNlIDogUHJlcm91dGluZyBORiBob29rLCBub3cgcmVhbGx5IGlzIHByZXJvdXRpbmcuCisgKgkJCQkgICBGaXhlZCBwb3NzaWJsZSBza2IgbGVhayBpbiBydG5ldGxpbmsgZnVuY3MuCisgKiAgICAgICAgICAgICAgU3RldmUgV2hpdGVob3VzZSA6IERhdmUgTWlsbGVyJ3MgZHluYW1pYyBoYXNoIHRhYmxlIHNpemluZyBhbmQKKyAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQWxleGV5IEt1em5ldHNvdidzIGZpbmVyIGdyYWluZWQgbG9ja2luZworICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmcm9tIGlwdjQvcm91dGUuYy4KKyAqICAgICAgICAgICAgICBTdGV2ZSBXaGl0ZWhvdXNlIDogUm91dGluZyBpcyBub3cgc3RhcnRpbmcgdG8gbG9vayBsaWtlIGEKKyAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2Vuc2libGUgc2V0IG9mIGNvZGUgbm93LCBtYWlubHkgZHVlIHRvCisgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG15IGNvcHlpbmcgdGhlIElQdjQgcm91dGluZyBjb2RlLiBUaGUKKyAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaG9va3MgaGVyZSBhcmUgbW9kaWZpZWQgYW5kIHdpbGwgY29udGludWUKKyAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdG8gZXZvbHZlIGZvciBhIHdoaWxlLgorICogICAgICAgICAgICAgIFN0ZXZlIFdoaXRlaG91c2UgOiBSZWFsIFNNUCBhdCBsYXN0IDotKSBBbHNvIG5ldyBuZXRmaWx0ZXIKKyAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3R1ZmYuIExvb2sgb3V0IHJhdyBzb2NrZXRzIHlvdXIgZGF5cworICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcmUgbnVtYmVyZWQhCisgKiAgICAgICAgICAgICAgU3RldmUgV2hpdGVob3VzZSA6IEFkZGVkIHJldHVybi10by1zZW5kZXIgZnVuY3Rpb25zLiBBZGRlZAorICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBiYWNrbG9nIGNvbmdlc3Rpb24gbGV2ZWwgcmV0dXJuIGNvZGVzLgorICoJCVN0ZXZlIFdoaXRlaG91c2UgOiBGaXhlZCBidWcgd2hl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zdCwgCisJCQllcnIsIHNrYi0+cGt0X3R5cGUpOworCX0KKworCWlmICgoc2tiLT5wa3RfdHlwZSA9PSBQQUNLRVRfSE9TVCkgJiYgKGNiLT5ydF9mbGFncyAmIEROX1JUX0ZfUlFSKSkgeworCQlzd2l0Y2goY2ItPnJ0X2ZsYWdzICYgRE5fUlRfUEtUX01TSykgeworCQkJY2FzZSBETl9SVF9QS1RfU0hPUlQ6CisJCQkJcmV0dXJuIGRuX3JldHVybl9zaG9ydChza2IpOworCQkJY2FzZSBETl9SVF9QS1RfTE9ORzoKKwkJCQlyZXR1cm4gZG5fcmV0dXJuX2xvbmcoc2tiKTsKKwkJfQorCX0KKworCWtmcmVlX3NrYihza2IpOworCXJldHVybiBORVRfUlhfRFJPUDsKK30KKworc3RhdGljIGludCBkbl9yb3V0ZV9yeF9sb25nKHN0cnVjdCBza19idWZmICpza2IpCit7CisJc3RydWN0IGRuX3NrYl9jYiAqY2IgPSBETl9TS0JfQ0Ioc2tiKTsKKwl1bnNpZ25lZCBjaGFyICpwdHIgPSBza2ItPmRhdGE7CisKKwlpZiAoIXBza2JfbWF5X3B1bGwoc2tiLCAyMSkpIC8qIDIwIGZvciBsb25nIGhlYWRlciwgMSBmb3Igc2hvcnRlc3QgbnNwICovCisJCWdvdG8gZHJvcF9pdDsKKworCXNrYl9wdWxsKHNrYiwgMjApOworCXNrYi0+aC5yYXcgPSBza2ItPmRhdGE7CisKKyAgICAgICAgLyogRGVzdGluYXRpb24gaW5mbyAqLworICAgICAgICBwdHIgKz0gMjsKKwljYi0+ZHN0ID0gZG5faHRvbnMoZG5fZXRoMmRuKHB0cikpOworICAgICAgICBpZiAobWVtY21wKHB0ciwgZG5faGlvcmRfYWRkciwgNCkgIT0gMCkKKyAgICAgICAgICAgICAgICBnb3RvIGRyb3BfaXQ7CisgICAgICAgIHB0ciArPSA2OworCisKKyAgICAgICAgLyogU291cmNlIGluZm8gKi8KKyAgICAgICAgcHRyICs9IDI7CisJY2ItPnNyYyA9IGRuX2h0b25zKGRuX2V0aDJkbihwdHIpKTsKKyAgICAgICAgaWYgKG1lbWNtcChwdHIsIGRuX2hpb3JkX2FkZHIsIDQpICE9IDApCisgICAgICAgICAgICAgICAgZ290byBkcm9wX2l0OworICAgICAgICBwdHIgKz0gNjsKKyAgICAgICAgLyogT3RoZXIganVuayAqLworICAgICAgICBwdHIrKzsKKyAgICAgICAgY2ItPmhvcHMgPSAqcHRyKys7IC8qIFZpc2l0IENvdW50ICovCisKKwlyZXR1cm4gTkZfSE9PSyhQRl9ERUNuZXQsIE5GX0ROX1BSRV9ST1VUSU5HLCBza2IsIHNrYi0+ZGV2LCBOVUxMLCBkbl9yb3V0ZV9yeF9wYWNrZXQpOworCitkcm9wX2l0OgorCWtmcmVlX3NrYihza2IpOworCXJldHVybiBORVRfUlhfRFJPUDsKK30KKworCisKK3N0YXRpYyBpbnQgZG5fcm91dGVfcnhfc2hvcnQoc3RydWN0IHNrX2J1ZmYgKnNrYikKK3sKKwlzdHJ1Y3QgZG5fc2tiX2NiICpjYiA9IEROX1NLQl9DQihza2IpOworCXVuc2lnbmVkIGNoYXIgKnB0ciA9IHNrYi0+ZGF0YTsKKworCWlmICghcHNrYl9tYXlfcHVsbChza2IsIDYpKSAvKiA1IGZvciBzaG9ydCBoZWFkZXIgKyAxIGZvciBzaG9ydGVzdCBuc3AgKi8KKwkJZ290byBkcm9wX2l0OworCisJc2tiX3B1bGwoc2tiLCA1KTsKKwlza2ItPmgucmF3ID0gc2tiLT5kYXRhOworCisJY2ItPmRzdCA9ICooZG5fYWRkcmVzcyAqKXB0cjsKKyAgICAgICAgcHRyICs9IDI7CisgICAgICAgIGNiLT5zcmMgPSAqKGRuX2FkZHJlc3MgKilwdHI7CisgICAgICAgIHB0ciArPSAyOworICAgICAgICBjYi0+aG9wcyA9ICpwdHIgJiAweDNmOworCisJcmV0dXJuIE5GX0hPT0soUEZfREVDbmV0LCBORl9ETl9QUkVfUk9VVElORywgc2tiLCBza2ItPmRldi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XRlcl9oZWxsbyk7CisKKyAgICAgICAgICAgICAgICAJY2FzZSBETl9SVF9QS1RfRUVESDoKKwkJCQlyZXR1cm4gTkZfSE9PSyhQRl9ERUNuZXQsIE5GX0ROX0hFTExPLCBza2IsIHNrYi0+ZGV2LCBOVUxMLCBkbl9uZWlnaF9lbmRub2RlX2hlbGxvKTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgIH0gZWxzZSB7CisJCWlmIChkbi0+cGFybXMuc3RhdGUgIT0gRE5fREVWX1NfUlUpCisJCQlnb3RvIGR1bXBfaXQ7CisKKwkJc2tiX3B1bGwoc2tiLCAxKTsgLyogUHVsbCBmbGFncyAqLworCisgICAgICAgICAgICAgICAgc3dpdGNoKGZsYWdzICYgRE5fUlRfUEtUX01TSykgeworICAgICAgICAgICAgICAgIAljYXNlIEROX1JUX1BLVF9MT05HOgorICAgICAgICAgICAgICAgICAgICAgICAgCXJldHVybiBkbl9yb3V0ZV9yeF9sb25nKHNrYik7CisgICAgICAgICAgICAgICAgCWNhc2UgRE5fUlRfUEtUX1NIT1JUOgorICAgICAgICAgICAgICAgICAgICAgICAgCXJldHVybiBkbl9yb3V0ZV9yeF9zaG9ydChza2IpOworCQl9CisgICAgICAgIH0KKworZHVtcF9pdDoKKwlrZnJlZV9za2Ioc2tiKTsKK291dDoKKwlyZXR1cm4gTkVUX1JYX0RST1A7Cit9CisKK3N0YXRpYyBpbnQgZG5fb3V0cHV0KHN0cnVjdCBza19idWZmICpza2IpCit7CisJc3RydWN0IGRzdF9lbnRyeSAqZHN0ID0gc2tiLT5kc3Q7CisJc3RydWN0IGRuX3JvdXRlICpydCA9IChzdHJ1Y3QgZG5fcm91dGUgKilkc3Q7CisJc3RydWN0IG5ldF9kZXZpY2UgKmRldiA9IGRzdC0+ZGV2OworCXN0cnVjdCBkbl9za2JfY2IgKmNiID0gRE5fU0tCX0NCKHNrYik7CisJc3RydWN0IG5laWdoYm91ciAqbmVpZ2g7CisKKwlpbnQgZXJyID0gLUV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dBVEVXQVkpOworCisJCQlpZiAoZ3cgJiYgZ3cgIT0gbmgtPm5oX2d3KQorCQkJCXJldHVybiAxOworCQl9CisJCW5ocCA9IFJUTkhfTkVYVChuaHApOworCX0gZW5kZm9yX25leHRob3BzKGZpKTsKKworCXJldHVybiAwOworfQorCitzdGF0aWMgaW50IGRuX2ZpYl9kdW1wX2luZm8oc3RydWN0IHNrX2J1ZmYgKnNrYiwgdTMyIHBpZCwgdTMyIHNlcSwgaW50IGV2ZW50LAorICAgICAgICAgICAgICAgICAgICAgICAgdTggdGJfaWQsIHU4IHR5cGUsIHU4IHNjb3BlLCB2b2lkICpkc3QsIGludCBkc3RfbGVuLAorICAgICAgICAgICAgICAgICAgICAgICAgc3RydWN0IGRuX2ZpYl9pbmZvICpmaSkKK3sKKyAgICAgICAgc3RydWN0IHJ0bXNnICpydG07CisgICAgICAgIHN0cnVjdCBubG1zZ2hkciAqbmxoOworICAgICAgICB1bnNpZ25lZCBjaGFyICpiID0gc2tiLT50YWlsOworCisgICAgICAgIG5saCA9IE5MTVNHX1BVVChza2IsIHBpZCwgc2VxLCBldmVudCwgc2l6ZW9mKCpydG0pKTsKKyAgICAgICAgcnRtID0gTkxNU0dfREFUQShubGgpOworICAgICAgICBydG0tPnJ0bV9mYW1pbHkgPSBBRl9ERUNuZXQ7CisgICAgICAgIHJ0bS0+cnRtX2RzdF9sZW4gPSBkc3RfbGVuOworICAgICAgICBydG0tPnJ0bV9zcmNfbGVuID0gMDsKKyAgICAgICAgcnRtLT5ydG1fdG9zID0gMDsKKyAgICAgICAgcnRtLT5ydG1fdGFibGUgPSB0Yl9pZDsKKyAgICAgICAgcnRtLT5ydG1fZmxhZ3MgPSBmaS0+ZmliX2ZsYWdzOworICAgICAgICBydG0tPnJ0bV9zY29wZSA9IHNjb3BlOworCXJ0bS0+cnRtX3R5cGUgID0gdHlwZTsKKyAgICAgICAgaWYgKHJ0bS0+cnRtX2RzdF9sZW4pCisgICAgICAgICAgICAgICAgUlRBX1BVVChza2IsIFJUQV9EU1QsIDIsIGRzdCk7CisgICAgICAgIHJ0bS0+cnRtX3Byb3RvY29sID0gZmktPmZpYl9wcm90b2NvbDsKKyAgICAgICAgaWYgKGZpLT5maWJfcHJpb3JpdHkpCisgICAgICAgICAgICAgICAgUlRBX1BVVChza2IsIFJUQV9QUklPUklUWSwgNCwgJmZpLT5maWJfcHJpb3JpdHkpOworCWlmIChydG5ldGxpbmtfcHV0X21ldHJpY3Moc2tiLCBmaS0+ZmliX21ldHJpY3MpIDwgMCkKKwkJZ290byBydGF0dHJfZmFpbHVyZTsKKyAgICAgICAgaWYgKGZpLT5maWJfbmhzID09IDEpIHsKKyAgICAgICAgICAgICAgICBpZiAoZmktPmZpYl9uaC0+bmhfZ3cpCisgICAgICAgICAgICAgICAgICAgICAgICBSVEFfUFVUKHNrYiwgUlRBX0dBVEVXQVksIDIsICZmaS0+ZmliX25oLT5uaF9ndyk7CisgICAgICAgICAgICAgICAgaWYgKGZpLT5maWJfbmgtPm5oX29pZikKKyAgICAgICAgICAgICAgICAgICAgICAgIFJUQV9QVVQoc2tiLCBSVEFfT0lGLCBzaXplb2YoaW50KSwgJmZpLT5maWJfbmgtPm5oX29pZik7CisgICAgICAgIH0KKyAgICAgICAgaWYgKGZpLT5maWJfbmhzID4gMSkgeworICAgICAgICAgICAgICAgIHN0cnVjdCBydG5leHRob3AgKm5ocDsKKyAgICAgICAgICAgICAgICBzdHJ1Y3QgcnRhdHRyICptcF9oZWFkOworICAgICAgICAgICAgICAgIGlmIChza2JfdGFpbHJvb20oc2tiKSA8PSBSVEFfU1BBQ0UoMCkpCisgICAgICAgICAgICAgICAgICAgICAgICBnb3RvIHJ0YXR0cl9mYWlsdXJlOworICAgICAgICAgICAgICAgIG1wX2hlYWQgPSAoc3RydWN0IHJ0YXR0ciAqKXNrYl9wdXQoc2tiLCBSVEFfU1BBQ0UoMCkpOworCisgICAgICAgICAgICAgICAgZm9yX25leHRob3BzKGZpKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc2tiX3RhaWxyb29tKHNrYikgPCBSVEFfQUxJR04oUlRBX0FMSUdOKHNpemVvZigqbmhwKSkgKyA0KSkKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ290byBydGF0dHJfZmFpbHVyZTsKKyAgICAgICAgICAgICAgICAgICAgICAgIG5ocCA9IChzdHJ1Y3QgcnRuZXh0aG9wICopc2tiX3B1dChza2IsIFJUQV9BTElHTihzaXplb2YoKm5ocCkpKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIG5ocC0+cnRuaF9mbGFncyA9IG5oLT5uaF9mbGFncyAmIDB4RkY7CisgICAgICAgICAgICAgICAgICAgICAgICBuaHAtPnJ0bmhfaG9wcyA9IG5oLT5uaF93ZWlnaHQgLSAxOworICAgICAgICAgICAgICAgICAgICAgICAgbmhwLT5ydG5oX2lmaW5kZXggPSBuaC0+bmhfb2lmOworICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG5oLT5uaF9ndykKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgUlRBX1BVVChza2IsIFJUQV9HQVRFV0FZLCAyLCAmbmgtPm5oX2d3KTsKKyAgICAgICAgICAgICAgICAgICAgICAgIG5ocC0+cnRuaF9sZW4gPSBza2ItPnRhaWwgLSAodW5zaWduZWQgY2hhciAqKW5ocDsKKyAgICAgICAgICAgICAgICB9IGVuZGZvcl9uZXh0aG9wcyhmaSk7CisgICAgICAgICAgICAgICAgbXBfaGVhZC0+cnRhX3R5cGUgPSBSVEFfTVVMVElQQVRIOworICAgICAgICAgICAgICAgIG1wX2hlYWQtPnJ0YV9sZW4gPSBza2ItPnRhaWwgLSAodTgqKW1wX2hlYWQ7CisgICAgICAgIH0KKworICAgICAgICBubGgtPm5sbXNnX2xlbiA9IHNrYi0+dGFpbCAtIGI7CisgICAgICAgIHJldHVybiBza2ItPmxlbjsKKworCitubG1zZ19mYWlsdXJlOgorcnRhdHRyX2ZhaWx1cmU6CisgICAgICAgIHNrYl90cmltKHNrYiwgYiAtIHNrYi0+ZGF0YSk7CisgICAgICAgIHJldHVybiAtMTsKK30KKworCitzdGF0aWMgdm9pZCBkbl9ydG1zZ19maWIoaW50IGV2ZW50LCBzdHJ1Y3QgZG5fZmliX25vZGUgKmYsIGludCB6LCBpbnQgdGJfaWQsCisgICAgICAgICAgICAgICAgICAgICAgICBzdHJ1Y3Qgbmxtc2doZHIgKm5saCwgc3RydWN0IG5ldGxpbmtfc2tiX3Bhcm1zICpyZXEpCit7CisgICAgICAgIHN0cnVjdCBza19idWZmICpza2I7CisgICAgICAgIHUzMiBwaWQgPSByZXEgPyByZXEtPnBpZCA6IDA7CisgICAgICAgIGludCBzaXplID0gTkxNU0dfU1BBQ0Uoc2l6ZW9mKHN0cnVjdCBydG1zZykgKyAyNTYpOworCisgICAgICAgIHNrYiA9IGFsbG9jX3NrYihzaXplLCBHRlBfS0VSTkVMKTsKKyAgICAgICAgaWYgKCFza2IpCisgICAgICAgICAgICAgICAgcmV0dXJuOworCisgICAgICAgIGlmIChkbl9maWJfZHVtcF9pbmZvKHNrYiwgcGlkLCBubGgtPm5sbXNnX3NlcSwgZXZlbnQsIHRiX2lkLCAKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZi0+Zm5fdHlwZSwgZi0+Zm5fc2NvcGUsICZmLT5mbl9rZXksIHosIAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBETl9GSUJfSU5GTyhmKSkgPCAwKSB7CisgICAgICAgICAgICAgICAga2ZyZWVfc2tiKHNrYik7CisgICAgICAgICAgICAgICAgcmV0dXJuOworICAgICAgICB9CisgICAgICAgIE5FVExJTktfQ0Ioc2tiKS5kc3RfZ3JvdXBzID0gUlRNR1JQX0RFQ25ldF9ST1VURTsKKyAgICAgICAgaWYgKG5saC0+bmxtc2dfZmxhZ3MgJiBOTE1fRl9FQ0hPKQorICAgICAgICAgICAgICAgIGF0b21pY19pbmMoJnNrYi0+dXNlcnMpOworICAgICAgIC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CkKKyAgICAgICAgICAgICAgICByZXR1cm4gTlVMTDsKKworICAgICAgICBpZiAoZG5fZmliX3RhYmxlc1tuXSkgCisgICAgICAgICAgICAgICAgcmV0dXJuIGRuX2ZpYl90YWJsZXNbbl07CisKKyAgICAgICAgaWYgKCFjcmVhdGUpCisgICAgICAgICAgICAgICAgcmV0dXJuIE5VTEw7CisKKyAgICAgICAgaWYgKGluX2ludGVycnVwdCgpICYmIG5ldF9yYXRlbGltaXQoKSkgeworICAgICAgICAgICAgICAgIHByaW50ayhLRVJOX0RFQlVHICJERUNuZXQ6IEJVRyEgQXR0ZW1wdCB0byBjcmVhdGUgcm91dGluZyB0YWJsZSBmcm9tIGludGVycnVwdFxuIik7IAorICAgICAgICAgICAgICAgIHJldHVybiBOVUxMOworICAgICAgICB9CisgICAgICAgIGlmICgodCA9IGttYWxsb2Moc2l6ZW9mKHN0cnVjdCBkbl9maWJfdGFibGUpICsgc2l6ZW9mKHN0cnVjdCBkbl9oYXNoKSwgR0ZQX0tFUk5FTCkpID09IE5VTEwpCisgICAgICAgICAgICAgICAgcmV0dXJuIE5VTEw7CisKKyAgICAgICAgbWVtc2V0KHQsIDAsIHNpemVvZihzdHJ1Y3QgZG5fZmliX3RhYmxlKSk7CisKKyAgICAgICAgdC0+biA9IG47CisgICAgICAgIHQtPmluc2VydCA9IGRuX2ZpYl90YWJsZV9pbnNlcnQ7CisgICAgICAgIHQtPmRlbGV0ZSA9IGRuX2ZpYl90YWJsZV9kZWxldGU7CisgICAgICAgIHQtPmxvb2t1cCA9IGRuX2ZpYl90YWJsZV9sb29rdXA7CisgICAgICAgIHQtPmZsdXNoICA9IGRuX2ZpYl90YWJsZV9mbHVzaDsKKyAgICAgICAgdC0+ZHVtcCA9IGRuX2ZpYl90YWJsZV9kdW1wOworCW1lbXNldCh0LT5kYXRhLCAwLCBzaXplb2Yoc3RydWN0IGRuX2hhc2gpKTsKKyAgICAgICAgZG5fZmliX3RhYmxlc1tuXSA9IHQ7CisKKyAgICAgICAgcmV0dXJuIHQ7Cit9CisKK3N0YXRpYyB2b2lkIGRuX2ZpYl9kZWxfdHJlZShpbnQgbikKK3sKKyAgICAgICAgc3RydWN0IGRuX2ZpYl90YWJsZSAqdDsKKworICAgICAgICB3cml0ZV9sb2NrKCZkbl9maWJfdGFibGVzX2xvY2spOworICAgICAgICB0ID0gZG5fZmliX3RhYmxlc1tuXTsKKyAgICAgICAgZG5fZmliX3RhYmxlc1tuXSA9IE5VTEw7CisgICAgICAgIHdyaXRlX3VubG9jaygmZG5fZmliX3RhYmxlc19sb2NrKTsKKworICAgICAgICBpZiAodCkgeworICAgICAgICAgICAgICAgIGtmcmVlKHQpOworICAgICAgICB9Cit9CisKK3N0cnVjdCBkbl9maWJfdGFibGUgKmRuX2ZpYl9lbXB0eV90YWJsZSh2b2lkKQoreworICAgICAgICBpbnQgaWQ7CisKKyAgICAgICAgZm9yKGlkID0gUlRfVEFCTEVfTUlOOyBpZCA8PSBSVF9UQUJMRV9NQVg7IGlkKyspCisgICAgICAgICAgICAgICAgaWYgKGRuX2ZpYl90YWJsZXNbaWRdID09IE5VTEwpCisgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZG5fZmliX2dldF90YWJsZShpZCwgMSk7CisgICAgICAgIHJldHVybiBOVUxMOworfQorCit2b2lkIF9faW5pdCBkbl9maWJfdGFibGVfaW5pdCh2b2lkKQoreworCWRuX2hhc2hfa21lbSA9IGttZW1fY2FjaGVfY3JlYXRlKCJkbl9maWJfaW5mb19jYWNoZSIsCisJCQkJCXNpemVvZihzdHJ1Y3QgZG5fZmliX2luZm8pLAorCQkJCQkwLCBTTEFCX0hXQ0FDSEVfQUxJR04sCisJCQkJCU5VTEwsIE5VTEwpOworfQorCit2b2lkIF9fZXhpdCBkbl9maWJfdGFibGVfY2xlYW51cCh2b2lkKQoreworCWludCBpOworCisJZm9yIChpID0gUlRfVEFCTEVfTUlOOyBpIDw9IFJUX1RBQkxFX01BWDsgKytpKQorCQlkbl9maWJf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CWVyciA9IHNvY2tfZXJyb3Ioc2spID8gOiAtRUNPTk5BQk9SVEVEOworCXNvY2stPnN0YXRlID0gU1NfVU5DT05ORUNURUQ7CisJaWYgKHNrLT5za19wcm90LT5kaXNjb25uZWN0KHNrLCBmbGFncykpCisJCXNvY2stPnN0YXRlID0gU1NfRElTQ09OTkVDVElORzsKKwlnb3RvIG91dDsKK30KKworLyoKKyAqCUFjY2VwdCBhIHBlbmRpbmcgY29ubmVjdGlvbi4gVGhlIFRDUCBsYXllciBub3cgZ2l2ZXMgQlNEIHNlbWFudGljcy4KKyAqLworCitpbnQgaW5ldF9hY2NlcHQoc3RydWN0IHNvY2tldCAqc29jaywgc3RydWN0IHNvY2tldCAqbmV3c29jaywgaW50IGZsYWdzKQoreworCXN0cnVjdCBzb2NrICpzazEgPSBzb2NrLT5zazsKKwlpbnQgZXJyID0gLUVJTlZBTDsKKwlzdHJ1Y3Qgc29jayAqc2syID0gc2sxLT5za19wcm90LT5hY2NlcHQoc2sxLCBmbGFncywgJmVycik7CisKKwlpZiAoIXNrMikKKwkJZ290byBkb19lcnI7CisKKwlsb2NrX3NvY2soc2syKTsKKworCUJVR19UUkFQKCgxIDw8IHNrMi0+c2tfc3RhdGUpICYKKwkJIChUQ1BGX0VTVEFCTElTSEVEIHwgVENQRl9DTE9TRV9XQUlUIHwgVENQRl9DTE9TRSkpOworCisJc29ja19ncmFmdChzazIsIG5ld3NvY2spOworCisJbmV3c29jay0+c3RhdGUgPSBTU19DT05ORUNURUQ7CisJZXJyID0gMDsKKwlyZWxlYXNlX3NvY2soc2syKTsKK2RvX2VycjoKKwlyZXR1cm4gZXJyOworfQorCisKKy8qCisgKglUaGlzIGRvZXMgYm90aCBwZWVybmFtZSBhbmQgc29ja25hbWUuCisgKi8KK2ludCBpbmV0X2dldG5hbWUoc3RydWN0IHNvY2tldCAqc29jaywgc3RydWN0IHNvY2thZGRyICp1YWRkciwKKwkJCWludCAqdWFkZHJfbGVuLCBpbnQgcGVlcikKK3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zZXRzb2Nrb3B0LAorCS5nZXRzb2Nrb3B0ID0Jc29ja19jb21tb25fZ2V0c29ja29wdCwKKwkuc2VuZG1zZyA9CWluZXRfc2VuZG1zZywKKwkucmVjdm1zZyA9CXNvY2tfY29tbW9uX3JlY3Ztc2csCisJLm1tYXAgPQkJc29ja19ub19tbWFwLAorCS5zZW5kcGFnZSA9CWluZXRfc2VuZHBhZ2UsCit9OworCitzdGF0aWMgc3RydWN0IG5ldF9wcm90b19mYW1pbHkgaW5ldF9mYW1pbHlfb3BzID0geworCS5mYW1pbHkgPSBQRl9JTkVULAorCS5jcmVhdGUgPSBpbmV0X2NyZWF0ZSwKKwkub3duZXIJPSBUSElTX01PRFVMRSwKK307CisKKworZXh0ZXJuIHZvaWQgdGNwX2luaXQodm9pZCk7CitleHRlcm4gdm9pZCB0Y3BfdjRfaW5pdChzdHJ1Y3QgbmV0X3Byb3RvX2ZhbWlseSAqKTsKKworLyogVXBvbiBzdGFydHVwIHdlIGluc2VydCBhbGwgdGhlIGVsZW1lbnRzIGluIGluZXRzd19hcnJheVtdIGludG8KKyAqIHRoZSBsaW5rZWQgbGlzdCBpbmV0c3cuCisgKi8KK3N0YXRpYyBzdHJ1Y3QgaW5ldF9wcm90b3N3IGluZXRzd19hcnJheVtdID0KK3sKKyAgICAgICAgeworICAgICAgICAgICAgICAgIC50eXBlID0gICAgICAgU09DS19TVFJFQU0sCisgICAgICAgICAgICAgICAgLnByb3RvY29sID0gICBJUFBST1RPX1RDUCwKKyAgICAgICAgICAgICAgICAucHJvdCA9ICAgICAgICZ0Y3BfcHJvdCwKKyAgICAgICAgICAgICAgICAub3BzID0gICAgICAgICZpbmV0X3N0cmVhbV9vcHMsCisgICAgICAgICAgICAgICAgLmNhcGFiaWxpdHkgPSAtMSwKKyAgICAgICAgICAgICAgICAubm9fY2hlY2sgPSAgIDAsCisgICAgICAgICAgICAgICAgLmZsYWdzID0gICAgICBJTkVUX1BST1RPU1dfUEVSTUFORU5ULAorICAgICAgICB9LAorCisgICAgICAgIHsKKyAgICAgICAgICAgICAgICAudHlwZSA9ICAgICAgIFNPQ0tfREdSQU0sCisgICAgICAgICAgICAgICAgLnByb3RvY29sID0gICBJUFBST1RPX1VEUCwKKyAgICAgICAgICAgICAgICAucHJvdCA9ICAgICAgICZ1ZHBfcHJvdCwKKyAgICAgICAgICAgICAgICAub3BzID0gICAgICAgICZpbmV0X2RncmFtX29wcywKKyAgICAgICAgICAgICAgICAuY2FwYWJpbGl0eSA9IC0xLAorICAgICAgICAgICAgICAgIC5ub19jaGVjayA9ICAgVURQX0NTVU1fREVGQVVMVCwKKyAgICAgICAgICAgICAgICAuZmxhZ3MgPSAgICAgIElORVRfUFJPVE9TV19QRVJNQU5FTlQsCisgICAgICAgfSwKKyAgICAgICAgCisKKyAgICAgICB7CisgICAgICAgICAgICAgICAudHlwZSA9ICAgICAgIFNPQ0tfUkFXLAorICAgICAgICAgICAgICAgLnByb3RvY29sID0gICBJUFBST1RPX0lQLAkvKiB3aWxkIGNhcmQgKi8KKyAgICAgICAgICAgICAgIC5wcm90ID0gICAgICAgJnJhd19wcm90LAorICAgICAgICAgICAgICAgLm9wcyA9ICAgICAgICAmaW5ldF9zb2NrcmF3X29wcywKKyAgICAgICAgICAgICAgIC5jYXBhYmlsaXR5ID0gQ0FQX05FVF9SQVcsCisgICAgICAgICAgICAgICAubm9fY2hlY2sgPSAgIFVEUF9DU1VNX0RFRkFVTFQsCisgICAgICAgICAgICAgICAuZmxhZ3MgPSAgICAgIElORVRfUFJPVE9TV19SRVVTRSwKKyAgICAgICB9Cit9OworCisjZGVmaW5lIElORVRTV19BUlJBWV9MRU4gKHNpemVvZihpbmV0c3dfYXJyYXkpIC8gc2l6ZW9mKHN0cnVjdCBpbmV0X3Byb3Rvc3cpKQorCit2b2lkIGluZXRfcmVnaXN0ZXJfcHJvdG9zdyhzdHJ1Y3QgaW5ldF9wcm90b3N3ICpwKQoreworCXN0cnVjdCBsaXN0X2hlYWQgKmxoOworCXN0c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MTI3c1xuIiwgYmYpOworb3V0OgorCXJldHVybiAwOworfQorCitzdGF0aWMgc3RydWN0IHNlcV9vcGVyYXRpb25zIGZpYl9zZXFfb3BzID0geworCS5zdGFydCAgPSBmaWJfc2VxX3N0YXJ0LAorCS5uZXh0ICAgPSBmaWJfc2VxX25leHQsCisJLnN0b3AgICA9IGZpYl9zZXFfc3RvcCwKKwkuc2hvdyAgID0gZmliX3NlcV9zaG93LAorfTsKKworc3RhdGljIGludCBmaWJfc2VxX29wZW4oc3RydWN0IGlub2RlICppbm9kZSwgc3RydWN0IGZpbGUgKmZpbGUpCit7CisJc3RydWN0IHNlcV9maWxlICpzZXE7CisJaW50IHJjID0gLUVOT01FTTsKKwlzdHJ1Y3QgZmliX2l0ZXJfc3RhdGUgKnMgPSBrbWFsbG9jKHNpemVvZigqcyksIEdGUF9LRVJORUwpOworICAgICAgIAorCWlmICghcykKKwkJZ290byBvdXQ7CisKKwlyYyA9IHNlcV9vcGVuKGZpbGUsICZmaWJfc2VxX29wcyk7CisJaWYgKHJjKQorCQlnb3RvIG91dF9rZnJlZTsKKworCXNlcQkgICAgID0gZmlsZS0+cHJpdmF0ZV9kYXRhOworCXNlcS0+cHJpdmF0ZSA9IHM7CisJbWVtc2V0KHMsIDAsIHNpemVvZigqcykpOworb3V0OgorCXJldHVybiByYzsKK291dF9rZnJlZToKKwlrZnJlZShzKTsKKwlnb3RvIG91dDsKK30KKworc3RhdGljIHN0cnVjdCBmaWxlX29wZXJhdGlvbnMgZmliX3NlcV9mb3BzID0geworCS5vd25lcgkJPSBUSElTX01PRFVMRSwKKwkub3BlbiAgICAgICAgICAgPSBmaWJfc2VxX29wZW4sCisJLnJlYWQgICAgICAgICAgID0gc2VxX3JlYWQsCisJLmxsc2VlayAgICAgICAgID0gc2VxX2xzZWVrLAorCS5yZWxlYXNlCT0gc2VxX3JlbGVhc2VfcHJpdmF0ZSwKK307CisKK2ludCBfX2luaXQgZmliX3Byb2NfaW5pdCh2b2lkKQoreworC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YgKCFpbl9kZXYtPmRlYWQpCisJCWlwX3J0X211bHRpY2FzdF9ldmVudChpbl9kZXYpOworb3V0OgorCXJldHVybjsKK30KKworLyoKKyAqCUEgc29ja2V0IGhhcyBsZWZ0IGEgbXVsdGljYXN0IGdyb3VwIG9uIGRldmljZSBkZXYKKyAqLworCit2b2lkIGlwX21jX2RlY19ncm91cChzdHJ1Y3QgaW5fZGV2aWNlICppbl9kZXYsIHUzMiBhZGRyKQoreworCXN0cnVjdCBpcF9tY19saXN0ICppLCAqKmlwOworCQorCUFTU0VSVF9SVE5MKCk7CisJCisJZm9yIChpcD0maW5fZGV2LT5tY19saXN0OyAoaT0qaXApIT1OVUxMOyBpcD0maS0+bmV4dCkgeworCQlpZiAoaS0+bXVsdGlhZGRyPT1hZGRyKSB7CisJCQlpZiAoLS1pLT51c2VycyA9PSAwKSB7CisJCQkJd3JpdGVfbG9ja19iaCgmaW5fZGV2LT5tY19saXN0X2xvY2spOworCQkJCSppcCA9IGktPm5leHQ7CisJCQkJd3JpdGVfdW5sb2NrX2JoKCZpbl9kZXYtPm1jX2xpc3RfbG9jayk7CisJCQkJaWdtcF9ncm91cF9kcm9wcGVkKGkpOworCisJCQkJaWYgKCFpbl9kZXYtPmRlYWQpCisJCQkJCWlwX3J0X211bHRpY2FzdF9ldmVudChpbl9kZXYpOworCisJCQkJaXBfbWFfcHV0KGkpOworCQkJCXJldHVybjsKKwkJCX0KKwkJCWJyZWFrOworCQl9CisJfQorfQorCisvKiBEZXZpY2UgZ29pbmcgZG93biAqLworCit2b2lkIGlwX21jX2Rvd24oc3RydWN0IGluX2RldmljZSAqaW5fZGV2KQoreworCXN0cnVjdCBpcF9tY19saXN0ICppOworCisJQVNTRVJUX1JUTkwoKTsKKworCWZvciAoaT1pbl9kZXYtPm1jX2xpc3Q7IGk7IGk9aS0+bmV4dCkKKwkJaWdtcF9ncm91cF9kcm9wcGVkKGkpOworCisjaWZkZWYgQ09ORklHX0lQX01VTFRJQ0FTVAorCWluX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xpc3RfbG9jayk7CisJc3Bpbl9sb2NrX2luaXQoJmluX2Rldi0+bWNfdG9tYl9sb2NrKTsKK30KKworLyogRGV2aWNlIGdvaW5nIHVwICovCisKK3ZvaWQgaXBfbWNfdXAoc3RydWN0IGluX2RldmljZSAqaW5fZGV2KQoreworCXN0cnVjdCBpcF9tY19saXN0ICppOworCisJQVNTRVJUX1JUTkwoKTsKKworCWlwX21jX2luY19ncm91cChpbl9kZXYsIElHTVBfQUxMX0hPU1RTKTsKKworCWZvciAoaT1pbl9kZXYtPm1jX2xpc3Q7IGk7IGk9aS0+bmV4dCkKKwkJaWdtcF9ncm91cF9hZGRlZChpKTsKK30KKworLyoKKyAqCURldmljZSBpcyBhYm91dCB0byBiZSBkZXN0cm95ZWQ6IGNsZWFuIHVwLgorICovCisKK3ZvaWQgaXBfbWNfZGVzdHJveV9kZXYoc3RydWN0IGluX2RldmljZSAqaW5fZGV2KQoreworCXN0cnVjdCBpcF9tY19saXN0ICppOworCisJQVNTRVJUX1JUTkwoKTsKKworCS8qIERlYWN0aXZhdGUgdGltZXJzICovCisJaXBfbWNfZG93bihpbl9kZXYpOworCisJd3JpdGVfbG9ja19iaCgmaW5fZGV2LT5tY19saXN0X2xvY2spOworCXdoaWxlICgoaSA9IGluX2Rldi0+bWNfbGlzdCkgIT0gTlVMTCkgeworCQlpbl9kZXYtPm1jX2xpc3QgPSBpLT5uZXh0OworCQl3cml0ZV91bmxvY2tfYmgoJmluX2Rldi0+bWNfbGlzdF9sb2NrKTsKKworCQlpZ21wX2dyb3VwX2Ryb3BwZWQoaSk7CisJCWlwX21hX3B1dChpKTsKKworCQl3cml0ZV9sb2NrX2JoKCZpbl9kZXYtPm1jX2xpc3RfbG9jayk7CisJfQorCXdyaXRlX3VubG9ja19iaCgmaW5fZGV2LT5tY19saXN0X2xvY2spOworfQorCitzdGF0aWMgc3RydWN0IGluX2RldmljZSAqIGlwX21jX2ZpbmRfZGV2KHN0cnVjdCBpcF9tcmVxbiAqaW1y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KyNkZWZpbmUgQ09ORl9JTlRFUl9USU1FT1VUCShIWi8yKQkvKiBJbnRlci1kZXZpY2UgdGltZW91dDogMS8yIHNlY29uZCAqLworI2RlZmluZSBDT05GX0JBU0VfVElNRU9VVAkoSFoqMikJLyogSW5pdGlhbCB0aW1lb3V0OiAyIHNlY29uZHMgKi8KKyNkZWZpbmUgQ09ORl9USU1FT1VUX1JBTkRPTQkoSFopCS8qIE1heGltdW0gYW1vdW50IG9mIHJhbmRvbWl6YXRpb24gKi8KKyNkZWZpbmUgQ09ORl9USU1FT1VUX01VTFQJKjcvNAkvKiBSYXRlIG9mIHRpbWVvdXQgZ3Jvd3RoICovCisjZGVmaW5lIENPTkZfVElNRU9VVF9NQVgJKEhaKjMwKQkvKiBNYXhpbXVtIGFsbG93ZWQgdGltZW91dCAqLworI2RlZmluZSBDT05GX05BTUVTRVJWRVJTX01BWCAgIDMgICAgICAgLyogTWF4aW11bSBudW1iZXIgb2YgbmFtZXNlcnZlcnMgIAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC0gJzMnIGZyb20gcmVzb2x2LmggKi8KKworCisvKgorICogUHVibGljIElQIGNvbmZpZ3VyYXRpb24KKyAqLworCisvKiBUaGlzIGlzIHVzZWQgYnkgcGxhdGZvcm1zIHdoaWNoIG1pZ2h0IGJlIGFibGUgdG8gc2V0IHRoZSBpcGNvbmZpZworICogdmFyaWFibGVzIHVzaW5nIGZpcm13YXJlIGVudmlyb25tZW50IHZhcnMuICBJZiB0aGlzIGlzIHNldCwgaXQgd2lsbAorICogaWdub3JlIHN1Y2ggZmlybXdhcmUgdmFyaWFibGVzLgorICovCitpbnQgaWNfc2V0X21hbnVhbGx5IF9faW5pdGRhdGEgPSAwOwkJLyogSVBjb25maWcgcGFyYW1ldGVycyBzZXQgbWFudWFsbHkgKi8KKworc3RhdGljIGludCBpY19lbmFibGUgX19pbml0ZGF0YSA9IDA7CQkvKiBJUCBjb25maWcgZW5hYmxlZD8gK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CAqLworCQkJNDAsCS8qIE5JUyBkb21haW4gbmFtZSAqLworCQl9OworCisJCSplKysgPSA1NTsJLyogUGFyYW1ldGVyIHJlcXVlc3QgbGlzdCAqLworCQkqZSsrID0gc2l6ZW9mKGljX3JlcV9wYXJhbXMpOworCQltZW1jcHkoZSwgaWNfcmVxX3BhcmFtcywgc2l6ZW9mKGljX3JlcV9wYXJhbXMpKTsKKwkJZSArPSBzaXplb2YoaWNfcmVxX3BhcmFtcyk7CisJfQorCisJKmUrKyA9IDI1NTsJLyogRW5kIG9mIHRoZSBsaXN0ICovCit9CisKKyNlbmRpZiAvKiBJUENPTkZJR19ESENQICovCisKK3N0YXRpYyB2b2lkIF9faW5pdCBpY19ib290cF9pbml0X2V4dCh1OCAqZSkKK3sKKwltZW1jcHkoZSwgaWNfYm9vdHBfY29va2llLCA0KTsJLyogUkZDMTA0OCBNYWdpYyBDb29raWUgKi8KKwllICs9IDQ7CisJKmUrKyA9IDE7CQkvKiBTdWJuZXQgbWFzayByZXF1ZXN0ICovCisJKmUrKyA9IDQ7CisJZSArPSA0OworCSplKysgPSAzOwkJLyogRGVmYXVsdCBnYXRld2F5IHJlcXVlc3QgKi8KKwkqZSsrID0gNDsKKwllICs9IDQ7CisJKmUrKyA9IDU7CQkvKiBOYW1lIHNlcnZlciByZXF1ZXN0ICovCisJKmUrKyA9IDg7CisJZSArPSA4OworCSplKysgPSAxMjsJCS8qIEhvc3QgbmFtZSByZXF1ZXN0ICovCisJKmUrKyA9IDMyOworCWUgKz0gMzI7CisJKmUrKyA9IDQwOwkJLyogTklTIERvbWFpbiBuYW1lIHJlcXVlc3QgKi8KKwkqZSsrID0gMzI7CisJZSArPSAzMjsKKwkqZSsrID0gMTc7CQkvKiBCb290IHBhdGggKi8KKwkqZSsrID0gNDA7CisJZSArPSA0MDsKKworCSplKysgPSA1NzsJCS8qIHNldCBleHRlbnNpb24gYnVmZmVyIHNpemUgZm9yIHJlcGx5ICovIAorCSplKysgPSAyOworCSplKysgP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X2hlYWRlcihza2IsIGRldiwgbnRvaHMoc2tiLT5wcm90b2NvbCksIGRldi0+YnJvYWRjYXN0LCBkZXYtPmRldl9hZGRyLCBza2ItPmxlbikgPCAwKSB8fAorCSAgICBkZXZfcXVldWVfeG1pdChza2IpIDwgMCkKKwkJcHJpbnRrKCJFIik7Cit9CisKKworLyoKKyAqICBDb3B5IEJPT1RQLXN1cHBsaWVkIHN0cmluZyBpZiBub3QgYWxyZWFkeSBzZXQuCisgKi8KK3N0YXRpYyBpbnQgX19pbml0IGljX2Jvb3RwX3N0cmluZyhjaGFyICpkZXN0LCBjaGFyICpzcmMsIGludCBsZW4sIGludCBtYXgpCit7CisJaWYgKCFsZW4pCisJCXJldHVybiAwOworCWlmIChsZW4gPiBtYXgtMSkKKwkJbGVuID0gbWF4LTE7CisJbWVtY3B5KGRlc3QsIHNyYywgbGVuKTsKKwlkZXN0W2xlbl0gPSAnXDAnOworCXJldHVybiAxOworfQorCisKKy8qCisgKiAgUHJvY2VzcyBCT09UUCBleHRlbnNpb25zLgorICovCitzdGF0aWMgdm9pZCBfX2luaXQgaWNfZG9fYm9vdHBfZXh0KHU4ICpleHQpCit7CisgICAgICAgdTggc2VydmVyczsKKyAgICAgICBpbnQgaTsKKworI2lmZGVmIElQQ09ORklHX0RFQlVHCisJdTggKmM7CisKKwlwcmludGsoIkRIQ1AvQk9PVFA6IEdvdCBleHRlbnNpb24gJWQ6IiwqZXh0KTsKKwlmb3IoYz1leHQrMjsgYzxleHQrMitleHRbMV07IGMrKykKKwkJcHJpbnRrKCIgJTAyeCIsICpjKTsKKwlwcmludGsoIlxuIik7CisjZW5kaWYKKworCXN3aXRjaCAoKmV4dCsrKSB7CisJCWNhc2UgMToJCS8qIFN1Ym5ldCBtYXNrICovCisJCQlpZiAoaWNfbmV0bWFzayA9PSBJTkFERFJfTk9ORSkKKwkJCQltZW1jcHkoJmljX25ldG1hc2ssIGV4dCsxLCA0KTsKKwkJCWJyZWFrOworCQljYXNlIDM6CQk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CWNvbnRpbnVlOworCisJCWlmICghIC0tcmV0cmllcykgeworCQkJcHJpbnRrKCIgdGltZWQgb3V0IVxuIik7CisJCQlicmVhazsKKwkJfQorCisJCWQgPSBpY19maXJzdF9kZXY7CisKKwkJdGltZW91dCA9IHRpbWVvdXQgQ09ORl9USU1FT1VUX01VTFQ7CisJCWlmICh0aW1lb3V0ID4gQ09ORl9USU1FT1VUX01BWCkKKwkJCXRpbWVvdXQgPSBDT05GX1RJTUVPVVRfTUFYOworCisJCXByaW50aygiLiIpOworCX0KKworI2lmZGVmIElQQ09ORklHX0JPT1RQCisJaWYgKGRvX2Jvb3RwKQorCQlpY19ib290cF9jbGVhbnVwKCk7CisjZW5kaWYKKyNpZmRlZiBJUENPTkZJR19SQVJQCisJaWYgKGRvX3JhcnApCisJCWljX3JhcnBfY2xlYW51cCgpOworI2VuZGlmCisKKwlpZiAoIWljX2dvdF9yZXBseSkKKwkJcmV0dXJuIC0xOworCisJcHJpbnRrKCJJUC1Db25maWc6IEdvdCAlcyBhbnN3ZXIgZnJvbSAldS4ldS4ldS4ldSwgIiwKKwkJKChpY19nb3RfcmVwbHkgJiBJQ19SQVJQKSA/ICJSQVJQIiAKKwkJIDogKGljX3Byb3RvX2VuYWJsZWQgJiBJQ19VU0VfREhDUCkgPyAiREhDUCIgOiAiQk9PVFAiKSwKKwkJTklQUVVBRChpY19zZXJ2YWRkcikpOworCXByaW50aygibXkgYWRkcmVzcyBpcyAldS4ldS4ldS4ldVxuIiwgTklQUVVBRChpY19teWFkZHIpKTsKKworCXJldHVybiAwOworfQorCisjZW5kaWYgLyogSVBDT05GSUdfRFlOQU1JQyAqLworCisjaWZkZWYgQ09ORklHX1BST0NfRlMKKworc3RhdGljIGludCBwbnBfc2VxX3Nob3coc3RydWN0IHNlcV9maWxlICpzZXEsIHZvaWQgKnYpCit7CisJaW50IGk7CisKKwlpZiAoaWNfcHJvdG9fdXNlZCAmIElDX1BST1RPKQorCQlzZXFfcHJpbnRmKHNlcSwg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0dXJuIDE7CisJfQorI2VuZGlmCisjaWZkZWYgSVBDT05GSUdfRFlOQU1JQworCWVsc2UgaWYgKCFzdHJjbXAobmFtZSwgImJvdGgiKSkgeworCQlpY19wcm90b19lbmFibGVkICY9IH5JQ19VU0VfREhDUDsgLyogYmFja3dhcmQgY29tcGF0IDotKCAqLworCQlyZXR1cm4gMTsKKwl9CisjZW5kaWYKKwlyZXR1cm4gMDsKK30KKworc3RhdGljIGludCBfX2luaXQgaXBfYXV0b19jb25maWdfc2V0dXAoY2hhciAqYWRkcnMpCit7CisJY2hhciAqY3AsICppcCwgKmRwOworCWludCBudW0gPSAwOworCisJaWNfc2V0X21hbnVhbGx5ID0gMTsKKworCWljX2VuYWJsZSA9ICgqYWRkcnMgJiYgCisJCShzdHJjbXAoYWRkcnMsICJvZmYiKSAhPSAwKSAmJiAKKwkJKHN0cmNtcChhZGRycywgIm5vbmUiKSAhPSAwKSk7CisJaWYgKCFpY19lbmFibGUpCisJCXJldHVybiAxOworCisJaWYgKGljX3Byb3RvX25hbWUoYWRkcnMpKQorCQlyZXR1cm4gMTsKKworCS8qIFBhcnNlIHRoZSB3aG9sZSBzdHJpbmcgKi8KKwlpcCA9IGFkZHJzOworCXdoaWxlIChpcCAmJiAqaXApIHsKKwkJaWYgKChjcCA9IHN0cmNocihpcCwgJzonKSkpCisJCQkqY3ArKyA9ICdcMCc7CisJCWlmIChzdHJsZW4oaXApID4gMCkgeworCQkJREJHKCgiSVAtQ29uZmlnOiBQYXJhbWV0ZXIgIyVkOiBgJXMnXG4iLCBudW0sIGlwKSk7CisJCQlzd2l0Y2ggKG51bSkgeworCQkJY2FzZSAwOgorCQkJCWlmICgoaWNfbXlhZGRyID0gaW5fYXRvbihpcCkpID09IElOQUREUl9BTlkpCisJCQkJCWljX215YWRkciA9IElOQUREUl9OT05FOworCQkJCWJyZWFrOworCQkJY2FzZSAxOgorCQkJCWlmICgoaWNfc2VydmFkZHIgPSBpbl9hdG9uKGlwKSkgPT0gSU5B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Nob3csCit9OworCitzdGF0aWMgaW50IGlwbXJfbWZjX29wZW4oc3RydWN0IGlub2RlICppbm9kZSwgc3RydWN0IGZpbGUgKmZpbGUpCit7CisJc3RydWN0IHNlcV9maWxlICpzZXE7CisJaW50IHJjID0gLUVOT01FTTsKKwlzdHJ1Y3QgaXBtcl9tZmNfaXRlciAqcyA9IGttYWxsb2Moc2l6ZW9mKCpzKSwgR0ZQX0tFUk5FTCk7CisgICAgICAgCisJaWYgKCFzKQorCQlnb3RvIG91dDsKKworCXJjID0gc2VxX29wZW4oZmlsZSwgJmlwbXJfbWZjX3NlcV9vcHMpOworCWlmIChyYykKKwkJZ290byBvdXRfa2ZyZWU7CisKKwlzZXEgPSBmaWxlLT5wcml2YXRlX2RhdGE7CisJc2VxLT5wcml2YXRlID0gczsKK291dDoKKwlyZXR1cm4gcmM7CitvdXRfa2ZyZWU6CisJa2ZyZWUocyk7CisJZ290byBvdXQ7CisKK30KKworc3RhdGljIHN0cnVjdCBmaWxlX29wZXJhdGlvbnMgaXBtcl9tZmNfZm9wcyA9IHsKKwkub3duZXIJID0gVEhJU19NT0RVTEUsCisJLm9wZW4gICAgPSBpcG1yX21mY19vcGVuLAorCS5yZWFkICAgID0gc2VxX3JlYWQsCisJLmxsc2VlayAgPSBzZXFfbHNlZWssCisJLnJlbGVhc2UgPSBzZXFfcmVsZWFzZV9wcml2YXRlLAorfTsKKyNlbmRpZgkKKworI2lmZGVmIENPTkZJR19JUF9QSU1TTV9WMgorc3RhdGljIHN0cnVjdCBuZXRfcHJvdG9jb2wgcGltX3Byb3RvY29sID0geworCS5oYW5kbGVyCT0JcGltX3JjdiwKK307CisjZW5kaWYKKworCisvKgorICoJU2V0dXAgZm9yIElQIG11bHRpY2FzdCByb3V0aW5nCisgKi8KKyAKK3ZvaWQgX19pbml0IGlwX21yX2luaXQodm9pZCkKK3sKKwltcnRfY2FjaGVwID0ga21lbV9jYWNoZV9jcmVhdGUoImlwX21ydF9jYWNoZSIsCisJCQkJIC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yNpZmRlZiBDT05GSUdfUFJPQ19GUworc3RhdGljIGludCBpcF92c19zdGF0c19zaG93KHN0cnVjdCBzZXFfZmlsZSAqc2VxLCB2b2lkICp2KQoreworCisvKiAgICAgICAgICAgICAgIDAxMjM0NTY3IDAxMjM0NTY3IDAxMjM0NTY3IDAxMjM0NTY3MDEyMzQ1NjcgMDEyMzQ1NjcwMTIzNDU2NyAqLworCXNlcV9wdXRzKHNlcSwKKwkJICIgICBUb3RhbCBJbmNvbWluZyBPdXRnb2luZyAgICAgICAgIEluY29taW5nICAgICAgICAgT3V0Z29pbmdcbiIpOworCXNlcV9wcmludGYoc2VxLAorCQkgICAiICAgQ29ubnMgIFBhY2tldHMgIFBhY2tldHMgICAgICAgICAgICBCeXRlcyAgICAgICAgICAgIEJ5dGVzXG4iKTsKKworCXNwaW5fbG9ja19iaCgmaXBfdnNfc3RhdHMubG9jayk7CisJc2VxX3ByaW50ZihzZXEsICIlOFggJThYICU4WCAlMTZMWCAlMTZMWFxuXG4iLCBpcF92c19zdGF0cy5jb25ucywKKwkJICAgaXBfdnNfc3RhdHMuaW5wa3RzLCBpcF92c19zdGF0cy5vdXRwa3RzLAorCQkgICAodW5zaWduZWQgbG9uZyBsb25nKSBpcF92c19zdGF0cy5pbmJ5dGVzLAorCQkgICAodW5zaWduZWQgbG9uZyBsb25nKSBpcF92c19zdGF0cy5vdXRieXRlcyk7CisKKy8qICAgICAgICAgICAgICAgICAwMTIzNDU2NyAwMTIzNDU2NyAwMTIzNDU2NyAwMTIzNDU2NzAxMjM0NTY3IDAxMjM0NTY3MDEyMzQ1NjcgKi8KKwlzZXFfcHV0cyhzZXEsCisJCSAgICIgQ29ubnMvcyAgIFBrdHMvcyAgIFBrdHMvcyAgICAgICAgICBCeXRlcy9zICAgICAgICAgIEJ5dGVzL3NcbiIpOworCXNlcV9wcmludGYoc2VxLCIlOFggJThYICU4WCAlMTZYICUxNlhcbiIsCisJCQlpcF92c19zdGF0cy5jcHMsCisJCQlpcF92c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AgICAgIDogICAgZml4ZWQgdGhlIHRlcnJpYmxlIGxvY2tpbmcgYnVncworICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICpsb2NrKHRibC0+bG9jaykgPT0+ICpsb2NrKCZ0YmwtPmxvY2spCisgKiAgICAgV2Vuc29uZyBaaGFuZyAgICAgICAgICAgOiAgICBmaXhlZCB0aGUgdW5pbml0aWxpemVkIHRibC0+bG9jayBidWcKKyAqICAgICBXZW5zb25nIFpoYW5nICAgICAgICAgICA6ICAgIGFkZGVkIGRvaW5nIGZ1bGwgZXhwaXJhdGlvbiBjaGVjayB0bworICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbGxlY3Qgc3RhbGUgZW50cmllcyBvZiAyNCsgaG91cnMgd2hlbgorICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5vIHBhcnRpYWwgZXhwaXJlIGNoZWNrIGluIGEgaGFsZiBob3VyCisgKiAgICAgSnVsaWFuIEFuYXN0YXNvdiAgICAgICAgOiAgICByZXBsYWNlZCBkZWxfdGltZXIgY2FsbCB3aXRoIGRlbF90aW1lcl9zeW5jCisgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdG8gYXZvaWQgdGhlIHBvc3NpYmxlIHJhY2UgYmV0d2VlbiB0aW1lcgorICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhhbmRsZXIgYW5kIGRlbF90aW1lciB0aHJlYWQgaW4gU01QCisgKgorICovCisKKy8qCisgKiBUaGUgbGJsYyBhbGdvcml0aG0gaXMgYXMgZm9sbG93cyAocHNldWRvIGNvZGUpOgorICoKKyAqICAgICAgIGlmIGNhY2hlbm9kZVtkZXN0X2lwXSBpcyBudWxsIHRoZW4KKyAqICAgICAgICAgICAgICAgbiwgY2FjaGVub2RlW2Rlc3RfaXBdIDwtIHt3ZWlnaHRlZCBsZWFzdC1jb25uIG5vZGV9OworICogICAgICAgZWxzZQorICogICAgICAgICAgICAgIC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ICAgKmRlc3Q7ICAgICAgICAgIC8qIHJlYWwgc2VydmVyIChjYWNoZSkgKi8KKwl1bnNpZ25lZCBsb25nICAgICAgICAgICBsYXN0dXNlOyAgICAgICAgLyogbGFzdCB1c2VkIHRpbWUgKi8KK307CisKKworLyoKKyAqICAgICAgSVBWUyBsYmxjIGhhc2ggdGFibGUKKyAqLworc3RydWN0IGlwX3ZzX2xibGNfdGFibGUgeworCXJ3bG9ja190CSAgICAgICAgbG9jazsgICAgICAgICAgIC8qIGxvY2sgZm9yIHRoaXMgdGFibGUgKi8KKwlzdHJ1Y3QgbGlzdF9oZWFkICAgICAgICBidWNrZXRbSVBfVlNfTEJMQ19UQUJfU0laRV07ICAvKiBoYXNoIGJ1Y2tldCAqLworCWF0b21pY190ICAgICAgICAgICAgICAgIGVudHJpZXM7ICAgICAgICAvKiBudW1iZXIgb2YgZW50cmllcyAqLworCWludCAgICAgICAgICAgICAgICAgICAgIG1heF9zaXplOyAgICAgICAvKiBtYXhpbXVtIHNpemUgb2YgZW50cmllcyAqLworCXN0cnVjdCB0aW1lcl9saXN0ICAgICAgIHBlcmlvZGljX3RpbWVyOyAvKiBjb2xsZWN0IHN0YWxlIGVudHJpZXMgKi8KKwlpbnQgICAgICAgICAgICAgICAgICAgICByb3ZlcjsgICAgICAgICAgLyogcm92ZXIgZm9yIGV4cGlyZSBjaGVjayAqLworCWludCAgICAgICAgICAgICAgICAgICAgIGNvdW50ZXI7ICAgICAgICAvKiBjb3VudGVyIGZvciBubyBleHBpcmUgKi8KK307CisKKworLyoKKyAqICAgICAgSVBWUyBMQkxDIHN5c2N0bCB0YWJsZQorICovCisKK3N0YXRpYyBjdGxfdGFibGUgdnNfdmFyc190YWJsZVtdID0geworCXsKKwkJLmN0bF9uYW1lCT0gTkVUX0lQVjRfVlNfTEJMQ19FWFBJUkUsCisJCS5wcm9jbmFtZQk9ICJsYmxjX2V4cGlyYXRpb24iLAorCQkuZGF0YQkJPSAmc3lzY3RsX2lwX3ZzX2x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gICAgICAgICAgICAgIGFkZCBuIHRvIHNlcnZlclNldFtkZXN0X2lwXTsKKyAqICAgICAgICAgICAgICAgaWYgfHNlcnZlclNldFtkZXN0X2lwXXwgPiAxIEFORAorICogICAgICAgICAgICAgICAgICAgbm93IC0gc2VydmVyU2V0W2Rlc3RfaXBdLmxhc3RNb2QgPiBUIHRoZW4KKyAqICAgICAgICAgICAgICAgICAgIG0gPC0ge21vc3QgY29ubiBub2RlIGluIHNlcnZlclNldFtkZXN0X2lwXX07CisgKiAgICAgICAgICAgICAgICAgICByZW1vdmUgbSBmcm9tIHNlcnZlclNldFtkZXN0X2lwXTsKKyAqICAgICAgIGlmIHNlcnZlclNldFtkZXN0X2lwXSBjaGFuZ2VkIHRoZW4KKyAqICAgICAgICAgICAgICAgc2VydmVyU2V0W2Rlc3RfaXBdLmxhc3RNb2QgPC0gbm93OworICoKKyAqICAgICAgIHJldHVybiBuOworICoKKyAqLworCisjaW5jbHVkZSA8bGludXgvbW9kdWxlLmg+CisjaW5jbHVkZSA8bGludXgva2VybmVsLmg+CisKKy8qIGZvciBzeXNjdGwgKi8KKyNpbmNsdWRlIDxsaW51eC9mcy5oPgorI2luY2x1ZGUgPGxpbnV4L3N5c2N0bC5oPgorLyogZm9yIHByb2NfbmV0X2NyZWF0ZS9wcm9jX25ldF9yZW1vdmUgKi8KKyNpbmNsdWRlIDxsaW51eC9wcm9jX2ZzLmg+CisKKyNpbmNsdWRlIDxuZXQvaXBfdnMuaD4KKworCisvKgorICogICAgSXQgaXMgZm9yIGdhcmJhZ2UgY29sbGVjdGlvbiBvZiBzdGFsZSBJUFZTIGxibGNyIGVudHJpZXMsCisgKiAgICB3aGVuIHRoZSB0YWJsZSBpcyBmdWxsLgorICovCisjZGVmaW5lIENIRUNLX0VYUElSRV9JTlRFUlZBTCAgICg2MCpIWikKKyNkZWZpbmUgRU5UUllfVElNRU9VVCAgICAgICAgICAgKDYqNjAqSFopCisKKy8qCisgKiAgICBJdCBpcyBmb3IgZnV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AgYWRkcjsgICAgICAgICAgIC8qIGRlc3RpbmF0aW9uIElQIGFkZHJlc3MgKi8KKwlzdHJ1Y3QgaXBfdnNfZGVzdF9zZXQgICBzZXQ7ICAgICAgICAgICAgLyogZGVzdGluYXRpb24gc2VydmVyIHNldCAqLworCXVuc2lnbmVkIGxvbmcgICAgICAgICAgIGxhc3R1c2U7ICAgICAgICAvKiBsYXN0IHVzZWQgdGltZSAqLworfTsKKworCisvKgorICogICAgICBJUFZTIGxibGNyIGhhc2ggdGFibGUKKyAqLworc3RydWN0IGlwX3ZzX2xibGNyX3RhYmxlIHsKKwlyd2xvY2tfdAkgICAgICAgIGxvY2s7ICAgICAgICAgICAvKiBsb2NrIGZvciB0aGlzIHRhYmxlICovCisJc3RydWN0IGxpc3RfaGVhZCAgICAgICAgYnVja2V0W0lQX1ZTX0xCTENSX1RBQl9TSVpFXTsgIC8qIGhhc2ggYnVja2V0ICovCisJYXRvbWljX3QgICAgICAgICAgICAgICAgZW50cmllczsgICAgICAgIC8qIG51bWJlciBvZiBlbnRyaWVzICovCisJaW50ICAgICAgICAgICAgICAgICAgICAgbWF4X3NpemU7ICAgICAgIC8qIG1heGltdW0gc2l6ZSBvZiBlbnRyaWVzICovCisJc3RydWN0IHRpbWVyX2xpc3QgICAgICAgcGVyaW9kaWNfdGltZXI7IC8qIGNvbGxlY3Qgc3RhbGUgZW50cmllcyAqLworCWludCAgICAgICAgICAgICAgICAgICAgIHJvdmVyOyAgICAgICAgICAvKiByb3ZlciBmb3IgZXhwaXJlIGNoZWNrICovCisJaW50ICAgICAgICAgICAgICAgICAgICAgY291bnRlcjsgICAgICAgIC8qIGNvdW50ZXIgZm9yIG5vIGV4cGlyZSAqLworfTsKKworCisvKgorICogICAgICBJUFZTIExCTENSIHN5c2N0bCB0YWJsZQorICovCisKK3N0YXRpYyBjdGxfdGFibGUgdnNfdmFyc190YWJsZVtdID0geworCXsKKwkJLmN0bF9uYW1lCT0gTkVUX0lQVjRfVlNfTEJMQ1J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lmIChwcC0+cHJvdG9jb2wgPT0gcHJvdG8pCisJCQlyZXR1cm4gcHA7CisJfQorCisJcmV0dXJuIE5VTEw7Cit9CisKKworLyoKKyAqCVByb3BhZ2F0ZSBldmVudCBmb3Igc3RhdGUgY2hhbmdlIHRvIGFsbCBwcm90b2NvbHMKKyAqLwordm9pZCBpcF92c19wcm90b2NvbF90aW1lb3V0X2NoYW5nZShpbnQgZmxhZ3MpCit7CisJc3RydWN0IGlwX3ZzX3Byb3RvY29sICpwcDsKKwlpbnQgaTsKKworCWZvciAoaSA9IDA7IGkgPCBJUF9WU19QUk9UT19UQUJfU0laRTsgaSsrKSB7CisJCWZvciAocHAgPSBpcF92c19wcm90b190YWJsZVtpXTsgcHA7IHBwID0gcHAtPm5leHQpIHsKKwkJCWlmIChwcC0+dGltZW91dF9jaGFuZ2UpCisJCQkJcHAtPnRpbWVvdXRfY2hhbmdlKHBwLCBmbGFncyk7CisJCX0KKwl9Cit9CisKKworaW50ICoKK2lwX3ZzX2NyZWF0ZV90aW1lb3V0X3RhYmxlKGludCAqdGFibGUsIGludCBzaXplKQoreworCWludCAqdDsKKworCXQgPSBrbWFsbG9jKHNpemUsIEdGUF9BVE9NSUMpOworCWlmICh0ID09IE5VTEwpCisJCXJldHVybiBOVUxMOworCW1lbWNweSh0LCB0YWJsZSwgc2l6ZSk7CisJcmV0dXJuIHQ7Cit9CisKKworLyoKKyAqCVNldCB0aW1lb3V0IHZhbHVlIGZvciBzdGF0ZSBzcGVjaWZpZWQgYnkgbmFtZQorICovCitpbnQKK2lwX3ZzX3NldF9zdGF0ZV90aW1lb3V0KGludCAqdGFibGUsIGludCBudW0sIGNoYXIgKipuYW1lcywgY2hhciAqbmFtZSwgaW50IHRvKQoreworCWludCBpOworCisJaWYgKCF0YWJsZSB8fCAhbmFtZSB8fCAhdG8pCisJCXJldHVybiAtRUlOVkFMOworCisJZm9yIChpID0gMDsgaSA8IG51bTsgaSsrKSB7CisJCWlmIChzdHJjbXAobmFtZXN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BQT1JUX0lTQUtNUAk1MDAKKworCitzdGF0aWMgc3RydWN0IGlwX3ZzX2Nvbm4gKgorYWhfY29ubl9pbl9nZXQoY29uc3Qgc3RydWN0IHNrX2J1ZmYgKnNrYiwKKwkgICAgICAgc3RydWN0IGlwX3ZzX3Byb3RvY29sICpwcCwKKwkgICAgICAgY29uc3Qgc3RydWN0IGlwaGRyICppcGgsCisJICAgICAgIHVuc2lnbmVkIGludCBwcm90b19vZmYsCisJICAgICAgIGludCBpbnZlcnNlKQoreworCXN0cnVjdCBpcF92c19jb25uICpjcDsKKworCWlmIChsaWtlbHkoIWludmVyc2UpKSB7CisJCWNwID0gaXBfdnNfY29ubl9pbl9nZXQoSVBQUk9UT19VRFAsCisJCQkJICAgICAgIGlwaC0+c2FkZHIsCisJCQkJICAgICAgIF9fY29uc3RhbnRfaHRvbnMoUE9SVF9JU0FLTVApLAorCQkJCSAgICAgICBpcGgtPmRhZGRyLAorCQkJCSAgICAgICBfX2NvbnN0YW50X2h0b25zKFBPUlRfSVNBS01QKSk7CisJfSBlbHNlIHsKKwkJY3AgPSBpcF92c19jb25uX2luX2dldChJUFBST1RPX1VEUCwKKwkJCQkgICAgICAgaXBoLT5kYWRkciwKKwkJCQkgICAgICAgX19jb25zdGFudF9odG9ucyhQT1JUX0lTQUtNUCksCisJCQkJICAgICAgIGlwaC0+c2FkZHIsCisJCQkJICAgICAgIF9fY29uc3RhbnRfaHRvbnMoUE9SVF9JU0FLTVApKTsKKwl9CisKKwlpZiAoIWNwKSB7CisJCS8qCisJCSAqIFdlIGFyZSBub3Qgc3VyZSBpZiB0aGUgcGFja2V0IGlzIGZyb20gb3VyCisJCSAqIHNlcnZpY2UsIHNvIG91ciBjb25uX3NjaGVkdWxlIGhvb2sgc2hvdWxkIHJldHVybiBORl9BQ0NFUFQKKwkJICovCisJCUlQX1ZTX0RCRygxMiwgIlVua25vd24gSVNBS01QIGVudHJ5IGZvciBvdXRpbiBwYWNrZXQgIgorCQkJICAiJXMlcy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4KKyNpbmNsdWRlIDxsaW51eC9kZWxheS5oPgorI2luY2x1ZGUgPGxpbnV4L3NrYnVmZi5oPgorI2luY2x1ZGUgPGxpbnV4L2luLmg+CisjaW5jbHVkZSA8bGludXgvaWdtcC5oPiAgICAgICAgICAgICAgICAgLyogZm9yIGlwX21jX2pvaW5fZ3JvdXAgKi8KKworI2luY2x1ZGUgPG5ldC9pcC5oPgorI2luY2x1ZGUgPG5ldC9zb2NrLmg+CisjaW5jbHVkZSA8YXNtL3VhY2Nlc3MuaD4gICAgICAgICAgICAgICAgLyogZm9yIGdldF9mcyBhbmQgc2V0X2ZzICovCisKKyNpbmNsdWRlIDxuZXQvaXBfdnMuaD4KKworI2RlZmluZSBJUF9WU19TWU5DX0dST1VQIDB4ZTAwMDAwNTEgICAgLyogbXVsdGljYXN0IGFkZHIgLSAyMjQuMC4wLjgxICovCisjZGVmaW5lIElQX1ZTX1NZTkNfUE9SVCAgODg0OCAgICAgICAgICAvKiBtdWx0aWNhc3QgcG9ydCAqLworCisKKy8qCisgKglJUFZTIHN5bmMgY29ubmVjdGlvbiBlbnRyeQorICovCitzdHJ1Y3QgaXBfdnNfc3luY19jb25uIHsKKwlfX3U4CQkJcmVzZXJ2ZWQ7CisKKwkvKiBQcm90b2NvbCwgYWRkcmVzc2VzIGFuZCBwb3J0IG51bWJlcnMgKi8KKwlfX3U4CQkJcHJvdG9jb2w7ICAgICAgIC8qIFdoaWNoIHByb3RvY29sIChUQ1AvVURQKSAqLworCV9fdTE2CQkJY3BvcnQ7CisJX191MTYgICAgICAgICAgICAgICAgICAgdnBvcnQ7CisJX191MTYgICAgICAgICAgICAgICAgICAgZHBvcnQ7CisJX191MzIgICAgICAgICAgICAgICAgICAgY2FkZHI7ICAgICAgICAgIC8qIGNsaWVudCBhZGRyZXNzICovCisJX191MzIgICAgICAgICAgICAgICAgICAgdmFkZHI7ICAgICAgICAgIC8qIHZpcnR1YWwgYWRkcmVzcyAqLworCV9fdTMyICAgICAgICAgICAgIC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SAwIDEgMiAzIDQgNSA2IDcgOCA5IDAgMSAyIDMgNCA1IDYgNyA4IDkgMCAxCisgICAgICArLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKworICAgICAgfCAgQ291bnQgQ29ubnMgIHwgICAgU3luY0lEICAgICB8ICAgICAgICAgICAgU2l6ZSAgICAgICAgICAgICAgIHwKKyAgICAgICstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rCisgICAgICB8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfAorICAgICAgfCAgICAgICAgICAgICAgICAgICAgSVBWUyBTeW5jIENvbm5lY3Rpb24gKDEpICAgICAgICAgICAgICAgICAgIHwKKyAgICAgICstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rCisgICAgICB8ICAgICAgICAgICAgICAgICAgICAgICAgICAgIC4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfAorICAgICAgfCAgICAgICAgICAgICAgICAgICAgICAgICAgICAuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwKKyAgICAgIHwgICAgICAgICAgICAgICAgICAgICAgICAgICAgLiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB8CisgICAgICArLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKworICAgICAgfCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwKKyAgICAgIHwgICAgICAgICAgICAgICAgICAgIElQVlMgU3luYyBDb25uZWN0aW9uIChuKSAgICAgICAgICAgICAgICAgICB8CisgICAgICArLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKworKi8KKworI2RlZmluZSBTWU5DX01FU0dfSEVBREVSX0xFTgk0CisKK3N0cnVjdCBpcF92c19zeW5jX21lc2cgeworCV9fdTggICAgICAgICAgICAgICAgICAgIG5yX2Nvbm5zOworCV9fdTggICAgICAgICAgICAgICAgICAgIHN5bmNpZDsKKwlfX3UxNiAgICAgICAgICAgICAgICAgICBzaXplOworCisJLyogaXBfdnNfc3luY19jb25uIGVudHJpZXMgc3RhcnQgaGVyZSAqLworfTsKKworLyogdGhlIG1heGltdW0gbGVuZ3RoIG9mIHN5bmMgKHNlbmRpbmcvcmVjZWl2aW5nKSBtZXNzYWdlICovCitzdGF0aWMgaW50IHN5bmNfc2VuZF9tZXNnX21heGxlbjsKK3N0YXRpYyBpbnQgc3luY19yZWN2X21lc2dfbWF4bGVuOworCitzdHJ1Y3QgaXBfdnNfc3luY19idWZmIHsKKwlzdHJ1Y3QgbGlzdF9oZWFkICAgICAgICBsaXN0OworCXVuc2lnbmVkIGxvbmcgICAgICAgICAgIGZpcnN0dXNlOworCisJLyogcG9pbnRlcnMgZm9yIHRoZSBtZXNzYWdlIGRhdGEgKi8KKwlzdHJ1Y3QgaXBfdnNfc3luY19tZXNnICAqbWVzZzsKKwl1bnNpZ25lZCBjaGFyICAgICAgICAgICAqaGVhZDsKKwl1bnNpZ25lZCBjaGFyICAgICAgICAgICAqZW5kOworfTsKKworCisvKiB0aGUgc3luY19idWZmIGxpc3QgaGVhZCBhbmQgdGhlIGxvY2sgKi8KK3N0YXRpYyBMSVNUX0hFQUQoaXBfdnNfc3luY19xdWV1ZSk7CitzdGF0aWMgREVGSU5FX1NQSU5MT0NLKGlwX3ZzX3N5bmNfbG9jayk7CisKKy8qIGN1cnJlbnQgc3luY19idWZmIGZvciBhY2NlcHRpbmcgbmV3IGNvbm4gZW50cmllcyAqLworc3RhdGljIHN0cnVjdCBpcF92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GhlIHRocmVlIGluc3RhbmNlcyBvZiBpcF90YWJsZXMKK29iai0kKENPTkZJR19JUF9ORl9GSUxURVIpICs9IGlwdGFibGVfZmlsdGVyLm8KK29iai0kKENPTkZJR19JUF9ORl9NQU5HTEUpICs9IGlwdGFibGVfbWFuZ2xlLm8KK29iai0kKENPTkZJR19JUF9ORl9OQVQpICs9IGlwdGFibGVfbmF0Lm8KK29iai0kKENPTkZJR19JUF9ORl9SQVcpICs9IGlwdGFibGVfcmF3Lm8KKworIyBtYXRjaGVzCitvYmotJChDT05GSUdfSVBfTkZfTUFUQ0hfSEVMUEVSKSArPSBpcHRfaGVscGVyLm8KK29iai0kKENPTkZJR19JUF9ORl9NQVRDSF9MSU1JVCkgKz0gaXB0X2xpbWl0Lm8KK29iai0kKENPTkZJR19JUF9ORl9NQVRDSF9IQVNITElNSVQpICs9IGlwdF9oYXNobGltaXQubworb2JqLSQoQ09ORklHX0lQX05GX01BVENIX1NDVFApICs9IGlwdF9zY3RwLm8KK29iai0kKENPTkZJR19JUF9ORl9NQVRDSF9NQVJLKSArPSBpcHRfbWFyay5vCitvYmotJChDT05GSUdfSVBfTkZfTUFUQ0hfTUFDKSArPSBpcHRfbWFjLm8KK29iai0kKENPTkZJR19JUF9ORl9NQVRDSF9JUFJBTkdFKSArPSBpcHRfaXByYW5nZS5vCitvYmotJChDT05GSUdfSVBfTkZfTUFUQ0hfUEtUVFlQRSkgKz0gaXB0X3BrdHR5cGUubworb2JqLSQoQ09ORklHX0lQX05GX01BVENIX01VTFRJUE9SVCkgKz0gaXB0X211bHRpcG9ydC5vCitvYmotJChDT05GSUdfSVBfTkZfTUFUQ0hfT1dORVIpICs9IGlwdF9vd25lci5vCitvYmotJChDT05GSUdfSVBfTkZfTUFUQ0hfVE9TKSArPSBpcHRfdG9zLm8KK29iai0kKENPTkZJR19JUF9ORl9NQVRDSF9SRUNFTlQpICs9IGlwdF9yZWNlbnQubworb2JqLSQoQ09ORklHX0lQX05GX01BVENIX0VDTik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pbmcgaG9va1xuIik7CisJCXJldHVybiAtRUxPT1A7CisJfQorCisJLyogRmluYWxseSwgZWFjaCBzYW5pdHkgY2hlY2sgbXVzdCBwYXNzICovCisJaSA9IDA7CisJcmV0ID0gQVJQVF9FTlRSWV9JVEVSQVRFKG5ld2luZm8tPmVudHJpZXMsIG5ld2luZm8tPnNpemUsCisJCQkJIGNoZWNrX2VudHJ5LCBuYW1lLCBzaXplLCAmaSk7CisKKwlpZiAocmV0ICE9IDApIHsKKwkJQVJQVF9FTlRSWV9JVEVSQVRFKG5ld2luZm8tPmVudHJpZXMsIG5ld2luZm8tPnNpemUsCisJCQkJICAgY2xlYW51cF9lbnRyeSwgJmkpOworCQlyZXR1cm4gcmV0OworCX0KKworCS8qIEFuZCBvbmUgY29weSBmb3IgZXZlcnkgb3RoZXIgQ1BVICovCisJZm9yIChpID0gMTsgaSA8IG51bV9wb3NzaWJsZV9jcHVzKCk7IGkrKykgeworCQltZW1jcHkobmV3aW5mby0+ZW50cmllcyArIFNNUF9BTElHTihuZXdpbmZvLT5zaXplKSppLAorCQkgICAgICAgbmV3aW5mby0+ZW50cmllcywKKwkJICAgICAgIFNNUF9BTElHTihuZXdpbmZvLT5zaXplKSk7CisJfQorCisJcmV0dXJuIHJldDsKK30KKworc3RhdGljIHN0cnVjdCBhcnB0X3RhYmxlX2luZm8gKnJlcGxhY2VfdGFibGUoc3RydWN0IGFycHRfdGFibGUgKnRhYmxlLAorCQkJCQkgICAgIHVuc2lnbmVkIGludCBudW1fY291bnRlcnMsCisJCQkJCSAgICAgc3RydWN0IGFycHRfdGFibGVfaW5mbyAqbmV3aW5mbywKKwkJCQkJICAgICBpbnQgKmVycm9yKQoreworCXN0cnVjdCBhcnB0X3RhYmxlX2luZm8gKm9sZGluZm87CisKKwkvKiBEbyB0aGUgc3Vic3RpdHV0aW9uLiAqLworCXdyaXRlX2xvY2tfYmgoJnRhYmxlLT5sb2NrKTsKKwkvKiBDaGVjayBpbnNpZGUgbG9jazogaXM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tPnByb3RvLmljbXAuY291bnQpOworCQlpcF9jdF9yZWZyZXNoX2FjY3QoY3QsIGN0aW5mbywgc2tiLCBpcF9jdF9pY21wX3RpbWVvdXQpOworCX0KKworCXJldHVybiBORl9BQ0NFUFQ7Cit9CisKKy8qIENhbGxlZCB3aGVuIGEgbmV3IGNvbm5lY3Rpb24gZm9yIHRoaXMgcHJvdG9jb2wgZm91bmQuICovCitzdGF0aWMgaW50IGljbXBfbmV3KHN0cnVjdCBpcF9jb25udHJhY2sgKmNvbm50cmFjaywKKwkJICAgIGNvbnN0IHN0cnVjdCBza19idWZmICpza2IpCit7CisJc3RhdGljIHVfaW50OF90IHZhbGlkX25ld1tdCisJCT0geyBbSUNNUF9FQ0hPXSA9IDEsCisJCSAgICBbSUNNUF9USU1FU1RBTVBdID0gMSwKKwkJICAgIFtJQ01QX0lORk9fUkVRVUVTVF0gPSAxLAorCQkgICAgW0lDTVBfQUREUkVTU10gPSAxIH07CisKKwlpZiAoY29ubnRyYWNrLT50dXBsZWhhc2hbMF0udHVwbGUuZHN0LnUuaWNtcC50eXBlID49IHNpemVvZih2YWxpZF9uZXcpCisJICAgIHx8ICF2YWxpZF9uZXdbY29ubnRyYWNrLT50dXBsZWhhc2hbMF0udHVwbGUuZHN0LnUuaWNtcC50eXBlXSkgeworCQkvKiBDYW4ndCBjcmVhdGUgYSBuZXcgSUNNUCBgY29ubicgd2l0aCB0aGlzLiAqLworCQlERUJVR1AoImljbXA6IGNhbid0IGNyZWF0ZSBuZXcgY29ubiB3aXRoIHR5cGUgJXVcbiIsCisJCSAgICAgICBjb25udHJhY2stPnR1cGxlaGFzaFswXS50dXBsZS5kc3QudS5pY21wLnR5cGUpOworCQlEVU1QX1RVUExFKCZjb25udHJhY2stPnR1cGxlaGFzaFswXS50dXBsZSk7CisJCXJldHVybiAwOworCX0KKwlhdG9taWNfc2V0KCZjb25udHJhY2stPnByb3RvLmljbXAuY291bnQsIDApOworCXJldHVybiAxOworfQorCitzdGF0aWMga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GgsIHRoLCAmY29ubnRyYWNrLT5wcm90by50Y3Auc2VlblswXSk7CisJCWNvbm50cmFjay0+cHJvdG8udGNwLnNlZW5bMV0uZmxhZ3MgPSAwOworCQljb25udHJhY2stPnByb3RvLnRjcC5zZWVuWzBdLmxvb3NlID0gCisJCWNvbm50cmFjay0+cHJvdG8udGNwLnNlZW5bMV0ubG9vc2UgPSAwOworCX0gZWxzZSBpZiAoaXBfY3RfdGNwX2xvb3NlID09IDApIHsKKwkJLyogRG9uJ3QgdHJ5IHRvIHBpY2sgdXAgY29ubmVjdGlvbnMuICovCisJCXJldHVybiAwOworCX0gZWxzZSB7CisJCS8qCisJCSAqIFdlIGFyZSBpbiB0aGUgbWlkZGxlIG9mIGEgY29ubmVjdGlvbiwKKwkJICogaXRzIGhpc3RvcnkgaXMgbG9zdCBmb3IgdXMuCisJCSAqIExldCdzIHRyeSB0byB1c2UgdGhlIGRhdGEgZnJvbSB0aGUgcGFja2V0LgorCQkgKi8KKwkJY29ubnRyYWNrLT5wcm90by50Y3Auc2VlblswXS50ZF9lbmQgPQorCQkJc2VnbWVudF9zZXFfcGx1c19sZW4obnRvaGwodGgtPnNlcSksIHNrYi0+bGVuLAorCQkJCQkgICAgIGlwaCwgdGgpOworCQljb25udHJhY2stPnByb3RvLnRjcC5zZWVuWzBdLnRkX21heHdpbiA9IG50b2hzKHRoLT53aW5kb3cpOworCQlpZiAoY29ubnRyYWNrLT5wcm90by50Y3Auc2VlblswXS50ZF9tYXh3aW4gPT0gMCkKKwkJCWNvbm50cmFjay0+cHJvdG8udGNwLnNlZW5bMF0udGRfbWF4d2luID0gMTsKKwkJY29ubnRyYWNrLT5wcm90by50Y3Auc2VlblswXS50ZF9tYXhlbmQgPQorCQkJY29ubnRyYWNrLT5wcm90by50Y3Auc2VlblswXS50ZF9lbmQgKyAKKwkJCWNvbm50cmFjay0+cHJvdG8udGNwLnNlZW5bMF0udGRfbWF4d2luOworCQljb25udHJhY2stPnByb3RvLnRjcC5zZWVu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OworCXN0cnVjdCBpcF9jb25udHJhY2tfcHJvdG9jb2wgKnByb3RvOworCisJTVVTVF9CRV9SRUFEX0xPQ0tFRCgmaXBfY29ubnRyYWNrX2xvY2spOworCUlQX05GX0FTU0VSVChjb25udHJhY2spOworCisJLyogd2Ugb25seSB3YW50IHRvIHByaW50IERJUl9PUklHSU5BTCAqLworCWlmIChESVJFQ1RJT04oaGFzaCkpCisJCXJldHVybiAwOworCisJcHJvdG8gPSBpcF9jdF9maW5kX3Byb3RvKGNvbm50cmFjay0+dHVwbGVoYXNoW0lQX0NUX0RJUl9PUklHSU5BTF0KKwkJCSAgICAgICAudHVwbGUuZHN0LnByb3RvbnVtKTsKKwlJUF9ORl9BU1NFUlQocHJvdG8pOworCisJaWYgKHNlcV9wcmludGYocywgIiUtOHMgJXUgJWxkICIsCisJCSAgICAgIHByb3RvLT5uYW1lLAorCQkgICAgICBjb25udHJhY2stPnR1cGxlaGFzaFtJUF9DVF9ESVJfT1JJR0lOQUxdLnR1cGxlLmRzdC5wcm90b251bSwKKwkJICAgICAgdGltZXJfcGVuZGluZygmY29ubnRyYWNrLT50aW1lb3V0KQorCQkgICAgICA/IChsb25nKShjb25udHJhY2stPnRpbWVvdXQuZXhwaXJlcyAtIGppZmZpZXMpL0haCisJCSAgICAgIDogMCkgIT0gMCkKKwkJcmV0dXJuIC1FTk9TUEM7CisKKwlpZiAocHJvdG8tPnByaW50X2Nvbm50cmFjayhzLCBjb25udHJhY2spKQorCQlyZXR1cm4gLUVOT1NQQzsKKyAgCisJaWYgKHByaW50X3R1cGxlKHMsICZjb25udHJhY2stPnR1cGxlaGFzaFtJUF9DVF9ESVJfT1JJR0lOQUxdLnR1cGxlLAorCQkJcHJvdG8pKQorCQlyZXR1cm4gLUVOT1NQQzsKKworIAlpZiAoc2VxX3ByaW50X2NvdW50ZXJzKHMsICZjb25udHJhY2stPmNvdW50ZXJzW0lQX0NUX0RJUl9PUklHSU5BTF0pKQorCQlyZXR1cm4gLUVOT1NQQ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wcm90by50Y3AucG9ydCk7IHBvcnQgIT0gMDsgcG9ydCsrKSB7CisJCWV4cC0+dHVwbGUuZHN0LnUudGNwLnBvcnQgPSBodG9ucyhwb3J0KTsKKwkJaWYgKGlwX2Nvbm50cmFja19leHBlY3RfcmVsYXRlZChleHApID09IDApCisJCQlicmVhazsKKwl9CisKKwlpZiAocG9ydCA9PSAwKSB7CisJCWlwX2Nvbm50cmFja19leHBlY3RfZnJlZShleHApOworCQlyZXR1cm4gTkZfRFJPUDsKKwl9CisKKwkvKiAgICAgIHN0cmxlbigiXDFEQ0MgQ0hBVCBjaGF0IEFBQUFBQUFBIFBcMVxuIik9MjcKKwkgKiAgICAgIHN0cmxlbigiXDFEQ0MgU0NIQVQgY2hhdCBBQUFBQUFBQSBQXDFcbiIpPTI4CisJICogICAgICBzdHJsZW4oIlwxRENDIFNFTkQgRiBBQUFBQUFBQSBQIFNcMVxuIik9MjYKKwkgKiAgICAgIHN0cmxlbigiXDFEQ0MgTU9WRSBGIEFBQUFBQUFBIFAgU1wxXG4iKT0yNgorCSAqICAgICAgc3RybGVuKCJcMURDQyBUU0VORCBGIEFBQUFBQUFBIFAgU1wxXG4iKT0yNworCSAqICAgICAgICAgICAgICBBQUFBQUFBQUE6IGJvdW5kIGFkZHIgKDEuMC4wLjA9PTE2Nzc3MjE2LCBtaW4gOCBkaWdpdHMsCisJICogICAgICAgICAgICAgICAgICAgICAgMjU1LjI1NS4yNTUuMjU1PT00Mjk0OTY3Mjk2LCAxMCBkaWdpdHMpCisJICogICAgICAgICAgICAgIFA6ICAgICAgICAgYm91bmQgcG9ydCAobWluIDEgZCwgbWF4IDVkICg2NTYzNSkpCisJICogICAgICAgICAgICAgIEY6ICAgICAgICAgZmlsZW5hbWUgICAobWluIDEgZCApCisJICogICAgICAgICAgICAgIFM6ICAgICAgICAgc2l6ZSAgICAgICAobWluIDEgZCApCisJICogICAgICAgICAgICAgIDB4MDEsIFxuOiAgdGVybWluYXRvcnMKKwkgKi8KKworCS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TElDRU5TRSgiR1BMIik7CitNT0RVTEVfQVVUSE9SKCJKYW1lcyBNb3JyaXMgPGptb3JyaXNAaW50ZXJjb2RlLmNvbS5hdT4iKTsKK01PRFVMRV9ERVNDUklQVElPTigiQmFzaWMgU05NUCBBcHBsaWNhdGlvbiBMYXllciBHYXRld2F5Iik7CisKKyNkZWZpbmUgU05NUF9QT1JUIDE2MQorI2RlZmluZSBTTk1QX1RSQVBfUE9SVCAxNjIKKyNkZWZpbmUgTk9DVDEobikgKHVfaW50OF90ICkoKG4pICYgMHhmZikKKworc3RhdGljIGludCBkZWJ1ZzsKK3N0YXRpYyBERUZJTkVfU1BJTkxPQ0soc25tcF9sb2NrKTsKKworLyogCisgKiBBcHBsaWNhdGlvbiBsYXllciBhZGRyZXNzIG1hcHBpbmcgbWltaWNzIHRoZSBOQVQgbWFwcGluZywgYnV0IAorICogb25seSBmb3IgdGhlIGZpcnN0IG9jdGV0IGluIHRoaXMgY2FzZSAoYSBtb3JlIGZsZXhpYmxlIHN5c3RlbQorICogY2FuIGJlIGltcGxlbWVudGVkIGlmIG5lZWRlZCkuCisgKi8KK3N0cnVjdCBvY3QxX21hcAoreworCXVfaW50OF90IGZyb207CisJdV9pbnQ4X3QgdG87Cit9OworCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyAqCisgKiBCYXNpYyBBU04uMSBkZWNvZGluZyByb3V0aW5lcyAoZ3hzbm1wIGF1dGhvciBEaXJrIFdpc3NlKQorICoKKyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKworLyogQ2xhc3MgKi8KKyNkZWZpbmUgQVNOMV9VTkkJMAkvKiBVbml2ZXJzYWwgKi8KKyNkZWZpbmUgQVNOMV9BUEwJMQkvKiB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ICAgICAgICAgICAgICAgICAgICAgICAgdW5zaWduZWQgaW50ICpjb24sCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1bnNpZ25lZCBpbnQgKnRhZykKK3sKKwl1bnNpZ25lZCBjaGFyIGNoOworCQorCWlmICghYXNuMV9vY3RldF9kZWNvZGUoY3R4LCAmY2gpKQorCQlyZXR1cm4gMDsKKwkJCisJKmNscyA9IChjaCAmIDB4QzApID4+IDY7CisJKmNvbiA9IChjaCAmIDB4MjApID4+IDU7CisJKnRhZyA9IChjaCAmIDB4MUYpOworCQorCWlmICgqdGFnID09IDB4MUYpIHsKKwkJaWYgKCFhc24xX3RhZ19kZWNvZGUoY3R4LCB0YWcpKQorCQkJcmV0dXJuIDA7CisJfQorCXJldHVybiAxOworfQorCitzdGF0aWMgdW5zaWduZWQgY2hhciBhc24xX2xlbmd0aF9kZWNvZGUoc3RydWN0IGFzbjFfY3R4ICpjdHgsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdW5zaWduZWQgaW50ICpkZWYsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdW5zaWduZWQgaW50ICpsZW4pCit7CisJdW5zaWduZWQgY2hhciBjaCwgY250OworCQorCWlmICghYXNuMV9vY3RldF9kZWNvZGUoY3R4LCAmY2gpKQorCQlyZXR1cm4gMDsKKwkJCisJaWYgKGNoID09IDB4ODApCisJCSpkZWYgPSAwOworCWVsc2UgeworCQkqZGVmID0gMTsKKwkJCisJCWlmIChjaCA8IDB4ODApCisJCQkqbGVuID0gY2g7CisJCWVsc2UgeworCQkJY250ID0gKHVuc2lnbmVkIGNoYXIpIChjaCAmIDB4N0YpOworCQkJKmxlbiA9IDA7CisJCQkKKwkJCXdoaWxlIChjbnQgPiAwKSB7CisJCQkJaWYgKCFhc24xX29jdGV0X2RlY29kZShjdHgsICZjaCkpCisJCQkJCXJldHVybiAwOworCQkJCSpsZW4gPDw9IDg7CisJCQkJKmxlbiB8PSBjaDsKKwkJCQljbnQtLTsKKwkJCX0KKwkJfQorCX0KKwlyZXR1cm4gMTsKK30KKworc3RhdGljIHVuc2lnbmVkIGNoYXIgYXNuMV9oZWFkZXJfZGVjb2RlKHN0cnVjdCBhc24xX2N0eCAqY3R4LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVuc2lnbmVkIGNoYXIgKiplb2MsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdW5zaWduZWQgaW50ICpjbHMsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdW5zaWduZWQgaW50ICpjb24sCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdW5zaWduZWQgaW50ICp0YWcpCit7CisJdW5zaWduZWQgaW50IGRlZiwgbGVuOworCQorCWlmICghYXNuMV9pZF9kZWNvZGUoY3R4LCBjbHMsIGNvbiwgdGFnKSkKKwkJcmV0dXJuIDA7CisJCQorCWlmICghYXNuMV9sZW5ndGhfZGVjb2RlKGN0eCwgJmRlZiwgJmxlbikpCisJCXJldHVybiAwOworCQkKKwlpZiAoZGVmKQorCQkqZW9jID0gY3R4LT5wb2ludGVyICsgbGVuOworCWVsc2UKKwkJKmVvYyA9IE5VTEw7CisJcmV0dXJuIDE7Cit9CisKK3N0YXRpYyB1bnNpZ25lZCBjaGFyIGFzbjFfZW9jX2RlY29kZShzdHJ1Y3QgYXNuMV9jdHggKmN0eCwgdW5zaWduZWQgY2hhciAqZW9jKQoreworCXVuc2lnbmVkIGNoYXIgY2g7CisJCisJaWYgKGVvYyA9PSAwKSB7CisJCWlmICghYXNuMV9vY3RldF9kZWNvZGUoY3R4LCAmY2gpKQorCQkJcmV0dXJuIDA7CisJCQkKKwkJaWYgKGNoICE9IDB4MDApIHsKKwkJCWN0eC0+ZXJyb3IgPSBBU04xX0VSUl9ERUNfRU9DX01JU01BVENIOworCQkJcmV0dXJuIDA7CisJCX0KKwkJC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l9CisJCQorCQlpZiAoIWFzbjFfb2N0ZXRfZGVjb2RlKGN0eCwgJmNoKSkKKwkJCXJldHVybiAwOworCQkJCisJCSppbnRlZ2VyIDw8PSA4OworCQkqaW50ZWdlciB8PSBjaDsKKwl9CisJcmV0dXJuIDE7Cit9CisKK3N0YXRpYyB1bnNpZ25lZCBjaGFyIGFzbjFfdWludF9kZWNvZGUoc3RydWN0IGFzbjFfY3R4ICpjdHgsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVuc2lnbmVkIGNoYXIgKmVvYywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdW5zaWduZWQgaW50ICppbnRlZ2VyKQoreworCXVuc2lnbmVkIGNoYXIgY2g7CisJdW5zaWduZWQgaW50ICBsZW47CisJCisJaWYgKCFhc24xX29jdGV0X2RlY29kZShjdHgsICZjaCkpCisJCXJldHVybiAwOworCQkKKwkqaW50ZWdlciA9IGNoOworCWlmIChjaCA9PSAwKSBsZW4gPSAwOworCWVsc2UgbGVuID0gMTsKKwkKKwl3aGlsZSAoY3R4LT5wb2ludGVyIDwgZW9jKSB7CisJCWlmICgrK2xlbiA+IHNpemVvZiAodW5zaWduZWQgaW50KSkgeworCQkJY3R4LT5lcnJvciA9IEFTTjFfRVJSX0RFQ19CQURWQUxVRTsKKwkJCXJldHVybiAwOworCQl9CisJCQorCQlpZiAoIWFzbjFfb2N0ZXRfZGVjb2RlKGN0eCwgJmNoKSkKKwkJCXJldHVybiAwOworCQkJCisJCSppbnRlZ2VyIDw8PSA4OworCQkqaW50ZWdlciB8PSBjaDsKKwl9CisJcmV0dXJuIDE7Cit9CisKK3N0YXRpYyB1bnNpZ25lZCBjaGFyIGFzbjFfdWxvbmdfZGVjb2RlKHN0cnVjdCBhc24xX2N0eCAqY3R4LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdW5zaWduZWQgY2hhciAqZW9jLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdW5zaWduZWQgbG9uZyAqaW50ZWdlcikKK3sKKwl1bnNpZ25lZCBjaGFyIGNoOworCXVuc2lnbmVkIGludCAgbGVuOworCQorCWlmICghYXNuMV9vY3RldF9kZWNvZGUoY3R4LCAmY2gpKQorCQlyZXR1cm4gMDsKKwkJCisJKmludGVnZXIgPSBjaDsKKwlpZiAoY2ggPT0gMCkgbGVuID0gMDsKKwllbHNlIGxlbiA9IDE7CisJCisJd2hpbGUgKGN0eC0+cG9pbnRlciA8IGVvYykgeworCQlpZiAoKytsZW4gPiBzaXplb2YgKHVuc2lnbmVkIGxvbmcpKSB7CisJCQljdHgtPmVycm9yID0gQVNOMV9FUlJfREVDX0JBRFZBTFVFOworCQkJcmV0dXJuIDA7CisJCX0KKwkJCisJCWlmICghYXNuMV9vY3RldF9kZWNvZGUoY3R4LCAmY2gpKQorCQkJcmV0dXJuIDA7CisJCQkKKwkJKmludGVnZXIgPDw9IDg7CisJCSppbnRlZ2VyIHw9IGNoOworCX0KKwlyZXR1cm4gMTsKK30KKworc3RhdGljIHVuc2lnbmVkIGNoYXIgYXNuMV9vY3RldHNfZGVjb2RlKHN0cnVjdCBhc24xX2N0eCAqY3R4LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVuc2lnbmVkIGNoYXIgKmVvYywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1bnNpZ25lZCBjaGFyICoqb2N0ZXRzLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVuc2lnbmVkIGludCAqbGVuKQoreworCXVuc2lnbmVkIGNoYXIgKnB0cjsKKwkKKwkqbGVuID0gMDsKKwkKKwkqb2N0ZXRzID0ga21hbGxvYyhlb2MgLSBjdHgtPnBvaW50ZXIsIEdGUF9BVE9NSUMpOworCWlmICgqb2N0ZXRzID09IE5VTEwpIHsKKwkJaWYgKG5ldF9yYXRlbGltaXQoKSkKKwkJCXByaW50aygiT09NIGluIGJzYWxnICglZClcbiIsIF9fTElORV9fKTsKKwkJcmV0dXJuIDA7CisJfQorCQorCXB0ciA9ICpvY3RldHM7CisJd2hpbGUgKGN0eC0+cG9pbnRlciA8IGVvYykgeworCQlpZiAoIWFzbjFfb2N0ZXRfZGVjb2RlKGN0eCwgKHVuc2lnbmVkIGNoYXIgKilwdHIrKykpIHsKKwkJCWtmcmVlKCpvY3RldHMpOworCQkJKm9jdGV0cyA9IE5VTEw7CisJCQlyZXR1cm4gMDsKKwkJfQorCQkoKmxlbikrKzsKKwl9CisJcmV0dXJuIDE7Cit9CisKK3N0YXRpYyB1bnNpZ25lZCBjaGFyIGFzbjFfc3ViaWRfZGVjb2RlKHN0cnVjdCBhc24xX2N0eCAqY3R4LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdW5zaWduZWQgbG9uZyAqc3ViaWQpCit7CisJdW5zaWduZWQgY2hhciBjaDsKKwkKKwkqc3ViaWQgPSAwOworCQorCWRvIHsKKwkJaWYgKCFhc24xX29jdGV0X2RlY29kZShjdHgsICZjaCkpCisJCQlyZXR1cm4gMDsKKwkJCisJCSpzdWJpZCA8PD0gNzsKKwkJKnN1YmlkIHw9IGNoICYgMHg3RjsKKwl9IHdoaWxlICgoY2ggJiAweDgwKSA9PSAweDgwKTsKKwlyZXR1cm4gMTsKK30KKworc3RhdGljIHVuc2lnbmVkIGNoYXIgYXNuMV9vaWRfZGVjb2RlKHN0cnVjdCBhc24xX2N0eCAqY3R4LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVuc2lnbmVkIGNoYXIgKmVvYywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1bnNpZ25lZCBsb25nICoqb2lkLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVuc2lnbmVkIGludCAqbGVuKQoreworCXVuc2lnbmVkIGxvbmcgc3ViaWQ7CisJdW5zaWduZWQgaW50ICB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XR1cm4gMTsKK30KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgKgorICogU05NUCBkZWNvZGluZyByb3V0aW5lcyAoZ3hzbm1wIGF1dGhvciBEaXJrIFdpc3NlKQorICoKKyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKworLyogU05NUCBWZXJzaW9ucyAqLworI2RlZmluZSBTTk1QX1YxCQkJCTAKKyNkZWZpbmUgU05NUF9WMkMJCQkxCisjZGVmaW5lIFNOTVBfVjIJCQkJMgorI2RlZmluZSBTTk1QX1YzCQkJCTMKKworLyogRGVmYXVsdCBTaXplcyAqLworI2RlZmluZSBTTk1QX1NJWkVfQ09NTQkJCTI1NgorI2RlZmluZSBTTk1QX1NJWkVfT0JKRUNUSUQJCTEyOAorI2RlZmluZSBTTk1QX1NJWkVfQlVGQ0hSCQkyNTYKKyNkZWZpbmUgU05NUF9TSVpFX0JVRklOVAkJMTI4CisjZGVmaW5lIFNOTVBfU0laRV9TTUFMTE9CSkVDVElECQkxNgorCisvKiBSZXF1ZXN0cyAqLworI2RlZmluZSBTTk1QX1BEVV9HRVQJCQkwCisjZGVmaW5lIFNOTVBfUERVX05FWFQJCQkxCisjZGVmaW5lIFNOTVBfUERVX1JFU1BPTlNFCQkyCisjZGVmaW5lIFNOTVBfUERVX1NFVAkJCTMKKyNkZWZpbmUgU05NUF9QRFVfVFJBUDEJCQk0CisjZGVmaW5lIFNOTVBfUERVX0JVTEsJCQk1CisjZGVmaW5lIFNOTVBfUERVX0lORk9STQkJCTYKKyNkZWZpbmUgU05NUF9QRFVfVFJBUDIJCQk3CisKKy8qIEVycm9ycyAqLworI2RlZmluZSBTTk1QX05PRVJST1IJCQkwCisjZGVmaW5lIFNOTVBfVE9PQklHCQkJMQorI2RlZmluZSBTTk1QX05PU1VDS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gICAgIDAKKyNkZWZpbmUgU05NUF9JTlRFR0VSICAgICAgICAgICAgIDEgICAgLyogbCAgKi8KKyNkZWZpbmUgU05NUF9PQ1RFVFNUUiAgICAgICAgICAgIDIgICAgLyogYyAgKi8KKyNkZWZpbmUgU05NUF9ESVNQTEFZU1RSICAgICAgICAgIDIgICAgLyogYyAgKi8KKyNkZWZpbmUgU05NUF9PQkpFQ1RJRCAgICAgICAgICAgIDMgICAgLyogdWwgKi8KKyNkZWZpbmUgU05NUF9JUEFERFIgICAgICAgICAgICAgIDQgICAgLyogdWMgKi8KKyNkZWZpbmUgU05NUF9DT1VOVEVSICAgICAgICAgICAgIDUgICAgLyogdWwgKi8KKyNkZWZpbmUgU05NUF9HQVVHRSAgICAgICAgICAgICAgIDYgICAgLyogdWwgKi8KKyNkZWZpbmUgU05NUF9USU1FVElDS1MgICAgICAgICAgIDcgICAgLyogdWwgKi8KKyNkZWZpbmUgU05NUF9PUEFRVUUgICAgICAgICAgICAgIDggICAgLyogYyAgKi8KKworLyogQWRkaXRpb25hbCBTTk1QdjIgVHlwZXMgKi8KKyNkZWZpbmUgU05NUF9VSU5URUdFUiAgICAgICAgICAgIDUgICAgLyogdWwgKi8KKyNkZWZpbmUgU05NUF9CSVRTVFIgICAgICAgICAgICAgIDkgICAgLyogdWMgKi8KKyNkZWZpbmUgU05NUF9OU0FQICAgICAgICAgICAgICAgMTAgICAgLyogdWMgKi8KKyNkZWZpbmUgU05NUF9DT1VOVEVSNjQgICAgICAgICAgMTEgICAgLyogdWwgKi8KKyNkZWZpbmUgU05NUF9OT1NVQ0hPQkpFQ1QgICAgICAgMTIKKyNkZWZpbmUgU05NUF9OT1NVQ0hJTlNUQU5DRSAgICAgMTMKKyNkZWZpbmUgU05NUF9FTkRPRk1JQlZJRVcgICAgICAgMTQKKwordW5pb24gc25tcF9zeW50YXgKK3sKKwl1bnNpZ25lZCBjaGFyIHVjWzBdOwkvKiA4IGJpdCB1bnNpZ25lZCAqLworCWNoYXIgY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U05NUF9DNjQsIFNOTVBfQ09VTlRFUjY0fSwKKwl7QVNOMV9DVFgsIFNFUlJfTlNPLCBTTk1QX05PU1VDSE9CSkVDVH0sCisJe0FTTjFfQ1RYLCBTRVJSX05TSSwgU05NUF9OT1NVQ0hJTlNUQU5DRX0sCisJe0FTTjFfQ1RYLCBTRVJSX0VPTSwgU05NUF9FTkRPRk1JQlZJRVd9LAorCXswLCAgICAgICAwLCAgICAgICAtMX0KK307CisKK3N0YXRpYyB1bnNpZ25lZCBjaGFyIHNubXBfdGFnX2NsczJzeW50YXgodW5zaWduZWQgaW50IHRhZywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdW5zaWduZWQgaW50IGNscywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdW5zaWduZWQgc2hvcnQgKnN5bnRheCkKK3sKKwlzdHJ1Y3Qgc25tcF9jbnYgKmNudjsKKwkKKwljbnYgPSBzbm1wX2NvbnY7CisJCisJd2hpbGUgKGNudi0+c3ludGF4ICE9IC0xKSB7CisJCWlmIChjbnYtPnRhZyA9PSB0YWcgJiYgY252LT5jbGFzcyA9PSBjbHMpIHsKKwkJCSpzeW50YXggPSBjbnYtPnN5bnRheDsKKwkJCXJldHVybiAxOworCQl9CisJCWNudisrOworCX0KKwlyZXR1cm4gMDsKK30KKworc3RhdGljIHVuc2lnbmVkIGNoYXIgc25tcF9vYmplY3RfZGVjb2RlKHN0cnVjdCBhc24xX2N0eCAqY3R4LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cnVjdCBzbm1wX29iamVjdCAqKm9iaikKK3sKKwl1bnNpZ25lZCBpbnQgY2xzLCBjb24sIHRhZywgbGVuLCBpZGxlbjsKKwl1bnNpZ25lZCBzaG9ydCB0eXBlOworCXVuc2lnbmVkIGNoYXIgKmVvYywgKmVuZCwgKnA7CisJdW5zaWduZWQgbG9uZyAqbHAsICppZDsKKwl1bnNpZ25lZ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KGN0eCwgJmVuZCwgJmNscywgJmNvbiwgJnRhZykpCisJCXJldHVybiAwOworCQkKKwlpZiAoY2xzICE9IEFTTjFfVU5JIHx8IGNvbiAhPSBBU04xX1BSSSB8fCB0YWcgIT0gQVNOMV9JTlQpCisJCXJldHVybiAwOworCQkKKwlpZiAoIWFzbjFfdWludF9kZWNvZGUoY3R4LCBlbmQsICZyZXF1ZXN0LT5lcnJvcl9pbmRleCkpCisJCXJldHVybiAwOworCQorCXJldHVybiAxOworfQorCisvKiAKKyAqIEZhc3QgY2hlY2tzdW0gdXBkYXRlIGZvciBwb3NzaWJseSBvZGRseS1hbGlnbmVkIFVEUCBieXRlLCBmcm9tIHRoZQorICogY29kZSBleGFtcGxlIGluIHRoZSBkcmFmdC4KKyAqLworc3RhdGljIHZvaWQgZmFzdF9jc3VtKHVuc2lnbmVkIGNoYXIgKmNzdW0sCisgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdW5zaWduZWQgY2hhciAqb3B0ciwKKyAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1bnNpZ25lZCBjaGFyICpucHRyLAorICAgICAgICAgICAgICAgICAgICAgIGludCBvZGQpCit7CisJbG9uZyB4LCBvbGQsIG5ldzsKKwkKKwl4ID0gY3N1bVswXSAqIDI1NiArIGNzdW1bMV07CisJCisJeCA9fiB4ICYgMHhGRkZGOworCQorCWlmIChvZGQpIG9sZCA9IG9wdHJbMF0gKiAyNTY7CisJZWxzZSBvbGQgPSBvcHRyWzBdOworCQorCXggLT0gb2xkICYgMHhGRkZGOworCWlmICh4IDw9IDApIHsKKwkJeC0tOworCQl4ICY9IDB4RkZGRjsKKwl9CisJCisJaWYgKG9kZCkgbmV3ID0gbnB0clswXSAqIDI1NjsKKwllbHNlIG5ldyA9IG5wdHJbMF07CisJCisJeCArPSBuZXcgJiAweEZGRkY7CisJaWYgKHggJiAweDEwMDAwKSB7CisJCXgrKzsKKwkJeCAmPSAweEZGRkY7CisJfQorCQorCXggPX4geCAmIDB4R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ICV1LiV1LiV1LiV1IHRvICIKKwkJCSAgICAgICAiJXUuJXUuJXUuJXVcbiIsIE5JUFFVQUQob2xkKSwgTklQUVVBRCgqYWRkcikpOworCX0KK30KKworc3RhdGljIHVuc2lnbmVkIGNoYXIgc25tcF90cmFwX2RlY29kZShzdHJ1Y3QgYXNuMV9jdHggKmN0eCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RydWN0IHNubXBfdjFfdHJhcCAqdHJhcCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3RydWN0IG9jdDFfbWFwICptYXAsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVfaW50MTZfdCAqY2hlY2spCit7CisJdW5zaWduZWQgaW50IGNscywgY29uLCB0YWcsIGxlbjsKKwl1bnNpZ25lZCBjaGFyICplbmQ7CisKKwlpZiAoIWFzbjFfaGVhZGVyX2RlY29kZShjdHgsICZlbmQsICZjbHMsICZjb24sICZ0YWcpKQorCQlyZXR1cm4gMDsKKwkJCisJaWYgKGNscyAhPSBBU04xX1VOSSB8fCBjb24gIT0gQVNOMV9QUkkgfHwgdGFnICE9IEFTTjFfT0pJKQorCQlyZXR1cm4gMDsKKwkKKwlpZiAoIWFzbjFfb2lkX2RlY29kZShjdHgsIGVuZCwgJnRyYXAtPmlkLCAmdHJhcC0+aWRfbGVuKSkKKwkJcmV0dXJuIDA7CisJCQorCWlmICghYXNuMV9oZWFkZXJfZGVjb2RlKGN0eCwgJmVuZCwgJmNscywgJmNvbiwgJnRhZykpCisJCWdvdG8gZXJyX2lkX2ZyZWU7CisKKwlpZiAoISgoY2xzID09IEFTTjFfQVBMICYmIGNvbiA9PSBBU04xX1BSSSAmJiB0YWcgPT0gU05NUF9JUEEpIHx8CisJICAgICAgKGNscyA9PSBBU04xX1VOSSAmJiBjb24gPT0gQVNOMV9QUkkgJiYgdGFnID09IEFTTjFfT1RTKSkpCisJCWdvdG8gZXJ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CQorCWlmICghKChjbHMgPT0gQVNOMV9BUEwgJiYgY29uID09IEFTTjFfUFJJICYmIHRhZyA9PSBTTk1QX1RJVCkgfHwKKwkgICAgICAoY2xzID09IEFTTjFfVU5JICYmIGNvbiA9PSBBU04xX1BSSSAmJiB0YWcgPT0gQVNOMV9JTlQpKSkKKwkJZ290byBlcnJfYWRkcl9mcmVlOworCQkKKwlpZiAoIWFzbjFfdWxvbmdfZGVjb2RlKGN0eCwgZW5kLCAmdHJhcC0+dGltZSkpCisJCWdvdG8gZXJyX2FkZHJfZnJlZTsKKwkJCisJcmV0dXJuIDE7CisKK2Vycl9pZF9mcmVlOgorCWtmcmVlKHRyYXAtPmlkKTsKKworZXJyX2FkZHJfZnJlZToKKwlrZnJlZSgodW5zaWduZWQgbG9uZyAqKXRyYXAtPmlwX2FkZHJlc3MpOworCQorCXJldHVybiAwOworfQorCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyAqCisgKiBNaXNjLiByb3V0aW5lcworICoKKyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKworc3RhdGljIHZvaWQgaGV4X2R1bXAodW5zaWduZWQgY2hhciAqYnVmLCBzaXplX3QgbGVuKQoreworCXNpemVfdCBpOworCQorCWZvciAoaSA9IDA7IGkgPCBsZW47IGkrKykgeworCQlpZiAoaSAmJiAhKGkgJSAxNikpCisJCQlwcmludGsoIlxuIik7CisJCXByaW50aygiJTAyeCAiLCAqKGJ1ZiArIGkpKTsKKwl9CisJcHJpbnRrKCJcbiIpOworfQorCisvKgorICogUGFyc2UgYW5kIG1hbmdsZSBTTk1QIG1lc3NhZ2UgYWNjb3JkaW5nIHRvIG1hcHBpbmcuCisgKiAoQW5kIHRoaXMgaXMgdGhlIGZ1Y2tpbmcgJ2Jhc2ljJyBtZXRob2QpLgorICovCitzdGF0aWMgaW50IHNubXBfcGFyc2VfbWFuZ2xlKHVuc2lnbmVkIGNoYXIgKm1zZywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdV9pbnQxNl90IGxlbiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3RydWN0IG9jdDFfbWFwICptYXAsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVfaW50MTZfdCAqY2hlY2spCit7CisJdW5zaWduZWQgY2hhciAqZW9jLCAqZW5kOworCXVuc2lnbmVkIGludCBjbHMsIGNvbiwgdGFnLCB2ZXJzLCBwZHV0eXBlOworCXN0cnVjdCBhc24xX2N0eCBjdHg7CisJc3RydWN0IGFzbjFfb2N0c3RyIGNvbW07CisJc3RydWN0IHNubXBfb2JqZWN0ICoqb2JqOworCQorCWlmIChkZWJ1ZyA+IDEpCisJCWhleF9kdW1wKG1zZywgbGVuKTsKKworCWFzbjFfb3BlbigmY3R4LCBtc2csIGxlbik7CisJCisJLyogCisJICogU3RhcnQgb2YgU05NUCBtZXNzYWdlLgorCSAqLworCWlmICghYXNuMV9oZWFkZXJfZGVjb2RlKCZjdHgsICZlb2MsICZjbHMsICZjb24sICZ0YWcpKQorCQlyZXR1cm4gMDsKKwlpZiAoY2xzICE9IEFTTjFfVU5JIHx8IGNvbiAhPSBBU04xX0NPTiB8fCB0YWcgIT0gQVNOMV9TRVEpCisJCXJldHVybiAwOworCQorCS8qIAorCSAqIFZlcnNpb24gMSBvciAyIGhhbmRsZWQuCisJICovCisJaWYgKCFhc24xX2hlYWRlcl9kZWNvZGUoJmN0eCwgJmVuZCwgJmNscywgJmNvbiwgJnRhZykpCisJCXJldHVybiAwOworCWlmIChjbHMgIT0gQVNOMV9VTkkgfHwgY29uICE9IEFTTjFfUFJJIHx8IHRhZyAhPSBBU04xX0lOVCkKKwkJcmV0dXJuIDA7CisJaWYgKCFhc24xX3VpbnRfZGVjb2RlICgmY3R4LCBlbmQsICZ2ZXJzKS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ZyZWUoKm9iaik7CisJCQl9CQorCQkJa2ZyZWUob2JqKTsKKwkJCXJldHVybiAwOworCQl9CisKKwkJaWYgKGRlYnVnID4gMSkgeworCQkJcHJpbnRrKEtFUk5fREVCVUcgImJzYWxnOiBvYmplY3Q6ICIpOworCQkJZm9yIChpID0gMDsgaSA8ICgqb2JqKS0+aWRfbGVuOyBpKyspIHsKKwkJCQlpZiAoaSA+IDApCisJCQkJCXByaW50aygiLiIpOworCQkJCXByaW50aygiJWx1IiwgKCpvYmopLT5pZFtpXSk7CisJCQl9CisJCQlwcmludGsoIjogdHlwZT0ldVxuIiwgKCpvYmopLT50eXBlKTsKKwkJCQorCQl9CisKKwkJaWYgKCgqb2JqKS0+dHlwZSA9PSBTTk1QX0lQQUREUikKKwkJCW1hbmdsZV9hZGRyZXNzKGN0eC5iZWdpbiwgY3R4LnBvaW50ZXIgLSA0ICwgbWFwLCBjaGVjayk7CisJCQorCQlrZnJlZSgoKm9iaiktPmlkKTsKKwkJa2ZyZWUoKm9iaik7CisJfQorCWtmcmVlKG9iaik7CisJCisJaWYgKCFhc24xX2VvY19kZWNvZGUoJmN0eCwgZW9jKSkKKwkJcmV0dXJuIDA7CisJCQorCXJldHVybiAxOworfQorCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyAqCisgKiBOQVQgcm91dGluZXMuCisgKgorICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworCisvKiAKKyAqIFNOTVAgdHJhbnNsYXRpb24gcm91dGluZS4KKyAqLworc3RhdGljIGludCBzbm1wX3RyYW5zbGF0ZShzdHJ1Y3QgaXBfY29ubnRyYWNrICpjdCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgZW51bSBpcF9jb25udHJhY2tfaW5mbyBjdGluZm8sCisgICAgICAgICAgICAgICAgICA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mgoJnNubXBfbG9jayk7CisJcmV0dXJuIHJldDsKK30KKworc3RhdGljIHN0cnVjdCBpcF9jb25udHJhY2tfaGVscGVyIHNubXBfaGVscGVyID0geworCS5tYXhfZXhwZWN0ZWQgPSAwLAorCS50aW1lb3V0ID0gMTgwLAorCS5tZSA9IFRISVNfTU9EVUxFLAorCS5oZWxwID0gaGVscCwKKwkubmFtZSA9ICJzbm1wIiwKKworCS50dXBsZSA9IHsgLnNyYyA9IHsgLnUgPSB7IF9fY29uc3RhbnRfaHRvbnMoU05NUF9QT1JUKSB9IH0sCisJCSAgIC5kc3QgPSB7IC5wcm90b251bSA9IElQUFJPVE9fVURQIH0sCisJfSwKKwkubWFzayA9IHsgLnNyYyA9IHsgLnUgPSB7IDB4RkZGRiB9IH0sCisJCSAuZHN0ID0geyAucHJvdG9udW0gPSAweEZGIH0sCisJfSwKK307CisKK3N0YXRpYyBzdHJ1Y3QgaXBfY29ubnRyYWNrX2hlbHBlciBzbm1wX3RyYXBfaGVscGVyID0geworCS5tYXhfZXhwZWN0ZWQgPSAwLAorCS50aW1lb3V0ID0gMTgwLAorCS5tZSA9IFRISVNfTU9EVUxFLAorCS5oZWxwID0gaGVscCwKKwkubmFtZSA9ICJzbm1wX3RyYXAiLAorCisJLnR1cGxlID0geyAuc3JjID0geyAudSA9IHsgX19jb25zdGFudF9odG9ucyhTTk1QX1RSQVBfUE9SVCkgfSB9LAorCQkgICAuZHN0ID0geyAucHJvdG9udW0gPSBJUFBST1RPX1VEUCB9LAorCX0sCisJLm1hc2sgPSB7IC5zcmMgPSB7IC51ID0geyAweEZGRkYgfSB9LAorCQkgLmRzdCA9IHsgLnByb3RvbnVtID0gMHhGRiB9LAorCX0sCit9OworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyAqCisgKiBNb2R1bGUgc3R1ZmYuCisgKgorICoqKioqKioqKioqKioqKioqKioqKioqKio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BpcHFfdGFibGUKKwl9LAorCXsgLmN0bF9uYW1lID0gMCB9Cit9OworCitzdGF0aWMgY3RsX3RhYmxlIGlwcV9yb290X3RhYmxlW10gPSB7CisJeworCQkuY3RsX25hbWUJPSBDVExfTkVULAorCQkucHJvY25hbWUJPSAibmV0IiwKKwkJLm1vZGUJCT0gMDU1NSwKKwkJLmNoaWxkCQk9IGlwcV9kaXJfdGFibGUKKwl9LAorCXsgLmN0bF9uYW1lID0gMCB9Cit9OworCisjaWZkZWYgQ09ORklHX1BST0NfRlMKK3N0YXRpYyBpbnQKK2lwcV9nZXRfaW5mbyhjaGFyICpidWZmZXIsIGNoYXIgKipzdGFydCwgb2ZmX3Qgb2Zmc2V0LCBpbnQgbGVuZ3RoKQoreworCWludCBsZW47CisKKwlyZWFkX2xvY2tfYmgoJnF1ZXVlX2xvY2spOworCQorCWxlbiA9IHNwcmludGYoYnVmZmVyLAorCSAgICAgICAgICAgICAgIlBlZXIgUElEICAgICAgICAgIDogJWRcbiIKKwkgICAgICAgICAgICAgICJDb3B5IG1vZGUgICAgICAgICA6ICVodVxuIgorCSAgICAgICAgICAgICAgIkNvcHkgcmFuZ2UgICAgICAgIDogJXVcbiIKKwkgICAgICAgICAgICAgICJRdWV1ZSBsZW5ndGggICAgICA6ICV1XG4iCisJICAgICAgICAgICAgICAiUXVldWUgbWF4LiBsZW5ndGggOiAldVxuIgorCQkgICAgICAiUXVldWUgZHJvcHBlZCAgICAgOiAldVxuIgorCQkgICAgICAiTmV0bGluayBkcm9wcGVkICAgOiAldVxuIiwKKwkgICAgICAgICAgICAgIHBlZXJfcGlkLAorCSAgICAgICAgICAgICAgY29weV9tb2RlLAorCSAgICAgICAgICAgICAgY29weV9yYW5nZSwKKwkgICAgICAgICAgICAgIHF1ZXVlX3RvdGFsLAorCSAgICAgICAgICAgICAgcXVldWVfbWF4bGVuLAorCQkgICAgICBxdWV1ZV9kcm9wcGVkLAorCQkgICAgICBxdWV1ZV91c2VyX2Ryb3BwZWQ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291bnRlcnMgY291bnRlcnNbXSkKK3sKKwl1bnNpZ25lZCBpbnQgY3B1OworCXVuc2lnbmVkIGludCBpOworCisJZm9yIChjcHUgPSAwOyBjcHUgPCBudW1fcG9zc2libGVfY3B1cygpOyBjcHUrKykgeworCQlpID0gMDsKKwkJSVBUX0VOVFJZX0lURVJBVEUodC0+ZW50cmllcyArIFRBQkxFX09GRlNFVCh0LCBjcHUpLAorCQkJCSAgdC0+c2l6ZSwKKwkJCQkgIGFkZF9lbnRyeV90b19jb3VudGVyLAorCQkJCSAgY291bnRlcnMsCisJCQkJICAmaSk7CisJfQorfQorCitzdGF0aWMgaW50Citjb3B5X2VudHJpZXNfdG9fdXNlcih1bnNpZ25lZCBpbnQgdG90YWxfc2l6ZSwKKwkJICAgICBzdHJ1Y3QgaXB0X3RhYmxlICp0YWJsZSwKKwkJICAgICB2b2lkIF9fdXNlciAqdXNlcnB0cikKK3sKKwl1bnNpZ25lZCBpbnQgb2ZmLCBudW0sIGNvdW50ZXJzaXplOworCXN0cnVjdCBpcHRfZW50cnkgKmU7CisJc3RydWN0IGlwdF9jb3VudGVycyAqY291bnRlcnM7CisJaW50IHJldCA9IDA7CisKKwkvKiBXZSBuZWVkIGF0b21pYyBzbmFwc2hvdCBvZiBjb3VudGVyczogcmVzdCBkb2Vzbid0IGNoYW5nZQorCSAgIChvdGhlciB0aGFuIGNvbWVmcm9tLCB3aGljaCB1c2Vyc3BhY2UgZG9lc24ndCBjYXJlCisJICAgYWJvdXQpLiAqLworCWNvdW50ZXJzaXplID0gc2l6ZW9mKHN0cnVjdCBpcHRfY291bnRlcnMpICogdGFibGUtPnByaXZhdGUtPm51bWJlcjsKKwljb3VudGVycyA9IHZtYWxsb2MoY291bnRlcnNpemUpOworCisJaWYgKGNvdW50ZXJzID09IE5VTEwpCisJCXJldHVybiAtRU5PTUVNOworCisJLyogRmlyc3QsIHN1bSBjb3VudGVycy4uLiAqLworCW1lbXNldChjb3VudGVycywgMCwgY291bnRlcnNpemU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vbnNpYmxlKHN0cnVjdCBjbHVzdGVyaXBfY29uZmlnICpjb25maWcsIHVfaW50MzJfdCBoYXNoKQoreworCWludCBpOworCisJUkVBRF9MT0NLKCZjbHVzdGVyaXBfbG9jayk7CisKKwlpZiAoY29uZmlnLT5udW1fbG9jYWxfbm9kZXMgPT0gMCkgeworCQlSRUFEX1VOTE9DSygmY2x1c3RlcmlwX2xvY2spOworCQlyZXR1cm4gMDsKKwl9CisKKwlmb3IgKGkgPSAwOyBpIDwgY29uZmlnLT5udW1fbG9jYWxfbm9kZXM7IGkrKykgeworCQlpZiAoY29uZmlnLT5sb2NhbF9ub2Rlc1tpXSA9PSBoYXNoKSB7CisJCQlSRUFEX1VOTE9DSygmY2x1c3RlcmlwX2xvY2spOworCQkJcmV0dXJuIDE7CisJCX0KKwl9CisKKwlSRUFEX1VOTE9DSygmY2x1c3RlcmlwX2xvY2spOworCisJcmV0dXJuIDA7Cit9CisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiAKKyAqIElQVEFCTEVTIFRBUkdFVCAKKyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKworc3RhdGljIHVuc2lnbmVkIGludAordGFyZ2V0KHN0cnVjdCBza19idWZmICoqcHNrYiwKKyAgICAgICBjb25zdCBzdHJ1Y3QgbmV0X2RldmljZSAqaW4sCisgICAgICAgY29uc3Qgc3RydWN0IG5ldF9kZXZpY2UgKm91dCwKKyAgICAgICB1bnNpZ25lZCBpbnQgaG9va251bSwKKyAgICAgICBjb25zdCB2b2lkICp0YXJnaW5mbywKKyAgICAgICB2b2lkICp1c2VyaW5mbykKK3sKKwljb25zdCBzdHJ1Y3QgaXB0X2NsdXN0ZXJpcF90Z3RfaW5mbyAqY2lwaW5mbyA9IHRhcmdpbmZvOworCWVudW0gaXBfY29ubnRyYWNrX2lu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ICIKKwkJICAgICAgICJpbnRlcmZhY2U6IGNpcCclcyctc2tiJyVzJ1xuIiwgYy0+ZGV2LT5uYW1lLCBvdXQtPm5hbWUpOworCQljbHVzdGVyaXBfY29uZmlnX3B1dChjKTsKKwkJcmV0dXJuIE5GX0FDQ0VQVDsKKwl9CisKKwkvKiBtYW5nbGUgcmVwbHkgaGFyZHdhcmUgYWRkcmVzcyAqLworCW1lbWNweShwYXlsb2FkLT5zcmNfaHcsIGMtPmNsdXN0ZXJtYWMsIGFycC0+YXJfaGxuKTsKKworI2lmZGVmIENMVVNURVJJUF9ERUJVRworCURFQlVHUChLRVJOX0RFQlVHICJDTFVTVEVSSVAgbWFuZ2xlZCBhcnAgcmVwbHk6ICIpOworCWFycF9wcmludChwYXlsb2FkKTsKKyNlbmRpZgorCisJY2x1c3RlcmlwX2NvbmZpZ19wdXQoYyk7CisKKwlyZXR1cm4gTkZfQUNDRVBUOworfQorCitzdGF0aWMgc3RydWN0IG5mX2hvb2tfb3BzIGNpcF9hcnBfb3BzID0geworCS5ob29rID0gYXJwX21hbmdsZSwKKwkucGYgPSBORl9BUlAsCisJLmhvb2tudW0gPSBORl9BUlBfT1VULAorCS5wcmlvcml0eSA9IC0xCit9OworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiogCisgKiBQUk9DIERJUiBIQU5ETElORyAKKyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKworI2lmZGVmIENPTkZJR19QUk9DX0ZTCisKK3N0YXRpYyB2b2lkICpjbHVzdGVyaXBfc2VxX3N0YXJ0KHN0cnVjdCBzZXFfZmlsZSAqcywgbG9mZl90ICpwb3MpCit7CisJc3RydWN0IHByb2NfZGlyX2VudHJ5ICpwZGUgPSBzLT5wcml2YXRlOworCXN0cnVjdCBjbHVzdGVyaXBfY29uZmlnICpjID0gc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VM9MHglMDJ4ICIsICh1OCkobnRvaGwodGNwX2ZsYWdfd29yZCh0aCkgJiBUQ1BfUkVTRVJWRURfQklUUykgPj4gMjIpKTsKKwkJLyogTWF4IGxlbmd0aDogMzIgIkNXUiBFQ0UgVVJHIEFDSyBQU0ggUlNUIFNZTiBGSU4gIiAqLworCQlpZiAodGgtPmN3cikKKwkJCXByaW50aygiQ1dSICIpOworCQlpZiAodGgtPmVjZSkKKwkJCXByaW50aygiRUNFICIpOworCQlpZiAodGgtPnVyZykKKwkJCXByaW50aygiVVJHICIpOworCQlpZiAodGgtPmFjaykKKwkJCXByaW50aygiQUNLICIpOworCQlpZiAodGgtPnBzaCkKKwkJCXByaW50aygiUFNIICIpOworCQlpZiAodGgtPnJzdCkKKwkJCXByaW50aygiUlNUICIpOworCQlpZiAodGgtPnN5bikKKwkJCXByaW50aygiU1lOICIpOworCQlpZiAodGgtPmZpbikKKwkJCXByaW50aygiRklOICIpOworCQkvKiBNYXggbGVuZ3RoOiAxMSAiVVJHUD02NTUzNSAiICovCisJCXByaW50aygiVVJHUD0ldSAiLCBudG9ocyh0aC0+dXJnX3B0cikpOworCisJCWlmICgoaW5mby0+bG9nZmxhZ3MgJiBJUFRfTE9HX1RDUE9QVCkKKwkJICAgICYmIHRoLT5kb2ZmICogNCA+IHNpemVvZihzdHJ1Y3QgdGNwaGRyKSkgeworCQkJdW5zaWduZWQgY2hhciBfb3B0WzQgKiAxNSAtIHNpemVvZihzdHJ1Y3QgdGNwaGRyKV07CisJCQl1bnNpZ25lZCBjaGFyICpvcDsKKwkJCXVuc2lnbmVkIGludCBpLCBvcHRzaXplOworCisJCQlvcHRzaXplID0gdGgtPmRvZmYgKiA0IC0gc2l6ZW9mKHN0cnVjdCB0Y3BoZHIpOworCQkJb3AgPSBza2JfaGVhZGVyX3BvaW50ZXIoc2tiLAorCQkJCQkJaXBob2ZmK2loLT5paGwqNCtzaXplb2YoX3RjcGgpLAorCQkJCQkJb3B0c2l6ZSwgX29wdCk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aWhsKjQpOworCQkJYnJlYWs7CisJCX0KKworCQkvKiBMZW5ndGg6IDE1ICJTUEk9MHhGMTIzNDU2NyAiICovCisJCXByaW50aygiU1BJPTB4JXggIiwgbnRvaGwoZWgtPnNwaSkpOworCQlicmVhazsKKwl9CisJLyogTWF4IGxlbmd0aDogMTAgIlBST1RPIDI1NSAiICovCisJZGVmYXVsdDoKKwkJcHJpbnRrKCJQUk9UTz0ldSAiLCBpaC0+cHJvdG9jb2wpOworCX0KKworCS8qIE1heCBsZW5ndGg6IDE1ICJVSUQ9NDI5NDk2NzI5NSAiICovCisgCWlmICgoaW5mby0+bG9nZmxhZ3MgJiBJUFRfTE9HX1VJRCkgJiYgIWlwaG9mZiAmJiBza2ItPnNrKSB7CisJCXJlYWRfbG9ja19iaCgmc2tiLT5zay0+c2tfY2FsbGJhY2tfbG9jayk7CisJCWlmIChza2ItPnNrLT5za19zb2NrZXQgJiYgc2tiLT5zay0+c2tfc29ja2V0LT5maWxlKQorIAkJCXByaW50aygiVUlEPSV1ICIsIHNrYi0+c2stPnNrX3NvY2tldC0+ZmlsZS0+Zl91aWQpOworCQlyZWFkX3VubG9ja19iaCgmc2tiLT5zay0+c2tfY2FsbGJhY2tfbG9jayk7CisJfQorCisJLyogUHJvdG8gICAgTWF4IGxvZyBzdHJpbmcgbGVuZ3RoICovCisJLyogSVA6ICAgICAgNDArNDYrNisxMSsxMjcgPSAyMzAgKi8KKwkvKiBUQ1A6ICAgICAxMCttYXgoMjUsMjArMzArMTMrOSszMisxMSsxMjcpID0gMjUyICovCisJLyogVURQOiAgICAgMTArbWF4KDI1LDIwKSA9IDM1ICovCisJLyogSUNNUDogICAgMTErbWF4KDI1LCAxOCsyNSttYXgoMTksMTQsMjQrMytuKzEwLDMrbisxMCkpID0gOTErbiAqLworCS8qIEVTUDogICAgIDEwK21heCgyNSkrMTUgPSA1MCAqLworCS8qIEFIOiAgICAgIDkrbWF4KDI1KSsxNSA9IDQ5ICovCisJLyogdW5rbm93bjogMTAgKi8KKworCS8qIChJQ01QIGFsbG93cyByZWN1cnNpb24gb25lIGxldmVsIGRlZXApICovCisJLyogbWF4bGVuID0gIElQICsgSUNNUCArICBJUCArIG1heChUQ1AsVURQLElDTVAsdW5rbm93bikgKi8KKwkvKiBtYXhsZW4gPSAyMzArICAgOTEgICsgMjMwICsgMjUyID0gODAzICovCit9CisKK3N0YXRpYyB2b2lkCitpcHRfbG9nX3BhY2tldCh1bnNpZ25lZCBpbnQgaG9va251bSwKKwkgICAgICAgY29uc3Qgc3RydWN0IHNrX2J1ZmYgKnNrYiwKKwkgICAgICAgY29uc3Qgc3RydWN0IG5ldF9kZXZpY2UgKmluLAorCSAgICAgICBjb25zdCBzdHJ1Y3QgbmV0X2RldmljZSAqb3V0LAorCSAgICAgICBjb25zdCBzdHJ1Y3QgaXB0X2xvZ19pbmZvICpsb2dpbmZvLAorCSAgICAgICBjb25zdCBjaGFyICpsZXZlbF9zdHJpbmcsCisJICAgICAgIGNvbnN0IGNoYXIgKnByZWZpeCkKK3sKKwlzcGluX2xvY2tfYmgoJmxvZ19sb2NrKTsKKwlwcmludGsobGV2ZWxfc3RyaW5nKTsKKwlwcmludGsoIiVzSU49JXMgT1VUPSVzICIsCisJICAgICAgIHByZWZpeCA9PSBOVUxMID8gbG9naW5mby0+cHJlZml4IDogcHJlZml4LAorCSAgICAgICBpbiA/IGluLT5uYW1lIDogIiIsCisJICAgICAgIG91dCA/IG91dC0+bmFtZSA6ICIiKTsKKyNpZmRlZiBDT05GSUdfQlJJREdFX05FVEZJTFRFUgorCWlmIChza2ItPm5mX2JyaWRnZSkgeworCQlzdHJ1Y3QgbmV0X2RldmljZSAqcGh5c2luZGV2ID0gc2tiLT5uZl9icmlkZ2UtPnBoeXNpbmRldjsKKwkJc3RydWN0IG5ldF9kZXZpY2UgKnBoeXNvdXRkZXYgPSBza2ItPm5mX2JyaWRnZS0+cGh5c291dGRldjsKKworCQlpZiAocGh5c2luZGV2ICYmIGluICE9IHBoeXNpb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iKTsKK01PRFVMRV9MSUNFTlNFKCJHUEwiKTsKKworI2luY2x1ZGUgPGxpbnV4L25ldGZpbHRlcl9pcHY0L2lwX3RhYmxlcy5oPgorI2luY2x1ZGUgPGxpbnV4L25ldGZpbHRlcl9pcHY0L2lwdF9jb25ubWFyay5oPgorI2luY2x1ZGUgPGxpbnV4L25ldGZpbHRlcl9pcHY0L2lwX2Nvbm50cmFjay5oPgorCitzdGF0aWMgaW50CittYXRjaChjb25zdCBzdHJ1Y3Qgc2tfYnVmZiAqc2tiLAorICAgICAgY29uc3Qgc3RydWN0IG5ldF9kZXZpY2UgKmluLAorICAgICAgY29uc3Qgc3RydWN0IG5ldF9kZXZpY2UgKm91dCwKKyAgICAgIGNvbnN0IHZvaWQgKm1hdGNoaW5mbywKKyAgICAgIGludCBvZmZzZXQsCisgICAgICBpbnQgKmhvdGRyb3ApCit7CisJY29uc3Qgc3RydWN0IGlwdF9jb25ubWFya19pbmZvICppbmZvID0gbWF0Y2hpbmZvOworCWVudW0gaXBfY29ubnRyYWNrX2luZm8gY3RpbmZvOworCXN0cnVjdCBpcF9jb25udHJhY2sgKmN0ID0gaXBfY29ubnRyYWNrX2dldCgoc3RydWN0IHNrX2J1ZmYgKilza2IsICZjdGluZm8pOworCWlmICghY3QpCisJCXJldHVybiAwOworCisJcmV0dXJuICgoY3QtPm1hcmsgJiBpbmZvLT5tYXNrKSA9PSBpbmZvLT5tYXJrKSBeIGluZm8tPmludmVydDsKK30KKworc3RhdGljIGludAorY2hlY2tlbnRyeShjb25zdCBjaGFyICp0YWJsZW5hbWUsCisJICAgY29uc3Qgc3RydWN0IGlwdF9pcCAqaXAsCisJICAgdm9pZCAqbWF0Y2hpbmZvLAorCSAgIHVuc2lnbmVkIGludCBtYXRjaHNpemUsCisJICAgdW5zaWduZWQgaW50IGhvb2tfbWFzaykKK3sKKwlpZiAobWF0Y2hzaXplICE9IElQVF9BTElHTihzaXplb2Yoc3RydWN0IGlwdF9jb25ubWFya19pbmZvKS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ZGV2aWNlICpvdXQsCisgICAgICBjb25zdCB2b2lkICptYXRjaGluZm8sCisgICAgICBpbnQgb2Zmc2V0LAorICAgICAgaW50ICpob3Rkcm9wKQoreworCWNvbnN0IHN0cnVjdCBpcHRfaGVscGVyX2luZm8gKmluZm8gPSBtYXRjaGluZm87CisJc3RydWN0IGlwX2Nvbm50cmFjayAqY3Q7CisJZW51bSBpcF9jb25udHJhY2tfaW5mbyBjdGluZm87CisJaW50IHJldCA9IGluZm8tPmludmVydDsKKwkKKwljdCA9IGlwX2Nvbm50cmFja19nZXQoKHN0cnVjdCBza19idWZmICopc2tiLCAmY3RpbmZvKTsKKwlpZiAoIWN0KSB7CisJCURFQlVHUCgiaXB0X2hlbHBlcjogRWVrISBpbnZhbGlkIGNvbm50cmFjaz9cbiIpOworCQlyZXR1cm4gcmV0OworCX0KKworCWlmICghY3QtPm1hc3RlcikgeworCQlERUJVR1AoImlwdF9oZWxwZXI6IGNvbm50cmFjayAlcCBoYXMgbm8gbWFzdGVyXG4iLCBjdCk7CisJCXJldHVybiByZXQ7CisJfQorCisJUkVBRF9MT0NLKCZpcF9jb25udHJhY2tfbG9jayk7CisJaWYgKCFjdC0+bWFzdGVyLT5oZWxwZXIpIHsKKwkJREVCVUdQKCJpcHRfaGVscGVyOiBtYXN0ZXIgY3QgJXAgaGFzIG5vIGhlbHBlclxuIiwgCisJCQlleHAtPmV4cGVjdGFudCk7CisJCWdvdG8gb3V0X3VubG9jazsKKwl9CisKKwlERUJVR1AoIm1hc3RlcidzIG5hbWUgPSAlcyAsIGluZm8tPm5hbWUgPSAlc1xuIiwgCisJCWN0LT5tYXN0ZXItPmhlbHBlci0+bmFtZSwgaW5mby0+bmFtZSk7CisKKwlpZiAoaW5mby0+bmFtZVswXSA9PSAnXDAnKQorCQlyZXQgXj0gMTsKKwllbHNlCisJCXJldCBePSAhc3RybmNtcChjdC0+bWFzdGVyLT5oZWxwZXItPm5hbWUsIGluZm8tPm5hbWUsIAorCQkgICAgICAgIC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LT5maWxlLT5mX3VpZCAhPSBpbmZvLT51aWQpIF4KKwkJICAgICEhKGluZm8tPmludmVydCAmIElQVF9PV05FUl9VSUQpKQorCQkJcmV0dXJuIDA7CisJfQorCisJaWYoaW5mby0+bWF0Y2ggJiBJUFRfT1dORVJfR0lEKSB7CisJCWlmICgoc2tiLT5zay0+c2tfc29ja2V0LT5maWxlLT5mX2dpZCAhPSBpbmZvLT5naWQpIF4KKwkJICAgICEhKGluZm8tPmludmVydCAmIElQVF9PV05FUl9HSUQpKQorCQkJcmV0dXJuIDA7CisJfQorCisJaWYoaW5mby0+bWF0Y2ggJiBJUFRfT1dORVJfUElEKSB7CisJCWlmICghbWF0Y2hfcGlkKHNrYiwgaW5mby0+cGlkKSBeCisJCSAgICAhIShpbmZvLT5pbnZlcnQgJiBJUFRfT1dORVJfUElEKSkKKwkJCXJldHVybiAwOworCX0KKworCWlmKGluZm8tPm1hdGNoICYgSVBUX09XTkVSX1NJRCkgeworCQlpZiAoIW1hdGNoX3NpZChza2IsIGluZm8tPnNpZCkgXgorCQkgICAgISEoaW5mby0+aW52ZXJ0ICYgSVBUX09XTkVSX1NJRCkpCisJCQlyZXR1cm4gMDsKKwl9CisKKwlpZihpbmZvLT5tYXRjaCAmIElQVF9PV05FUl9DT01NKSB7CisJCWlmICghbWF0Y2hfY29tbShza2IsIGluZm8tPmNvbW0pIF4KKwkJICAgICEhKGluZm8tPmludmVydCAmIElQVF9PV05FUl9DT01NKSkKKwkJCXJldHVybiAwOworCX0KKworCXJldHVybiAxOworfQorCitzdGF0aWMgaW50CitjaGVja2VudHJ5KGNvbnN0IGNoYXIgKnRhYmxlbmFtZSwKKyAgICAgICAgICAgY29uc3Qgc3RydWN0IGlwdF9pcCAqaXAsCisgICAgICAgICAgIHZvaWQgKm1hdGNoaW5mbywKKyAgICAgICAgICAgdW5zaWduZWQgaW50IG1hdGNoc2l6ZSwKKyAgICAgICAgICAgdW5zaWduZWQgaW50IGhvb2tfbWFzaykKK3sKKyAg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WlucyAqLworCWlmICgoaW5mby0+Yml0bWFzayAmIElQVF9QSFlTREVWX09QX0JSSURHRUQpICYmCisJICAgICghIShuZl9icmlkZ2UtPm1hc2sgJiBCUk5GX0JSSURHRUQpIF4KKwkgICAgIShpbmZvLT5pbnZlcnQgJiBJUFRfUEhZU0RFVl9PUF9CUklER0VEKSkpCisJCXJldHVybiBOT01BVENIOworCisJaWYgKChpbmZvLT5iaXRtYXNrICYgSVBUX1BIWVNERVZfT1BfSVNJTiAmJgorCSAgICAoIW5mX2JyaWRnZS0+cGh5c2luZGV2IF4gISEoaW5mby0+aW52ZXJ0ICYgSVBUX1BIWVNERVZfT1BfSVNJTikpKSB8fAorCSAgICAoaW5mby0+Yml0bWFzayAmIElQVF9QSFlTREVWX09QX0lTT1VUICYmCisJICAgICghbmZfYnJpZGdlLT5waHlzb3V0ZGV2IF4gISEoaW5mby0+aW52ZXJ0ICYgSVBUX1BIWVNERVZfT1BfSVNPVVQpKSkpCisJCXJldHVybiBOT01BVENIOworCisJaWYgKCEoaW5mby0+Yml0bWFzayAmIElQVF9QSFlTREVWX09QX0lOKSkKKwkJZ290byBtYXRjaF9vdXRkZXY7CisJaW5kZXYgPSBuZl9icmlkZ2UtPnBoeXNpbmRldiA/IG5mX2JyaWRnZS0+cGh5c2luZGV2LT5uYW1lIDogbnVsbGRldm5hbWU7CisJZm9yIChpID0gMCwgcmV0ID0gMDsgaSA8IElGTkFNU0laL3NpemVvZih1bnNpZ25lZCBpbnQpOyBpKyspIHsKKwkJcmV0IHw9ICgoKGNvbnN0IHVuc2lnbmVkIGludCAqKWluZGV2KVtpXQorCQkJXiAoKGNvbnN0IHVuc2lnbmVkIGludCAqKWluZm8tPnBoeXNpbmRldilbaV0pCisJCQkmICgoY29uc3QgdW5zaWduZWQgaW50ICopaW5mby0+aW5fbWFzaylbaV07CisJfQorCisJaWYgKChyZXQgPT0gMCkgXiAhKGluZm8tPmludmVydCAmIElQVF9QSFlTREVWX09QX0lOKSkKKwkJcm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UNDRVBUOworCX0KKworCXJldHVybiBpcHRfZG9fdGFibGUocHNrYiwgaG9vaywgaW4sIG91dCwgJnBhY2tldF9maWx0ZXIsIE5VTEwpOworfQorCitzdGF0aWMgc3RydWN0IG5mX2hvb2tfb3BzIGlwdF9vcHNbXSA9IHsKKwl7CisJCS5ob29rCQk9IGlwdF9ob29rLAorCQkub3duZXIJCT0gVEhJU19NT0RVTEUsCisJCS5wZgkJPSBQRl9JTkVULAorCQkuaG9va251bQk9IE5GX0lQX0xPQ0FMX0lOLAorCQkucHJpb3JpdHkJPSBORl9JUF9QUklfRklMVEVSLAorCX0sCisJeworCQkuaG9vawkJPSBpcHRfaG9vaywKKwkJLm93bmVyCQk9IFRISVNfTU9EVUxFLAorCQkucGYJCT0gUEZfSU5FVCwKKwkJLmhvb2tudW0JPSBORl9JUF9GT1JXQVJELAorCQkucHJpb3JpdHkJPSBORl9JUF9QUklfRklMVEVSLAorCX0sCisJeworCQkuaG9vawkJPSBpcHRfbG9jYWxfb3V0X2hvb2ssCisJCS5vd25lcgkJPSBUSElTX01PRFVMRSwKKwkJLnBmCQk9IFBGX0lORVQsCisJCS5ob29rbnVtCT0gTkZfSVBfTE9DQUxfT1VULAorCQkucHJpb3JpdHkJPSBORl9JUF9QUklfRklMVEVSLAorCX0sCit9OworCisvKiBEZWZhdWx0IHRvIGZvcndhcmQgYmVjYXVzZSBJIGdvdCB0b28gbXVjaCBtYWlsIGFscmVhZHkuICovCitzdGF0aWMgaW50IGZvcndhcmQgPSBORl9BQ0NFUFQ7Cittb2R1bGVfcGFyYW0oZm9yd2FyZCwgYm9vbCwgMDAwMCk7CisKK3N0YXRpYyBpbnQgX19pbml0IGluaXQodm9pZCkKK3sKKwlpbnQgcmV0OworCisJaWYgKGZvcndhcmQgPCAwIHx8IGZvcndhcmQgPiBORl9NQVhfVkVSRElDVCkgeworCQlwcmludGsoImlwdGFibGVzIGZvcndhcmQgbXVzdCBiZSAwIG9yIDFcbiIpOworCQlyZXR1cm4g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vdG8gb3V0OworCisJaWYgKGFkZHJfbGVuKQorCQkqYWRkcl9sZW4gPSBzaXplb2YoKnNpbik7CisKKwlpZiAoZmxhZ3MgJiBNU0dfRVJSUVVFVUUpIHsKKwkJZXJyID0gaXBfcmVjdl9lcnJvcihzaywgbXNnLCBsZW4pOworCQlnb3RvIG91dDsKKwl9CisKKwlza2IgPSBza2JfcmVjdl9kYXRhZ3JhbShzaywgZmxhZ3MsIG5vYmxvY2ssICZlcnIpOworCWlmICghc2tiKQorCQlnb3RvIG91dDsKKworCWNvcGllZCA9IHNrYi0+bGVuOworCWlmIChsZW4gPCBjb3BpZWQpIHsKKwkJbXNnLT5tc2dfZmxhZ3MgfD0gTVNHX1RSVU5DOworCQljb3BpZWQgPSBsZW47CisJfQorCisJZXJyID0gc2tiX2NvcHlfZGF0YWdyYW1faW92ZWMoc2tiLCAwLCBtc2ctPm1zZ19pb3YsIGNvcGllZCk7CisJaWYgKGVycikKKwkJZ290byBkb25lOworCisJc29ja19yZWN2X3RpbWVzdGFtcChtc2csIHNrLCBza2IpOworCisJLyogQ29weSB0aGUgYWRkcmVzcy4gKi8KKwlpZiAoc2luKSB7CisJCXNpbi0+c2luX2ZhbWlseSA9IEFGX0lORVQ7CisJCXNpbi0+c2luX2FkZHIuc19hZGRyID0gc2tiLT5uaC5pcGgtPnNhZGRyOworCQltZW1zZXQoJnNpbi0+c2luX3plcm8sIDAsIHNpemVvZihzaW4tPnNpbl96ZXJvKSk7CisJfQorCWlmIChpbmV0LT5jbXNnX2ZsYWdzKQorCQlpcF9jbXNnX3JlY3YobXNnLCBza2IpOworCWlmIChmbGFncyAmIE1TR19UUlVOQykKKwkJY29waWVkID0gc2tiLT5sZW47Citkb25lOgorCXNrYl9mcmVlX2RhdGFncmFtKHNrLCBza2IpOworb3V0OglyZXR1cm4gZXJyID8gZXJyIDogY29waWVkOworfQorCitzdGF0aWMgaW50IHJhd19pbml0KHN0cnVjdCBzb2NrICpzaykKK3sKKwlzdHJ1Y3Q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ICghcmVwKQorCQlnb3RvIG91dDsKKworCWlmICh0Y3BkaWFnX2ZpbGwocmVwLCBzaywgcmVxLT50Y3BkaWFnX2V4dCwKKwkJCSBORVRMSU5LX0NCKGluX3NrYikucGlkLAorCQkJIG5saC0+bmxtc2dfc2VxLCAwKSA8PSAwKQorCQlCVUcoKTsKKworCWVyciA9IG5ldGxpbmtfdW5pY2FzdCh0Y3BubCwgcmVwLCBORVRMSU5LX0NCKGluX3NrYikucGlkLCBNU0dfRE9OVFdBSVQpOworCWlmIChlcnIgPiAwKQorCQllcnIgPSAwOworCitvdXQ6CisJaWYgKHNrKSB7CisJCWlmIChzay0+c2tfc3RhdGUgPT0gVENQX1RJTUVfV0FJVCkKKwkJCXRjcF90d19wdXQoKHN0cnVjdCB0Y3BfdHdfYnVja2V0Kilzayk7CisJCWVsc2UKKwkJCXNvY2tfcHV0KHNrKTsKKwl9CisJcmV0dXJuIGVycjsKK30KKworc3RhdGljIGludCBiaXRzdHJpbmdfbWF0Y2goY29uc3QgdTMyICphMSwgY29uc3QgdTMyICphMiwgaW50IGJpdHMpCit7CisJaW50IHdvcmRzID0gYml0cyA+PiA1OworCisJYml0cyAmPSAweDFmOworCisJaWYgKHdvcmRzKSB7CisJCWlmIChtZW1jbXAoYTEsIGEyLCB3b3JkcyA8PCAyKSkKKwkJCXJldHVybiAwOworCX0KKwlpZiAoYml0cykgeworCQlfX3UzMiB3MSwgdzI7CisJCV9fdTMyIG1hc2s7CisKKwkJdzEgPSBhMVt3b3Jkc107CisJCXcyID0gYTJbd29yZHNdOworCisJCW1hc2sgPSBodG9ubCgoMHhmZmZmZmZmZikgPDwgKDMyIC0gYml0cykpOworCisJCWlmICgodzEgXiB3MikgJiBtYXNrKQorCQkJcmV0dXJuIDA7CisJfQorCisJcmV0dXJuIDE7Cit9CisKKworc3RhdGljIGludCB0Y3BkaWFnX2JjX3J1bihjb25zdCB2b2lkICpiYywgaW50IGxlbiwKKwkJCSAgY29uc3Qgc3RydWN0IHRjc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gU09DS19TVFJFQU0pCisJCXJldHVybiAtRUlOVkFMOworCisJc251bSA9IG50b2hzKGFkZHItPnNpbjZfcG9ydCk7CisJaWYgKHNudW0gJiYgc251bSA8IFBST1RfU09DSyAmJiAhY2FwYWJsZShDQVBfTkVUX0JJTkRfU0VSVklDRSkpCisJCXJldHVybiAtRUFDQ0VTOworCisJbG9ja19zb2NrKHNrKTsKKworCS8qIENoZWNrIHRoZXNlIGVycm9ycyAoYWN0aXZlIHNvY2tldCwgZG91YmxlIGJpbmQpLiAqLworCWlmIChzay0+c2tfc3RhdGUgIT0gVENQX0NMT1NFIHx8IGluZXQtPm51bSkgeworCQllcnIgPSAtRUlOVkFMOworCQlnb3RvIG91dDsKKwl9CisKKwkvKiBDaGVjayBpZiB0aGUgYWRkcmVzcyBiZWxvbmdzIHRvIHRoZSBob3N0LiAqLworCWlmIChhZGRyX3R5cGUgPT0gSVBWNl9BRERSX01BUFBFRCkgeworCQl2NGFkZHIgPSBhZGRyLT5zaW42X2FkZHIuczZfYWRkcjMyWzNdOworCQlpZiAoaW5ldF9hZGRyX3R5cGUodjRhZGRyKSAhPSBSVE5fTE9DQUwpIHsKKwkJCWVyciA9IC1FQUREUk5PVEFWQUlMOworCQkJZ290byBvdXQ7CisJCX0KKwl9IGVsc2UgeworCQlpZiAoYWRkcl90eXBlICE9IElQVjZfQUREUl9BTlkpIHsKKwkJCXN0cnVjdCBuZXRfZGV2aWNlICpkZXYgPSBOVUxMOworCisJCQlpZiAoYWRkcl90eXBlICYgSVBWNl9BRERSX0xJTktMT0NBTCkgeworCQkJCWlmIChhZGRyX2xlbiA+PSBzaXplb2Yoc3RydWN0IHNvY2thZGRyX2luNikgJiYKKwkJCQkgICAgYWRkci0+c2luNl9zY29wZV9pZCkgeworCQkJCQkvKiBPdmVycmlkZSBhbnkgZXhpc3RpbmcgYmluZGluZywgaWYgYW5vdGhlciBvbmUKKwkJCQkJICogaXMgc3VwcGxpZWQgYnkgdXNlci4KKwkJCQkJICovCis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EtFUk5fRVJSICJpcHY2X2Rlc3RvcHRfaW5pdDogQ291bGQgbm90IHJlZ2lzdGVyIHByb3RvY29sXG4iKTsKK30KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgIE5PTkUgaGVhZGVyLiBObyBkYXRhIGluIHBhY2tldC4KKyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKworc3RhdGljIGludCBpcHY2X25vZGF0YV9yY3Yoc3RydWN0IHNrX2J1ZmYgKipza2JwLCB1bnNpZ25lZCBpbnQgKm5ob2ZmcCkKK3sKKwlzdHJ1Y3Qgc2tfYnVmZiAqc2tiID0gKnNrYnA7CisKKwlrZnJlZV9za2Ioc2tiKTsKKwlyZXR1cm4gMDsKK30KKworc3RhdGljIHN0cnVjdCBpbmV0Nl9wcm90b2NvbCBub2RhdGFfcHJvdG9jb2wgPSB7CisJLmhhbmRsZXIJPQlpcHY2X25vZGF0YV9yY3YsCisJLmZsYWdzCQk9CUlORVQ2X1BST1RPX05PUE9MSUNZLAorfTsKKwordm9pZCBfX2luaXQgaXB2Nl9ub2RhdGFfaW5pdCh2b2lkKQoreworCWlmIChpbmV0Nl9hZGRfcHJvdG9jb2woJm5vZGF0YV9wcm90b2NvbCwgSVBQUk9UT19OT05FKSA8IDApCisJCXByaW50ayhLRVJOX0VSUiAiaXB2Nl9ub2RhdGFfaW5pdDogQ291bGQgbm90IHJlZ2lzdGVyIHByb3RvY29sXG4iKTsKK30KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgIFJvdXRpbmcgaGVhZGVyLgorICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworCitzdGF0aWMgaW50IGlwdjZfcnRoZHJfcmN2KHN0cnVjdCBza19idWZmICoqc2ticCwgdW5zaWduZWQgaW50ICpuaG9mZnApCit7CisJc3RydWN0IHNrX2J1ZmYgKnNrYiA9ICpza2JwOworCXN0cnVjdCBpbmV0Nl9za2JfcGFybSAqb3B0ID0gSVA2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ApOworCisJaWYgKGdyb3VwX3R5cGUgIT0gSVBWNl9BRERSX0FOWSAmJgorCSAgICAhKGdyb3VwX3R5cGUmSVBWNl9BRERSX01VTFRJQ0FTVCkpIHsKKwkJaW42X2Rldl9wdXQoaWRldik7CisJCXJldHVybiAtRUlOVkFMOworCX0KKworCWlmIChsZW4gPT0gMjQpIHsKKwkJaW50IHN3aXRjaGJhY2s7CisJCS8qIE1MRHYxIHJvdXRlciBwcmVzZW50ICovCisKKwkJLyogVHJhbnNsYXRlIG1pbGxpc2Vjb25kcyB0byBqaWZmaWVzICovCisJCW1heF9kZWxheSA9IChudG9ocyhoZHItPmljbXA2X21heGRlbGF5KSpIWikvMTAwMDsKKworCQlzd2l0Y2hiYWNrID0gKGlkZXYtPm1jX3FydiArIDEpICogbWF4X2RlbGF5OworCQlpZGV2LT5tY192MV9zZWVuID0gamlmZmllcyArIHN3aXRjaGJhY2s7CisKKwkJLyogY2FuY2VsIHRoZSBpbnRlcmZhY2UgY2hhbmdlIHRpbWVyICovCisJCWlkZXYtPm1jX2lmY19jb3VudCA9IDA7CisJCWlmIChkZWxfdGltZXIoJmlkZXYtPm1jX2lmY190aW1lcikpCisJCQlfX2luNl9kZXZfcHV0KGlkZXYpOworCQkvKiBjbGVhciBkZWxldGVkIHJlcG9ydCBpdGVtcyAqLworCQltbGRfY2xlYXJfZGVscmVjKGlkZXYpOworCX0gZWxzZSBpZiAobGVuID49IDI4KSB7CisJCW1heF9kZWxheSA9IChNTERWMl9NUkMobnRvaHMobWxoMi0+bXJjKSkqSFopLzEwMDA7CisJCWlmICghbWF4X2RlbGF5KQorCQkJbWF4X2RlbGF5ID0gMTsKKwkJaWRldi0+bWNfbWF4ZGVsYXkgPSBtYXhfZGVsYXk7CisJCWlmIChtbGgyLT5xcnYpCisJCQlpZGV2LT5tY19xcnYgPSBtbGgyLT5xcnY7CisJCWlmIChncm91cF90eXBlID09IElQVjZfQUREUl9BTlkpIHsgLyogZ2VuZXJhbCBxdWVyeSAq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aGlsZAkJPSBpcHFfZGlyX3RhYmxlCisJfSwKKwl7IC5jdGxfbmFtZSA9IDAgfQorfTsKKworc3RhdGljIGludAoraXBxX2dldF9pbmZvKGNoYXIgKmJ1ZmZlciwgY2hhciAqKnN0YXJ0LCBvZmZfdCBvZmZzZXQsIGludCBsZW5ndGgpCit7CisJaW50IGxlbjsKKworCXJlYWRfbG9ja19iaCgmcXVldWVfbG9jayk7CisJCisJbGVuID0gc3ByaW50ZihidWZmZXIsCisJICAgICAgICAgICAgICAiUGVlciBQSUQgICAgICAgICAgOiAlZFxuIgorCSAgICAgICAgICAgICAgIkNvcHkgbW9kZSAgICAgICAgIDogJWh1XG4iCisJICAgICAgICAgICAgICAiQ29weSByYW5nZSAgICAgICAgOiAldVxuIgorCSAgICAgICAgICAgICAgIlF1ZXVlIGxlbmd0aCAgICAgIDogJXVcbiIKKwkgICAgICAgICAgICAgICJRdWV1ZSBtYXguIGxlbmd0aCA6ICV1XG4iCisJCSAgICAgICJRdWV1ZSBkcm9wcGVkICAgICA6ICV1XG4iCisJCSAgICAgICJOZXRmaWx0ZXIgZHJvcHBlZCA6ICV1XG4iLAorCSAgICAgICAgICAgICAgcGVlcl9waWQsCisJICAgICAgICAgICAgICBjb3B5X21vZGUsCisJICAgICAgICAgICAgICBjb3B5X3JhbmdlLAorCSAgICAgICAgICAgICAgcXVldWVfdG90YWwsCisJICAgICAgICAgICAgICBxdWV1ZV9tYXhsZW4sCisJCSAgICAgIHF1ZXVlX2Ryb3BwZWQsCisJCSAgICAgIHF1ZXVlX3VzZXJfZHJvcHBlZCk7CisKKwlyZWFkX3VubG9ja19iaCgmcXVldWVfbG9jayk7CisJCisJKnN0YXJ0ID0gYnVmZmVyICsgb2Zmc2V0OworCWxlbiAtPSBvZmZzZXQ7CisJaWYgKGxlbiA+IGxlbmd0aCkKKwkJbGVuID0gbGVuZ3RoOworCWVsc2UgaWYgKGxlbiA8IDApCisJCWxlbiA9IDA7CisJcmV0dXJuIGxlbjsKK30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VmaW5lIHVwKHgpIGRvIHsgcHJpbnRrKCJVUDoldToiICN4ICJcbiIsIF9fTElORV9fKTsgdXAoeCk7IH0gd2hpbGUoMCkKKyNlbmRpZgorCitzdGF0aWMgaW50IGlwNl9tYXNrZWRfYWRkcmNtcChzdHJ1Y3QgaW42X2FkZHIgYWRkcjEsIHN0cnVjdCBpbjZfYWRkciBtYXNrLAorCQkJICAgICAgc3RydWN0IGluNl9hZGRyIGFkZHIyKQoreworCWludCBpOworCWZvciggaSA9IDA7IGkgPCAxNjsgaSsrKXsKKwkJaWYoKGFkZHIxLnM2X2FkZHJbaV0gJiBtYXNrLnM2X2FkZHJbaV0pICE9IAorCQkgICAoYWRkcjIuczZfYWRkcltpXSAmIG1hc2suczZfYWRkcltpXSkpCisJCQlyZXR1cm4gMTsKKwl9CisJcmV0dXJuIDA7Cit9CisKKy8qIENoZWNrIGZvciBhbiBleHRlbnNpb24gKi8KK2ludCAKK2lwNnRfZXh0X2hkcih1OCBuZXh0aGRyKQoreworICAgICAgICByZXR1cm4gKCAobmV4dGhkciA9PSBJUFBST1RPX0hPUE9QVFMpICAgfHwKKyAgICAgICAgICAgICAgICAgKG5leHRoZHIgPT0gSVBQUk9UT19ST1VUSU5HKSAgIHx8CisgICAgICAgICAgICAgICAgIChuZXh0aGRyID09IElQUFJPVE9fRlJBR01FTlQpICB8fAorICAgICAgICAgICAgICAgICAobmV4dGhkciA9PSBJUFBST1RPX0VTUCkgICAgICAgfHwKKyAgICAgICAgICAgICAgICAgKG5leHRoZHIgPT0gSVBQUk9UT19BSCkgICAgICAgIHx8CisgICAgICAgICAgICAgICAgIChuZXh0aGRyID09IElQUFJPVE9fTk9ORSkgICAgICB8fAorICAgICAgICAgICAgICAgICAobmV4dGhkciA9PSBJUFBST1RPX0RTVE9QVFMpICk7Cit9CisKKy8qIFJldHVybnMgd2hldGhlciBtYXRjaGVzIHJ1bGUgb3Igbm90LiAqLworc3RhdGljIGlubGluZSBpbnQKK2lwNl9wYWNrZX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dlIHdpbGwgY2hhbmdlIHRoZSByZXR1cm4gMCB0byAxKi8KKwkJCWlmICgoY3VycmVudGhkciA9PSBJUFBST1RPX05PTkUpIHx8IAorCQkJCShjdXJyZW50aGRyID09IElQUFJPVE9fRVNQKSkKKwkJCQlicmVhazsKKworCQkJaHAgPSBza2JfaGVhZGVyX3BvaW50ZXIoc2tiLCBwdHIsIHNpemVvZihfaGRyKSwgJl9oZHIpOworCQkJQlVHX09OKGhwID09IE5VTEwpOworCisJCQkvKiBTaXplIGNhbGN1bGF0aW9uICovCisJICAgICAgICAgICAgICAgIGlmIChjdXJyZW50aGRyID09IElQUFJPVE9fRlJBR01FTlQpIHsKKwkJCQlmcCA9IHNrYl9oZWFkZXJfcG9pbnRlcihza2IsCisJCQkJCQkgICBwdHIrb2Zmc2V0b2Yoc3RydWN0IGZyYWdfaGRyLAorCQkJCQkJCQlmcmFnX29mZiksCisJCQkJCQkgICBzaXplb2YoX2ZyYWdvZmYpLAorCQkJCQkJICAgJl9mcmFnb2ZmKTsKKwkJCQlpZiAoZnAgPT0gTlVMTCkKKwkJCQkJcmV0dXJuIDA7CisKKwkJCQlfZnJhZ29mZiA9IG50b2hzKCpmcCkgJiB+MHg3OworCSAgICAgICAgICAgICAgICAgICAgICAgIGhkcmxlbiA9IDg7CisJICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoY3VycmVudGhkciA9PSBJUFBST1RPX0FIKQorCSAgICAgICAgICAgICAgICAgICAgICAgIGhkcmxlbiA9IChocC0+aGRybGVuKzIpPDwyOworCSAgICAgICAgICAgICAgICBlbHNlCisJICAgICAgICAgICAgICAgICAgICAgICAgaGRybGVuID0gaXB2Nl9vcHRsZW4oaHApOworCisJCQljdXJyZW50aGRyID0gaHAtPm5leHRoZHI7CisJICAgICAgICAgICAgICAgIHB0ciArPSBoZHJsZW47CisJCQkvKiBwdHIgaXMgdG9vIGxhcmdlICovCisJICAgICAgICAgICAgICAgIGlmICggcHRyID4gc2tiLT5sZW4gKSAK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plLAorCQkJCWhvb2tfZW50cmllcywgdW5kZXJmbG93cywgJmkpOworCWlmIChyZXQgIT0gMCkKKwkJcmV0dXJuIHJldDsKKworCWlmIChpICE9IG51bWJlcikgeworCQlkdXByaW50ZigidHJhbnNsYXRlX3RhYmxlOiAldSBub3QgJXUgZW50cmllc1xuIiwKKwkJCSBpLCBudW1iZXIpOworCQlyZXR1cm4gLUVJTlZBTDsKKwl9CisKKwkvKiBDaGVjayBob29rcyBhbGwgYXNzaWduZWQgKi8KKwlmb3IgKGkgPSAwOyBpIDwgTkZfSVA2X05VTUhPT0tTOyBpKyspIHsKKwkJLyogT25seSBob29rcyB3aGljaCBhcmUgdmFsaWQgKi8KKwkJaWYgKCEodmFsaWRfaG9va3MgJiAoMSA8PCBpKSkpCisJCQljb250aW51ZTsKKwkJaWYgKG5ld2luZm8tPmhvb2tfZW50cnlbaV0gPT0gMHhGRkZGRkZGRikgeworCQkJZHVwcmludGYoIkludmFsaWQgaG9vayBlbnRyeSAldSAldVxuIiwKKwkJCQkgaSwgaG9va19lbnRyaWVzW2ldKTsKKwkJCXJldHVybiAtRUlOVkFMOworCQl9CisJCWlmIChuZXdpbmZvLT51bmRlcmZsb3dbaV0gPT0gMHhGRkZGRkZGRikgeworCQkJZHVwcmludGYoIkludmFsaWQgdW5kZXJmbG93ICV1ICV1XG4iLAorCQkJCSBpLCB1bmRlcmZsb3dzW2ldKTsKKwkJCXJldHVybiAtRUlOVkFMOworCQl9CisJfQorCisJaWYgKCFtYXJrX3NvdXJjZV9jaGFpbnMobmV3aW5mbywgdmFsaWRfaG9va3MpKQorCQlyZXR1cm4gLUVMT09QOworCisJLyogRmluYWxseSwgZWFjaCBzYW5pdHkgY2hlY2sgbXVzdCBwYXNzICovCisJaSA9IDA7CisJcmV0ID0gSVA2VF9FTlRSWV9JVEVSQVRFKG5ld2luZm8tPmVudHJpZXMsIG5ld2luZm8tPnNpemUsCisJCQkJY2hlY2tfZW50cnksIG5hbWUsIHNpemUsICZpKTs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nbWVudCkgeworCQkJCQlwcmludGsoIikiKTsKKwkJCQkJcmV0dXJuOworCQkJCX0KKworCQkJCS8qCisJCQkJICogTWF4IGxlbmd0aDogMjYgIklOQ09NUExFVEUgWzY1NTM1IGJ5dGVzXSApIgorCQkJCSAqLworCQkJCWVoID0gc2tiX2hlYWRlcl9wb2ludGVyKHNrYiwgcHRyLCBzaXplb2YoX2VzcGgpLAorCQkJCQkJCSZfZXNwaCk7CisJCQkJaWYgKGVoID09IE5VTEwpIHsKKwkJCQkJcHJpbnRrKCJJTkNPTVBMRVRFIFsldSBieXRlc10gKSIsCisJCQkJCSAgICAgICBza2ItPmxlbiAtIHB0cik7CisJCQkJCXJldHVybjsKKwkJCQl9CisKKwkJCQkvKiBMZW5ndGg6IDE2ICJTUEk9MHhGMTIzNDU2NyApIiAqLworCQkJCXByaW50aygiU1BJPTB4JXggKSIsIG50b2hsKGVoLT5zcGkpICk7CisKKwkJCX0KKwkJCXJldHVybjsKKwkJZGVmYXVsdDoKKwkJCS8qIE1heCBsZW5ndGg6IDIwICJVbmtub3duIEV4dCBIZHIgMjU1IiAqLworCQkJcHJpbnRrKCJVbmtub3duIEV4dCBIZHIgJXUiLCBjdXJyZW50aGRyKTsKKwkJCXJldHVybjsKKwkJfQorCQlpZiAoaW5mby0+bG9nZmxhZ3MgJiBJUDZUX0xPR19JUE9QVCkKKwkJCXByaW50aygiKSAiKTsKKworCQljdXJyZW50aGRyID0gaHAtPm5leHRoZHI7CisJCXB0ciArPSBoZHJsZW47CisJfQorCisJc3dpdGNoIChjdXJyZW50aGRyKSB7CisJY2FzZSBJUFBST1RPX1RDUDogeworCQlzdHJ1Y3QgdGNwaGRyIF90Y3BoLCAqdGg7CisKKwkJLyogTWF4IGxlbmd0aDogMTAgIlBST1RPPVRDUCAiICovCisJCXByaW50aygiUFJPVE89VENQICIpOworCisJCWlmIChmcmFnbWVudCkKKwkJCWJyZWFrOworCisJCS8qIE1heCBsZW5ndGg6IDI1ICJJTkNPTVBM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AodGgtPnVyZykKKwkJCXByaW50aygiVVJHICIpOworCQlpZiAodGgtPmFjaykKKwkJCXByaW50aygiQUNLICIpOworCQlpZiAodGgtPnBzaCkKKwkJCXByaW50aygiUFNIICIpOworCQlpZiAodGgtPnJzdCkKKwkJCXByaW50aygiUlNUICIpOworCQlpZiAodGgtPnN5bikKKwkJCXByaW50aygiU1lOICIpOworCQlpZiAodGgtPmZpbikKKwkJCXByaW50aygiRklOICIpOworCQkvKiBNYXggbGVuZ3RoOiAxMSAiVVJHUD02NTUzNSAiICovCisJCXByaW50aygiVVJHUD0ldSAiLCBudG9ocyh0aC0+dXJnX3B0cikpOworCisJCWlmICgoaW5mby0+bG9nZmxhZ3MgJiBJUDZUX0xPR19UQ1BPUFQpCisJCSAgICAmJiB0aC0+ZG9mZiAqIDQgPiBzaXplb2Yoc3RydWN0IHRjcGhkcikpIHsKKwkJCXVfaW50OF90IF9vcHRbNjAgLSBzaXplb2Yoc3RydWN0IHRjcGhkcildLCAqb3A7CisJCQl1bnNpZ25lZCBpbnQgaTsKKwkJCXVuc2lnbmVkIGludCBvcHRzaXplID0gdGgtPmRvZmYgKiA0CisJCQkJCSAgICAgICAtIHNpemVvZihzdHJ1Y3QgdGNwaGRyKTsKKworCQkJb3AgPSBza2JfaGVhZGVyX3BvaW50ZXIoc2tiLAorCQkJCQkJcHRyICsgc2l6ZW9mKHN0cnVjdCB0Y3BoZHIpLAorCQkJCQkJb3B0c2l6ZSwgX29wdCk7CisJCQlpZiAob3AgPT0gTlVMTCkgeworCQkJCXByaW50aygiT1BUIChUUlVOQ0FURUQpIik7CisJCQkJcmV0dXJuOworCQkJfQorCisJCQkvKiBNYXggbGVuZ3RoOiAxMjcgIk9QVCAoIiAxNSo0KjJjaGFycyAiKSAiICovCisJCQlwcmludGsoIk9QVCAoIik7CisJCQlmb3IgKGkgPTA7IGkgPCBvcHRzaXplOyBpKyspCisJCQkJcHJpbnRrKCIlMDJYIiwgb3BbaV0pOworCQkJcHJpbnRrK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CisgICAgICAgdW5zaWduZWQgaW50IHJldCA9IDA7CisgICAgICAgdTggX29wdHR5cGUsICp0cCA9IE5VTEw7CisgICAgICAgdTggX29wdGxlbiwgKmxwID0gTlVMTDsKKyAgICAgICB1bnNpZ25lZCBpbnQgb3B0bGVuOworICAgICAgIAorICAgICAgIC8qIHR5cGUgb2YgdGhlIDFzdCBleHRoZHIgKi8KKyAgICAgICBuZXh0aGRyID0gc2tiLT5uaC5pcHY2aC0+bmV4dGhkcjsKKyAgICAgICAvKiBwb2ludGVyIHRvIHRoZSAxc3QgZXh0aGRyICovCisgICAgICAgcHRyID0gc2l6ZW9mKHN0cnVjdCBpcHY2aGRyKTsKKyAgICAgICAvKiBhdmFpbGFibGUgbGVuZ3RoICovCisgICAgICAgbGVuID0gc2tiLT5sZW4gLSBwdHI7CisgICAgICAgdGVtcCA9IDA7CisKKyAgICAgICAgd2hpbGUgKGlwNnRfZXh0X2hkcihuZXh0aGRyKSkgeworICAgICAgICAgICAgICAgc3RydWN0IGlwdjZfb3B0X2hkciBfaGRyLCAqaHA7CisKKyAgICAgICAgICAgICAgREVCVUdQKCJpcHY2X29wdHMgaGVhZGVyIGl0ZXJhdGlvbiBcbiIpOworCisgICAgICAgICAgICAgIC8qIElzIHRoZXJlIGVub3VnaCBzcGFjZSBmb3IgdGhlIG5leHQgZXh0IGhlYWRlcj8gKi8KKyAgICAgICAgICAgICAgICBpZiAobGVuIDwgKGludClzaXplb2Yoc3RydWN0IGlwdjZfb3B0X2hkcikpCisgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gMDsKKyAgICAgICAgICAgICAgLyogTm8gbW9yZSBleHRoZHIgLT4gZXZhbHVhdGUgKi8KKyAgICAgICAgICAgICAgICBpZiAobmV4dGhkciA9PSBORVhUSERSX05PTkUpIHsKKyAgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgIC8qIEVTUCAtPiBldmFsdWF0ZSAqLworICAgICAgICAgICAgICAgIGlmIChuZXh0aGRyID09IE5FWFRIRFJfRVNQKSB7CisgICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgfQorCisJICAgICAgaHAgPSBza2JfaGVhZGVyX3BvaW50ZXIoc2tiLCBwdHIsIHNpemVvZihfaGRyKSwgJl9oZHIpOworCSAgICAgIEJVR19PTihocCA9PSBOVUxMKTsKKworICAgICAgICAgICAgICAvKiBDYWxjdWxhdGUgdGhlIGhlYWRlciBsZW5ndGggKi8KKyAgICAgICAgICAgICAgICBpZiAobmV4dGhkciA9PSBORVhUSERSX0ZSQUdNRU5UKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBoZHJsZW4gPSA4OworICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAobmV4dGhkciA9PSBORVhUSERSX0FVVEgpCisgICAgICAgICAgICAgICAgICAgICAgICBoZHJsZW4gPSAoaHAtPmhkcmxlbisyKTw8MjsKKyAgICAgICAgICAgICAgICBlbHNlCisgICAgICAgICAgICAgICAgICAgICAgICBoZHJsZW4gPSBpcHY2X29wdGxlbihocCk7CisKKyAgICAgICAgICAgICAgLyogT1BUUyAtPiBldmFsdWF0ZSAqLworI2lmIEhPUEJZSE9QCisgICAgICAgICAgICAgICAgaWYgKG5leHRoZHIgPT0gTkVYVEhEUl9IT1ApIHsKKyAgICAgICAgICAgICAgICAgICAgIHRlbXAgfD0gTUFTS19IT1BPUFRTOworI2Vsc2UKKyAgICAgICAgICAgICAgICBpZiAobmV4dGhkciA9PSBORVhUSERSX0RFU1QpIHsKKyAgICAgICAgICAgICAgICAgICAgIHRlbXAgfD0gTUFTS19EU1RPUFRTOworI2VuZGlmCisgICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgfQorCisKKyAgICAgICAgICAgICAgLyogc2V0IHRoZSBmbGFnICovCisgICAgICAgICAgICAgIHN3aXRjaCAobmV4dGhkcil7CisgICAgICAgICAgICAgICAgICAgICBjYXNlIE5FWFRIRFJfSE9QOgorICAgICAgICAgICAgICAgICAgICAgY2FzZSBORVhUSERSX1JPVVRJTkc6CisgICAgICAgICAgICAgICAgICAgICBjYXNlIE5FWFRIRFJfRlJBR01FTlQ6CisgICAgICAgICAgICAgICAgICAgICBjYXNlIE5FWFRIRFJfQVVUSDoKKyAgICAgICAgICAgICAgICAgICAgIGNhc2UgTkVYVEhEUl9ERVNUOgorICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBERUJVR1AoImlwdjZfb3B0cyBtYXRjaDogdW5rbm93biBuZXh0aGVhZGVyICV1XG4iLG5leHRoZHIpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAwOworICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICB9CisKKyAgICAgICAgICAgICAgICBuZXh0aGRyID0gaHAtPm5leHRoZHI7CisgICAgICAgICAgICAgICAgbGVuIC09IGhkcmxlbjsKKyAgICAgICAgICAgICAgICBwdHIgKz0gaGRybGVuOworCQlpZiAoIHB0ciA+IHNrYi0+bGVuICkgeworCQkJREVCVUdQKCJpcHY2X29wdHM6IG5ldyBwb2ludGVyIGlzIHRvbyBsYXJnZSEgXG4iKTsKKwkJCWJyZWFrOworCQl9CisgICAgICAgIH0KKworICAgICAgIC8qIE9QVElPTlMgaGVhZGVyIG5vdCBmb3VuZCAqLworI2lmIEhPUEJZSE9QCisgICAgICAgaWYgKCB0ZW1wICE9IE1BU0tfSE9QT1BUUyApIHJldHVybiAwOworI2Vsc2UKKyAgICAgICBpZiAoIHRlbXAgIT0gTUFTS19EU1RPUFRTICkgcmV0dXJuIDA7CisjZW5kaWYKKworICAgICAgIGlmIChsZW4gPCAoaW50KXNpemVvZihzdHJ1Y3QgaXB2Nl9vcHRfaGRyKSl7CisJICAgICAgICpob3Rkcm9wID0gMTsKKyAgICAgICAJCXJldHVybiAwOworICAgICAgIH0KKworICAgICAgIGlmIChsZW4gPCBoZHJsZW4peworCSAgICAgICAvKiBQYWNrZXQgc21hbGxlciB0aGFuIGl0J3MgbGVuZ3RoIGZpZWxkICovCisgICAgICAgCQlyZXR1cm4gMDsKKyAgICAgICB9CisKKyAgICAgICBvaCA9IHNrYl9oZWFkZXJfcG9pbnRlcihza2IsIHB0ciwgc2l6ZW9mKF9vcHRzaCksICZfb3B0c2gpOworICAgICAgIEJVR19PTihvaCA9PSBOVUxMKTsKKworICAgICAgIERFQlVHUCgiSVB2NiBPUFRTIExFTiAldSAldSAiLCBoZHJsZW4sIG9oLT5oZHJsZW4pOworCisgICAgICAgREVCVUdQKCJsZW4gJTAyWCAlMDRYICUwMlggIiwKKyAgICAgICAJCW9wdGluZm8tPmhkcmxlbiwgaGRybGVuLAorICAgICAgIAkJKCEob3B0aW5mby0+ZmxhZ3MgJiBJUDZUX09QVFNfTEVOKSB8fAorICAgICAgICAgICAgICAgICAgICAgICAgICAgKChvcHRpbmZvLT5oZHJsZW4gPT0gaGRybGVuKSBeCisgICAgICAgICAgICAgICAgICAgICAgICAgICAhIShvcHRpbmZvLT5pbnZmbGFncyAmIElQNlRfT1BUU19JTlZfTEVOKSkpKTsKKworICAgICAgIHJldCA9IChvaCAhPSBOVUxMKQorICAgICAgIAkJJiYKKwkgICAgICAJKCEob3B0aW5mby0+ZmxhZ3MgJiBJUDZUX09QVFNfTEVOKSB8fAorICAgICAgICAgICAgICAgICAgICAgICAgICAgKChvcHRpbmZvLT5oZHJsZW4gPT0gaGRybGVuKSBeCisgICAgICAgICAgICAgICAgICAgICAgICAgICAhIShvcHRpbmZvLT5pbnZmbGFncyAmIElQNlRfT1BUU19JTlZfTEVOKSkpOworCisgICAgICAgcHRyICs9IDI7CisgICAgICAgaGRybGVuIC09IDI7CisgICAgICAgaWYgKCAhKG9wdGluZm8tPmZsYWdzICYgSVA2VF9PUFRTX09QVFMpICl7CisJICAgICAgIHJldHVybiByZ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XRjaGluZm8sCisgICAgICAgICAgdW5zaWduZWQgaW50IG1hdGNoaW5mb3NpemUsCisgICAgICAgICAgdW5zaWduZWQgaW50IGhvb2tfbWFzaykKK3sKKyAgICAgICBjb25zdCBzdHJ1Y3QgaXA2dF9vcHRzICpvcHRzaW5mbyA9IG1hdGNoaW5mbzsKKworICAgICAgIGlmIChtYXRjaGluZm9zaXplICE9IElQNlRfQUxJR04oc2l6ZW9mKHN0cnVjdCBpcDZ0X29wdHMpKSkgeworICAgICAgICAgICAgICBERUJVR1AoImlwNnRfb3B0czogbWF0Y2hzaXplICV1ICE9ICV1XG4iLAorICAgICAgICAgICAgICAgICAgICAgIG1hdGNoaW5mb3NpemUsIElQNlRfQUxJR04oc2l6ZW9mKHN0cnVjdCBpcDZ0X29wdHMpKSk7CisgICAgICAgICAgICAgIHJldHVybiAwOworICAgICAgIH0KKyAgICAgICBpZiAob3B0c2luZm8tPmludmZsYWdzICYgfklQNlRfT1BUU19JTlZfTUFTSykgeworICAgICAgICAgICAgICBERUJVR1AoImlwNnRfb3B0czogdW5rbm93biBmbGFncyAlWFxuIiwKKyAgICAgICAgICAgICAgICAgICAgICBvcHRzaW5mby0+aW52ZmxhZ3MpOworICAgICAgICAgICAgICByZXR1cm4gMDsKKyAgICAgICB9CisKKyAgICAgICByZXR1cm4gMTsKK30KKworc3RhdGljIHN0cnVjdCBpcDZ0X21hdGNoIG9wdHNfbWF0Y2ggPSB7CisjaWYgSE9QQllIT1AKKwkubmFtZQkJPSAiaGJoIiwKKyNlbHNlCisJLm5hbWUJCT0gImRzdCIsCisjZW5kaWYKKwkubWF0Y2gJCT0gJm1hdGNoLAorCS5jaGVja2VudHJ5CT0gJmNoZWNrZW50cnksCisJLm1lCQk9IFRISVNfTU9EVUxFLAorfTsKKworc3RhdGljIGludCBfX2luaXQgaW5pdCh2b2lkKQoreworICAgICAgIHJldHVybiBpcDZ0X3JlZ2lzdGVyX21hdGNoKCZvcHRzX21hdGNoKTsKK30KKworc3Rhd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c2tiLT5kYXRhKQorICAgICAgICAgICAgICAgICYmIG9mZnNldCAhPSAwKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAqaG90ZHJvcCA9IDE7CisgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gMDsKKyAgICAgICAgICAgICAgICB9CisgICAgCisgICAgbWVtc2V0KGV1aTY0LCAwLCBzaXplb2YoZXVpNjQpKTsKKworICAgIGlmIChldGhfaGRyKHNrYiktPmhfcHJvdG8gPT0gbnRvaHMoRVRIX1BfSVBWNikpIHsKKyAgICAgIGlmIChza2ItPm5oLmlwdjZoLT52ZXJzaW9uID09IDB4NikgeyAKKyAgICAgICAgIG1lbWNweShldWk2NCwgZXRoX2hkcihza2IpLT5oX3NvdXJjZSwgMyk7CisgICAgICAgICBtZW1jcHkoZXVpNjQgKyA1LCBldGhfaGRyKHNrYiktPmhfc291cmNlICsgMywgMyk7CisJIGV1aTY0WzNdPTB4ZmY7CisJIGV1aTY0WzRdPTB4ZmU7CisJIGV1aTY0WzBdIHw9IDB4MDI7CisKKwkgaT0wOworCSB3aGlsZSAoKHNrYi0+bmguaXB2NmgtPnNhZGRyLnM2X2FkZHJbOCtpXSA9PQorCQkJIGV1aTY0W2ldKSAmJiAoaTw4KSkgaSsrOworCisJIGlmICggaSA9PSA4ICkKKwkgCXJldHVybiAxOworICAgICAgfQorICAgIH0KKworICAgIHJldHVybiAwOworfQorCitzdGF0aWMgaW50CitpcDZ0X2V1aTY0X2NoZWNrZW50cnkoY29uc3QgY2hhciAqdGFibGVuYW1lLAorCQkgICBjb25zdCBzdHJ1Y3QgaXA2dF9pcDYgKmlwLAorCQkgICB2b2lkICptYXRjaGluZm8sCisJCSAgIHVuc2lnbmVkIGludCBtYXRjaHNpemUsCisJCSAgIHVuc2lnbmVkIGludCBob29rX21hc2spCit7CisJaWYgKGhvb2tfbWFzaworCSAgICAmIH4oKDEgPDwgTkZfSVA2X1BSRV9ST1VUSU5HKSB8ICgxIDw8IE5GX0lQNl9MT0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sIHVfaW50MzJfdCBpZCwgaW50IGludmVydCkKK3sKKyAgICAgICBpbnQgcj0wOworICAgICAgIERFQlVHUCgiZnJhZyBpZF9tYXRjaDolYyAweCV4IDw9IDB4JXggPD0gMHgleCIsaW52ZXJ0PyAnISc6JyAnLAorICAgICAgICAgICAgICBtaW4saWQsbWF4KTsKKyAgICAgICByPShpZCA+PSBtaW4gJiYgaWQgPD0gbWF4KSBeIGludmVydDsKKyAgICAgICBERUJVR1AoIiByZXN1bHQgJXNcbiIscj8gIlBBU1MiIDogIkZBSUxFRCIpOworICAgICAgIHJldHVybiByOworfQorCitzdGF0aWMgaW50CittYXRjaChjb25zdCBzdHJ1Y3Qgc2tfYnVmZiAqc2tiLAorICAgICAgY29uc3Qgc3RydWN0IG5ldF9kZXZpY2UgKmluLAorICAgICAgY29uc3Qgc3RydWN0IG5ldF9kZXZpY2UgKm91dCwKKyAgICAgIGNvbnN0IHZvaWQgKm1hdGNoaW5mbywKKyAgICAgIGludCBvZmZzZXQsCisgICAgICB1bnNpZ25lZCBpbnQgcHJvdG9mZiwKKyAgICAgIGludCAqaG90ZHJvcCkKK3sKKyAgICAgICBzdHJ1Y3QgZnJhZ19oZHIgX2ZyYWcsICpmaCA9IE5VTEw7CisgICAgICAgY29uc3Qgc3RydWN0IGlwNnRfZnJhZyAqZnJhZ2luZm8gPSBtYXRjaGluZm87CisgICAgICAgdW5zaWduZWQgaW50IHRlbXA7CisgICAgICAgaW50IGxlbjsKKyAgICAgICB1OCBuZXh0aGRyOworICAgICAgIHVuc2lnbmVkIGludCBwdHI7CisgICAgICAgdW5zaWduZWQgaW50IGhkcmxlbiA9IDA7CisKKyAgICAgICAvKiB0eXBlIG9mIHRoZSAxc3QgZXh0aGRyICovCisgICAgICAgbmV4dGhkciA9IHNrYi0+bmguaXB2NmgtPm5leHRoZHI7CisgICAgICAgLyogcG9pbnRlciB0byB0aGUgMXN0IGV4dGhkciAqLworICAgICAgIHB0ciA9IHNpemVvZihzdHJ1Y3QgaXB2Nmhkcik7CisgICAgICAgLyogYXZhaWxhYmxlIGxlbmd0aCAqLworICAgICAgIGxlbiA9IHNrYi0+bGVuIC0gcHRyOworICAgICAgIHRlbXAgPSAwOworCisgICAgICAgIHdoaWxlIChpcDZ0X2V4dF9oZHIobmV4dGhkcikpIHsKKyAgICAgICAgICAgICAgIHN0cnVjdCBpcHY2X29wdF9oZHIgX2hkciwgKmhwOworCisgICAgICAgICAgICAgIERFQlVHUCgiaXB2Nl9mcmFnIGhlYWRlciBpdGVyYXRpb24gXG4iKTsKKworICAgICAgICAgICAgICAvKiBJcyB0aGVyZSBlbm91Z2ggc3BhY2UgZm9yIHRoZSBuZXh0IGV4dCBoZWFkZXI/ICovCisgICAgICAgICAgICAgICAgaWYgKGxlbiA8IChpbnQpc2l6ZW9mKHN0cnVjdCBpcHY2X29wdF9oZHIpKQorICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIDA7CisgICAgICAgICAgICAgIC8qIE5vIG1vcmUgZXh0aGRyIC0+IGV2YWx1YXRlICovCisgICAgICAgICAgICAgICAgaWYgKG5leHRoZHIgPT0gTkVYVEhEUl9OT05FKSB7CisgICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAvKiBFU1AgLT4gZXZhbHVhdGUgKi8KKyAgICAgICAgICAgICAgICBpZiAobmV4dGhkciA9PSBORVhUSERSX0VTUCkgeworICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgIH0KKworCSAgICAgIGhwID0gc2tiX2hlYWRlcl9wb2ludGVyKHNrYiwgcHRyLCBzaXplb2YoX2hkciksICZfaGRyKTsKKwkgICAgICBCVUdfT04oaHAgPT0gTlVMTCk7CisKKyAgICAgICAgICAgICAgLyogQ2FsY3VsYXRlIHRoZSBoZWFkZXIgbGVuZ3RoICovCisgICAgICAgICAgICAgICAgaWYgKG5leHRoZHIgPT0gTkVYVEhEUl9GUkFHTUVOVCkgeworICAgICAgICAgICAgICAgICAgICAgICAgaGRybGVuID0gODsKKyAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKG5leHRoZHIgPT0gTkVYVEhEUl9BVVRIKQorICAgICAgICAgICAgICAgICAgICAgICAgaGRybGVuID0gKGhwLT5oZHJsZW4rMik8PDI7CisgICAgICAgICAgICAgICAgZWxzZQorICAgICAgICAgICAgICAgICAgICAgICAgaGRybGVuID0gaXB2Nl9vcHRsZW4oaHApOworCisgICAgICAgICAgICAgIC8qIEZSQUcgLT4gZXZhbHVhdGUgKi8KKyAgICAgICAgICAgICAgICBpZiAobmV4dGhkciA9PSBORVhUSERSX0ZSQUdNRU5UKSB7CisgICAgICAgICAgICAgICAgICAgICB0ZW1wIHw9IE1BU0tfRlJBR01FTlQ7CisgICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgfQorCisKKyAgICAgICAgICAgICAgLyogc2V0IHRoZSBmbGFnICovCisgICAgICAgICAgICAgIHN3aXRjaCAobmV4dGhkcil7CisgICAgICAgICAgICAgICAgICAgICBjYXNlIE5FWFRIRFJfSE9QOgorICAgICAgICAgICAgICAgICAgICAgY2FzZSBORVhUSERSX1JPVVRJTkc6CisgICAgICAgICAgICAgICAgICAgICBjYXNlIE5FWFRIRFJfRlJBR01FTlQ6CisgICAgICAgICAgICAgICAgICAgICBjYXNlIE5FWFRIRFJfQVVUSDoKKyAgICAgICAgICAgICAgICAgICAgIGNhc2UgTkVYVEhEUl9ERVNUOgorICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBERUJVR1AoImlwdjZfZnJhZyBtYXRjaDogdW5rbm93biBuZXh0aGVhZGVyICV1XG4iLG5leHRoZHIpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAwOworICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICB9CisKKyAgICAgICAgICAgICAgICBuZXh0aGRyID0gaHAtPm5leHRoZHI7CisgICAgICAgICAgICAgICAgbGVuIC09IGhkcmxlbjsKKyAgICAgICAgICAgICAgICBwdHIgKz0gaGRybGVuOworCQlpZiAoIHB0ciA+IHNrYi0+bGVuICkgeworCQkJREVCVUdQKCJpcHY2X2ZyYWc6IG5ldyBwb2ludGVyIHRvbyBsYXJnZSEgXG4iKTsKKwkJCWJyZWFrOworCQl9CisgICAgICAgIH0KKworICAgICAgIC8qIEZSQUcgaGVhZGVyIG5vdCBmb3VuZCAqLworICAgICAgIGlmICggdGVtcCAhPSBNQVNLX0ZSQUdNRU5UICkgcmV0dXJuIDA7CisKKyAgICAgICBpZiAobGVuIDwgc2l6ZW9mKHN0cnVjdCBmcmFnX2hkcikpeworCSAgICAgICAqaG90ZHJvcCA9IDE7CisgICAgICAgCQlyZXR1cm4gMDsKKyAgICAgICB9CisKKyAgICAgICBmaCA9IHNrYl9oZWFkZXJfcG9pbnRlcihza2IsIHB0ciwgc2l6ZW9mKF9mcmFnKSwgJl9mcmFnKTsKKyAgICAgICBCVUdfT04oZmggPT0gTlVMTCk7CisKKyAgICAgICBERUJVR1AoIklORk8gJTA0WCAiLCBmaC0+ZnJhZ19vZmYpOworICAgICAgIERFQlVHUCgiT0ZGU0VUICUwNFggIiwgbnRvaHMoZmgtPmZyYWdfb2ZmKSAmIH4weDcpOworICAgICAgIERFQlVHUCgiUkVTICUwMlggJTA0WCIsIGZoLT5yZXNlcnZlZCwgbnRvaHMoZmgtPmZyYWdfb2ZmKSAmIDB4Nik7CisgICAgICAgREVCVUdQKCJNRiAlMDRYICIsIGZoLT5mcmFnX29mZiAmIGh0b25zKElQNl9NRikpOworICAgICAgIERFQlVHUCgiSUQgJXUgJTA4WFxuIiwgbnRvaGwoZmgtPmlkZW50aWZpY2F0aW9uKSwKKwkgICAgICBudG9obChmaC0+aWRlbnRpZmljYXRpb24pKTsKKworICAgICAgIERFQlVHUCgiS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EgYnl0ZSEpCisgKiAgICAgIDEJLT4gUGFkTiBMRU5HVEggaW5mbyAodG90YWwgbGVuZ3RoID0gbGVuZ3RoICsgMikKKyAqICAgICAgQzAgfCAyCS0+IEpVTUJPIDQgeCB4IHggeCAoIHh4eHggPiA2NGsgKQorICogICAgICA1CS0+IFJUQUxFUlQgMiB4IHgKKyAqLworCitzdGF0aWMgaW50CittYXRjaChjb25zdCBzdHJ1Y3Qgc2tfYnVmZiAqc2tiLAorICAgICAgY29uc3Qgc3RydWN0IG5ldF9kZXZpY2UgKmluLAorICAgICAgY29uc3Qgc3RydWN0IG5ldF9kZXZpY2UgKm91dCwKKyAgICAgIGNvbnN0IHZvaWQgKm1hdGNoaW5mbywKKyAgICAgIGludCBvZmZzZXQsCisgICAgICB1bnNpZ25lZCBpbnQgcHJvdG9mZiwKKyAgICAgIGludCAqaG90ZHJvcCkKK3sKKyAgICAgICBzdHJ1Y3QgaXB2Nl9vcHRfaGRyIF9vcHRzaCwgKm9oOworICAgICAgIGNvbnN0IHN0cnVjdCBpcDZ0X29wdHMgKm9wdGluZm8gPSBtYXRjaGluZm87CisgICAgICAgdW5zaWduZWQgaW50IHRlbXA7CisgICAgICAgdW5zaWduZWQgaW50IGxlbjsKKyAgICAgICB1OCBuZXh0aGRyOworICAgICAgIHVuc2lnbmVkIGludCBwdHI7CisgICAgICAgdW5zaWduZWQgaW50IGhkcmxlbiA9IDA7CisgICAgICAgdW5zaWduZWQgaW50IHJldCA9IDA7CisgICAgICAgdTggX29wdHR5cGUsICp0cCA9IE5VTEw7CisgICAgICAgdTggX29wdGxlbiwgKmxwID0gTlVMTDsKKyAgICAgICB1bnNpZ25lZCBpbnQgb3B0bGVuOworICAgICAgIAorICAgICAgIC8qIHR5cGUgb2YgdGhlIDFzdCBleHRoZHIgKi8KKyAgICAgICBuZXh0aGRyID0gc2tiLT5uaC5pcHY2aC0+bmV4dGhkcjsKKyAgICAgICAvKiBwb2ludGVyIHRvIHRoZSAxc3QgZXh0aGRyICovCisgICAgICAgcHRyID0gc2l6ZW9mKHN0cnVjdCBpcHY2aGRyKTsKKyAgICAgICAvKiBhdmFpbGFibGUgbGVuZ3RoICovCisgICAgICAgbGVuID0gc2tiLT5sZW4gLSBwdHI7CisgICAgICAgdGVtcCA9IDA7CisKKyAgICAgICAgd2hpbGUgKGlwNnRfZXh0X2hkcihuZXh0aGRyKSkgeworICAgICAgICAgICAgICAgc3RydWN0IGlwdjZfb3B0X2hkciBfaGRyLCAqaHA7CisKKyAgICAgICAgICAgICAgREVCVUdQKCJpcHY2X29wdHMgaGVhZGVyIGl0ZXJhdGlvbiBcbiIpOworCisgICAgICAgICAgICAgIC8qIElzIHRoZXJlIGVub3VnaCBzcGFjZSBmb3IgdGhlIG5leHQgZXh0IGhlYWRlcj8gKi8KKyAgICAgICAgICAgICAgICBpZiAobGVuIDwgKGludClzaXplb2Yoc3RydWN0IGlwdjZfb3B0X2hkcikpCisgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gMDsKKyAgICAgICAgICAgICAgLyogTm8gbW9yZSBleHRoZHIgLT4gZXZhbHVhdGUgKi8KKyAgICAgICAgICAgICAgICBpZiAobmV4dGhkciA9PSBORVhUSERSX05PTkUpIHsKKyAgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgIC8qIEVTUCAtPiBldmFsdWF0ZSAqLworICAgICAgICAgICAgICAgIGlmIChuZXh0aGRyID09IE5FWFRIRFJfRVNQKSB7CisgICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgfQorCisJICAgICAgaHAgPSBza2JfaGVhZGVyX3BvaW50ZXIoc2tiLCBwdHIsIHNpemVvZihfaGRyKSwgJl9oZHIpOworCSAgICAgIEJVR19PTihocCA9PSBOVUxMKTsKKworICAgICAgICAgICAgICAvKiBDYWxjdWxhdGUgdGhlIGhlYWRlciBsZW5ndGggKi8KKyAgICAgICAgICAgICAgICBpZiAobmV4dGhkciA9PSBORVhUSERSX0ZSQUdNRU5UKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBoZHJsZW4gPSA4OworICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAobmV4dGhkciA9PSBORVhUSERSX0FVVEgpCisgICAgICAgICAgICAgICAgICAgICAgICBoZHJsZW4gPSAoaHAtPmhkcmxlbisyKTw8MjsKKyAgICAgICAgICAgICAgICBlbHNlCisgICAgICAgICAgICAgICAgICAgICAgICBoZHJsZW4gPSBpcHY2X29wdGxlbihocCk7CisKKyAgICAgICAgICAgICAgLyogT1BUUyAtPiBldmFsdWF0ZSAqLworI2lmIEhPUEJZSE9QCisgICAgICAgICAgICAgICAgaWYgKG5leHRoZHIgPT0gTkVYVEhEUl9IT1ApIHsKKyAgICAgICAgICAgICAgICAgICAgIHRlbXAgfD0gTUFTS19IT1BPUFRTOworI2Vsc2UKKyAgICAgICAgICAgICAgICBpZiAobmV4dGhkciA9PSBORVhUSERSX0RFU1QpIHsKKyAgICAgICAgICAgICAgICAgICAgIHRlbXAgfD0gTUFTS19EU1RPUFRTOworI2VuZGlmCisgICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgfQorCisKKyAgICAgICAgICAgICAgLyogc2V0IHRoZSBmbGFnICovCisgICAgICAgICAgICAgIHN3aXRjaCAobmV4dGhkcil7CisgICAgICAgICAgICAgICAgICAgICBjYXNlIE5FWFRIRFJfSE9QOgorICAgICAgICAgICAgICAgICAgICAgY2FzZSBORVhUSERSX1JPVVRJTkc6CisgICAgICAgICAgICAgICAgICAgICBjYXNlIE5FWFRIRFJfRlJBR01FTlQ6CisgICAgICAgICAgICAgICAgICAgICBjYXNlIE5FWFRIRFJfQVVUSDoKKyAgICAgICAgICAgICAgICAgICAgIGNhc2UgTkVYVEhEUl9ERVNUOgorICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBERUJVR1AoImlwdjZfb3B0cyBtYXRjaDogdW5rbm93biBuZXh0aGVhZGVyICV1XG4iLG5leHRoZHIpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAwOworICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICB9CisKKyAgICAgICAgICAgICAgICBuZXh0aGRyID0gaHAtPm5leHRoZHI7CisgICAgICAgICAgICAgICAgbGVuIC09IGhkcmxlbjsKKyAgICAgICAgICAgICAgICBwdHIgKz0gaGRybGVuOworCQlpZiAoIHB0ciA+IHNrYi0+bGVuICkgeworCQkJREVCVUdQKCJpcHY2X29wdHM6IG5ldyBwb2ludGVyIGlzIHRvbyBsYXJnZSEgXG4iKTsKKwkJCWJyZWFrOworCQl9CisgICAgICAgIH0KKworICAgICAgIC8qIE9QVElPTlMgaGVhZGVyIG5vdCBmb3VuZCAqLworI2lmIEhPUEJZSE9QCisgICAgICAgaWYgKCB0ZW1wICE9IE1BU0tfSE9QT1BUUyApIHJldHVybiAwOworI2Vsc2UKKyAgICAgICBpZiAoIHRlbXAgIT0gTUFTS19EU1RPUFRTICkgcmV0dXJuIDA7CisjZW5kaWYKKworICAgICAgIGlmIChsZW4gPCAoaW50KXNpemVvZihzdHJ1Y3QgaXB2Nl9vcHRfaGRyKSl7CisJICAgICAgICpob3Rkcm9wID0gMTsKKyAgICAgICAJCXJldHVybiAwOworICAgICAgIH0KKworICAgICAgIGlmIChsZW4gPCBoZHJsZW4peworCSAgICAgICAvKiBQYWNrZXQgc21hbGxlciB0aGFuIGl0J3MgbGVuZ3RoIGZpZWxkICovCisgICAgICAgCQlyZXR1cm4gMDsKKyAgICAgICB9CisKKyAgICAgICBvaCA9IHNrYl9oZWFkZXJfcG9pbnRlcihza2IsIHB0ciwgc2l6ZW9mKF9vcHRzaCksICZfb3B0c2gpOworICAgICAgIEJVR19PTihvaCA9PSBOVUxMKTsKKworICAgICAgIERFQlVHUCgiSVB2NiBPUFRTIExFTiAldSAldSAiLCBoZHJsZW4sIG9oLT5oZHJsZW4pOworCisgICAgICAgREVCVUdQKCJsZW4gJTAyWCAlMDRYICUwMlggIiwKKyAgICAgICAJCW9wdGluZm8tPmhkcmxlbiwgaGRybGVuLAorICAgICAgIAkJKCEob3B0aW5mby0+ZmxhZ3MgJiBJUDZUX09QVFNfTEVOKSB8fAorICAgICAgICAgICAgICAgICAgICAgICAgICAgKChvcHRpbmZvLT5oZHJsZW4gPT0gaGRybGVuKSBeCisgICAgICAgICAgICAgICAgICAgICAgICAgICAhIShvcHRpbmZvLT5pbnZmbGFncyAmIElQNlRfT1BUU19JTlZfTEVOKSkpKTsKKworICAgICAgIHJldCA9IChvaCAhPSBOVUxMKQorICAgICAgIAkJJiYKKwkgICAgICAJKCEob3B0aW5mby0+ZmxhZ3MgJiBJUDZUX09QVFNfTEVOKSB8fAorICAgICAgICAgICAgICAgICAgICAgICAgICAgKChvcHRpbmZvLT5oZHJsZW4gPT0gaGRybGVuKSBeCisgICAgICAgICAgICAgICAgICAgICAgICAgICAhIShvcHRpbmZvLT5pbnZmbGFncyAmIElQNlRfT1BUU19JTlZfTEVOKSkpOworCisgICAgICAgcHRyICs9IDI7CisgICAgICAgaGRybGVuIC09IDI7CisgICAgICAgaWYgKCAhKG9wdGluZm8tPmZsYWdzICYgSVA2VF9PUFRTX09QVFMpICl7CisJICAgICAgIHJldHVybiByZXQ7CisJfSBlbHNlIGlmIChvcHRpbmZvLT5mbGFncyAmIElQNlRfT1BUU19OU1RSSUNUKSB7CisJCURFQlVHUCgiTm90IHN0cmljdCAtIG5vdCBpbXBsZW1lbnRlZCIpOworCX0gZWxzZSB7CisJCURFQlVHUCgiU3RyaWN0ICIpOworCQlERUJVR1AoIiMlZCAiLG9wdGluZm8tPm9wdHNucik7CisJCWZvcih0ZW1wPTA7IHRlbXA8b3B0aW5mby0+b3B0c25yOyB0ZW1wKyspeworCQkJLyogdHlwZSBmaWVsZCBleGlzdHMgPyAqL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lbiA9ICpscCArIDI7CisJCQl9IGVsc2UgeworCQkJCURFQlVHUCgiUGFkMVxuIik7CisJCQkJb3B0bGVuID0gMTsKKwkJCX0KKworCQkJLyogU3RlcCB0byB0aGUgbmV4dCAqLworCQkJREVCVUdQKCJsZW4lMDRYIFxuIiwgb3B0bGVuKTsKKworCQkJaWYgKChwdHIgPiBza2ItPmxlbiAtIG9wdGxlbiB8fCBoZHJsZW4gPCBvcHRsZW4pICYmCisJCQkgICAgKHRlbXAgPCBvcHRpbmZvLT5vcHRzbnIgLSAxKSkgeworCQkJCURFQlVHUCgibmV3IHBvaW50ZXIgaXMgdG9vIGxhcmdlISBcbiIpOworCQkJCWJyZWFrOworCQkJfQorCQkJcHRyICs9IG9wdGxlbjsKKwkJCWhkcmxlbiAtPSBvcHRsZW47CisJCX0KKwkJaWYgKHRlbXAgPT0gb3B0aW5mby0+b3B0c25yKQorCQkJcmV0dXJuIHJldDsKKwkJZWxzZSByZXR1cm4gMDsKKwl9CisKKwlyZXR1cm4gMDsKK30KKworLyogQ2FsbGVkIHdoZW4gdXNlciB0cmllcyB0byBpbnNlcnQgYW4gZW50cnkgb2YgdGhpcyB0eXBlLiAqLworc3RhdGljIGludAorY2hlY2tlbnRyeShjb25zdCBjaGFyICp0YWJsZW5hbWUsCisgICAgICAgICAgY29uc3Qgc3RydWN0IGlwNnRfaXA2ICppcCwKKyAgICAgICAgICB2b2lkICptYXRjaGluZm8sCisgICAgICAgICAgdW5zaWduZWQgaW50IG1hdGNoaW5mb3NpemUsCisgICAgICAgICAgdW5zaWduZWQgaW50IGhvb2tfbWFzaykKK3sKKyAgICAgICBjb25zdCBzdHJ1Y3QgaXA2dF9vcHRzICpvcHRzaW5mbyA9IG1hdGNoaW5mbzsKKworICAgICAgIGlmIChtYXRjaGluZm9zaXplICE9IElQNlRfQUxJR04oc2l6ZW9mKHN0cnVjdCBpcDZ0X29wdHMpKSkgeworICAgICAgICAgICAgICBERUJVR1AoImlwNnRfb3B0czogbWF0Y2hzaXplICV1ICE9ICV1XG4iLAorICAgICAgICAgICAgICAgICAgICAgIG1hdGNoaW5mb3NpemUsIElQNlRfQUxJR04oc2l6ZW9mKHN0cnVjdCBpcDZ0X29wdHMpKSk7CisgICAgICAgICAgICAgIHJldHVybiAwOworICAgICAgIH0KKyAgICAgICBpZiAob3B0c2luZm8tPmludmZsYWdzICYgfklQNlRfT1BUU19JTlZfTUFTSykgeworICAgICAgICAgICAgICBERUJVR1AoImlwNnRfb3B0czogdW5rbm93biBmbGFncyAlWFxuIiwKKyAgICAgICAgICAgICAgICAgICAgICBvcHRzaW5mby0+aW52ZmxhZ3MpOworICAgICAgICAgICAgICByZXR1cm4gMDsKKyAgICAgICB9CisKKyAgICAgICByZXR1cm4gMTsKK30KKworc3RhdGljIHN0cnVjdCBpcDZ0X21hdGNoIG9wdHNfbWF0Y2ggPSB7CisjaWYgSE9QQllIT1AKKwkubmFtZQkJPSAiaGJoIiwKKyNlbHNlCisJLm5hbWUJCT0gImRzdCIsCisjZW5kaWYKKwkubWF0Y2gJCT0gJm1hdGNoLAorCS5jaGVja2VudHJ5CT0gJmNoZWNrZW50cnksCisJLm1lCQk9IFRISVNfTU9EVUxFLAorfTsKKworc3RhdGljIGludCBfX2luaXQgaW5pdCh2b2lkKQoreworICAgICAgIHJldHVybiBpcDZ0X3JlZ2lzdGVyX21hdGNoKCZvcHRzX21hdGNoKTsKK30KKworc3RhdGljIHZvaWQgX19leGl0IGNsZWFudXAodm9pZCkKK3sKKyAgICAgICBpcDZ0X3VucmVnaXN0ZXJfbWF0Y2goJm9wdHNfbWF0Y2gpOworfQorCittb2R1bGVfaW5pdChpbml0KTsKK21vZHVsZV9leGl0KGNsZWFudXApOwpkaWZmIC0tZ2l0IGEvbmV0L2lwdjYvbmV0ZmlsdGVyL2lwNnRfaGwuYyBiL25ldC9pcHY2L25ldGZpbHRlci9pcDZ0X2hsLmMKbmV3IGZpbGUgbW9kZSAxMDA2NDQKaW5kZXggMDAwMDAwMC4uM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1BU0tfRVNQOworCQkJYnJlYWs7CisJCX0KKworCQlocCA9IHNrYl9oZWFkZXJfcG9pbnRlcihza2IsIHB0ciwgc2l6ZW9mKF9oZHIpLCAmX2hkcik7CisJCUJVR19PTihocCA9PSBOVUxMKTsKKworCQkvKiBDYWxjdWxhdGUgdGhlIGhlYWRlciBsZW5ndGggKi8KKyAgICAgICAgICAgICAgICBpZiAobmV4dGhkciA9PSBORVhUSERSX0ZSQUdNRU5UKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBoZHJsZW4gPSA4OworICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAobmV4dGhkciA9PSBORVhUSERSX0FVVEgpCisgICAgICAgICAgICAgICAgICAgICAgICBoZHJsZW4gPSAoaHAtPmhkcmxlbisyKTw8MjsKKyAgICAgICAgICAgICAgICBlbHNlCisgICAgICAgICAgICAgICAgICAgICAgICBoZHJsZW4gPSBpcHY2X29wdGxlbihocCk7CisKKwkJLyogc2V0IHRoZSBmbGFnICovCisJCXN3aXRjaCAobmV4dGhkcil7CisJCQljYXNlIE5FWFRIRFJfSE9QOgorCQkJCXRlbXAgfD0gTUFTS19IT1BPUFRTOworCQkJCWJyZWFrOworCQkJY2FzZSBORVhUSERSX1JPVVRJTkc6CisJCQkJdGVtcCB8PSBNQVNLX1JPVVRJTkc7CisJCQkJYnJlYWs7CisJCQljYXNlIE5FWFRIRFJfRlJBR01FTlQ6CisJCQkJdGVtcCB8PSBNQVNLX0ZSQUdNRU5UOworCQkJCWJyZWFrOworCQkJY2FzZSBORVhUSERSX0FVVEg6CisJCQkJdGVtcCB8PSBNQVNLX0FIOworCQkJCWJyZWFrOworCQkJY2FzZSBORVhUSERSX0RFU1Q6CisJCQkJdGVtcCB8PSBNQVNLX0RTVE9QVFM7CisJCQkJYnJlYWs7CisJCQlkZWZhdWx0OgorCQkJCXJldHVybiAwOworCQkJCWJyZWFrOworCQl9CisKKyAgICAgICAgICAgICAgICBuZXh0aGRyID0gaHAtPm5leHRoZHI7CisgICAgICAgICAgICAgICAgbGVuIC09IGhkcmxlbjsKKyAgICAgICAgICAgICAgICBwdHIgKz0gaGRybGVuOworCQlpZiAocHRyID4gc2tiLT5sZW4pCisJCQlicmVhazsKKyAgICAgICAgfQorCisJaWYgKCAobmV4dGhkciAhPSBORVhUSERSX05PTkUgKSAmJiAobmV4dGhkciAhPSBORVhUSERSX0VTUCkgKQorCQl0ZW1wIHw9IE1BU0tfUFJPVE87CisKKwlpZiAoaW5mby0+bW9kZWZsYWcpCisJCXJldHVybiAhKCh0ZW1wIF4gaW5mby0+bWF0Y2hmbGFncyBeIGluZm8tPmludmZsYWdzKQorCQkJICYgaW5mby0+bWF0Y2hmbGFncyk7CisJZWxzZSB7CisJCWlmIChpbmZvLT5pbnZmbGFncykKKwkJCXJldHVybiB0ZW1wICE9IGluZm8tPm1hdGNoZmxhZ3M7CisJCWVsc2UKKwkJCXJldHVybiB0ZW1wID09IGluZm8tPm1hdGNoZmxhZ3M7CisJfQorfQorCitzdGF0aWMgaW50CitpcHY2aGVhZGVyX2NoZWNrZW50cnkoY29uc3QgY2hhciAqdGFibGVuYW1lLAorCQkgICAgICBjb25zdCBzdHJ1Y3QgaXA2dF9pcDYgKmlwLAorCQkgICAgICB2b2lkICptYXRjaGluZm8sCisJCSAgICAgIHVuc2lnbmVkIGludCBtYXRjaHNpemUsCisJCSAgICAgIHVuc2lnbmVkIGludCBob29rX21hc2spCit7CisJY29uc3Qgc3RydWN0IGlwNnRfaXB2NmhlYWRlcl9pbmZvICppbmZvID0gbWF0Y2hpbmZvOworCisJLyogQ2hlY2sgZm9yIG9idmlvdXMgZXJyb3JzICovCisJLyogVGhpcyBtYXRjaCBpcyB2YWxpZCBpbiBhbGwgaG9va3MhICovCisJaWYgKG1hdGNoc2l6ZSAhPSBJUDZUX0FMSUdOKHNpemVvZihzdHJ1Y3QgaXA2dF9pcHY2aGVhZGVyX2luZm8pKSkKKwkJcmV0dXJuIDA7CisKKwkvKiBpbnZmbGFncyBpcy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yZXR1cm4gMDsKKwl9CisKKwlpZihpbmZvLT5tYXRjaCAmIElQNlRfT1dORVJfR0lEKSB7CisJCWlmKChza2ItPnNrLT5za19zb2NrZXQtPmZpbGUtPmZfZ2lkICE9IGluZm8tPmdpZCkgXgorCQkgICAgISEoaW5mby0+aW52ZXJ0ICYgSVA2VF9PV05FUl9HSUQpKQorCQkJcmV0dXJuIDA7CisJfQorCisJaWYoaW5mby0+bWF0Y2ggJiBJUDZUX09XTkVSX1BJRCkgeworCQlpZiAoIW1hdGNoX3BpZChza2IsIGluZm8tPnBpZCkgXgorCQkgICAgISEoaW5mby0+aW52ZXJ0ICYgSVA2VF9PV05FUl9QSUQpKQorCQkJcmV0dXJuIDA7CisJfQorCisJaWYoaW5mby0+bWF0Y2ggJiBJUDZUX09XTkVSX1NJRCkgeworCQlpZiAoIW1hdGNoX3NpZChza2IsIGluZm8tPnNpZCkgXgorCQkgICAgISEoaW5mby0+aW52ZXJ0ICYgSVA2VF9PV05FUl9TSUQpKQorCQkJcmV0dXJuIDA7CisJfQorCisJcmV0dXJuIDE7Cit9CisKK3N0YXRpYyBpbnQKK2NoZWNrZW50cnkoY29uc3QgY2hhciAqdGFibGVuYW1lLAorICAgICAgICAgICBjb25zdCBzdHJ1Y3QgaXA2dF9pcDYgKmlwLAorICAgICAgICAgICB2b2lkICptYXRjaGluZm8sCisgICAgICAgICAgIHVuc2lnbmVkIGludCBtYXRjaHNpemUsCisgICAgICAgICAgIHVuc2lnbmVkIGludCBob29rX21hc2spCit7CisgICAgICAgIGlmIChob29rX21hc2sKKyAgICAgICAgICAgICYgfigoMSA8PCBORl9JUDZfTE9DQUxfT1VUKSB8ICgxIDw8IE5GX0lQNl9QT1NUX1JPVVRJTkcpKSkgeworICAgICAgICAgICAgICAgIHByaW50aygiaXA2dF9vd25lcjogb25seSB2YWxpZCBmb3IgTE9DQUxfT1VUIG9yIFBPU1RfUk9VVElORy5cbiIpOworICAgICAgICAgICAgICAgIHJldHVybiAwOworICAgIC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QsCisgICAgICBjb25zdCB2b2lkICptYXRjaGluZm8sCisgICAgICBpbnQgb2Zmc2V0LAorICAgICAgdW5zaWduZWQgaW50IHByb3RvZmYsCisgICAgICBpbnQgKmhvdGRyb3ApCit7CisgICAgICAgc3RydWN0IGlwdjZfcnRfaGRyIF9yb3V0ZSwgKnJoID0gTlVMTDsKKyAgICAgICBjb25zdCBzdHJ1Y3QgaXA2dF9ydCAqcnRpbmZvID0gbWF0Y2hpbmZvOworICAgICAgIHVuc2lnbmVkIGludCB0ZW1wOworICAgICAgIHVuc2lnbmVkIGludCBsZW47CisgICAgICAgdTggbmV4dGhkcjsKKyAgICAgICB1bnNpZ25lZCBpbnQgcHRyOworICAgICAgIHVuc2lnbmVkIGludCBoZHJsZW4gPSAwOworICAgICAgIHVuc2lnbmVkIGludCByZXQgPSAwOworICAgICAgIHN0cnVjdCBpbjZfYWRkciAqYXAsIF9hZGRyOworCisgICAgICAgLyogdHlwZSBvZiB0aGUgMXN0IGV4dGhkciAqLworICAgICAgIG5leHRoZHIgPSBza2ItPm5oLmlwdjZoLT5uZXh0aGRyOworICAgICAgIC8qIHBvaW50ZXIgdG8gdGhlIDFzdCBleHRoZHIgKi8KKyAgICAgICBwdHIgPSBzaXplb2Yoc3RydWN0IGlwdjZoZHIpOworICAgICAgIC8qIGF2YWlsYWJsZSBsZW5ndGggKi8KKyAgICAgICBsZW4gPSBza2ItPmxlbiAtIHB0cjsKKyAgICAgICB0ZW1wID0gMDsKKworICAgICAgICB3aGlsZSAoaXA2dF9leHRfaGRyKG5leHRoZHIpKSB7CisgICAgICAgICAgICAgICBzdHJ1Y3QgaXB2Nl9vcHRfaGRyIF9oZHIsICpocDsKKworICAgICAgICAgICAgICBERUJVR1AoImlwdjZfcnQgaGVhZGVyIGl0ZXJhdGlvbiBcbiIpOworCisgICAgICAgICAgICAgIC8qIElzIHRoZXJlIGVub3VnaCBzcGFjZSBmb3IgdGhlIG5leHQgZXh0IGhlYWRlcj8gKi8KKyAgICAgICAgICAgICAgICBpZiAobGVuIDwgKGludClzaXplb2Yoc3RydWN0IGlwdjZfb3B0X2hkcikpCisgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gMDsKKyAgICAgICAgICAgICAgLyogTm8gbW9yZSBleHRoZHIgLT4gZXZhbHVhdGUgKi8KKyAgICAgICAgICAgICAgICBpZiAobmV4dGhkciA9PSBORVhUSERSX05PTkUpIHsKKyAgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgIC8qIEVTUCAtPiBldmFsdWF0ZSAqLworICAgICAgICAgICAgICAgIGlmIChuZXh0aGRyID09IE5FWFRIRFJfRVNQKSB7CisgICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgfQorCisJICAgICAgaHAgPSBza2JfaGVhZGVyX3BvaW50ZXIoc2tiLCBwdHIsIHNpemVvZihfaGRyKSwgJl9oZHIpOworCSAgICAgIEJVR19PTihocCA9PSBOVUxMKTsKKworICAgICAgICAgICAgICAvKiBDYWxjdWxhdGUgdGhlIGhlYWRlciBsZW5ndGggKi8KKyAgICAgICAgICAgICAgICBpZiAobmV4dGhkciA9PSBORVhUSERSX0ZSQUdNRU5UKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBoZHJsZW4gPSA4OworICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAobmV4dGhkciA9PSBORVhUSERSX0FVVEgpCisgICAgICAgICAgICAgICAgICAgICAgICBoZHJsZW4gPSAoaHAtPmhkcmxlbisyKTw8MjsKKyAgICAgICAgICAgICAgICBlbHNlCisgICAgICAgICAgICAgICAgICAgICAgICBoZHJsZW4gPSBpcHY2X29wdGxlbihocCk7CisKKyAgICAgICAgICAgICAgLyogUk9VVElORyAtPiBldmFsdWF0ZSAqLworICAgICAgICAgICAgICAgIGlmIChuZXh0aGRyID09IE5FWFRIRFJfUk9VVElORykgeworICAgICAgICAgICAgICAgICAgICAgdGVtcCB8PSBNQVNLX1JPVVRJTkc7CisgICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgfQorCisKKyAgICAgICAgICAgICAgLyogc2V0IHRoZSBmbGFnICovCisgICAgICAgICAgICAgIHN3aXRjaCAobmV4dGhkcil7CisgICAgICAgICAgICAgICAgICAgICBjYXNlIE5FWFRIRFJfSE9QOgorICAgICAgICAgICAgICAgICAgICAgY2FzZSBORVhUSERSX1JPVVRJTkc6CisgICAgICAgICAgICAgICAgICAgICBjYXNlIE5FWFRIRFJfRlJBR01FTlQ6CisgICAgICAgICAgICAgICAgICAgICBjYXNlIE5FWFRIRFJfQVVUSDoKKyAgICAgICAgICAgICAgICAgICAgIGNhc2UgTkVYVEhEUl9ERVNUOgorICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBERUJVR1AoImlwdjZfcnQgbWF0Y2g6IHVua25vd24gbmV4dGhlYWRlciAldVxuIixuZXh0aGRyKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gMDsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgfQorCisgICAgICAgICAgICAgICAgbmV4dGhkciA9IGhwLT5uZXh0aGRyOworICAgICAgICAgICAgICAgIGxlbiAtPSBoZHJsZW47CisgICAgICAgICAgICAgICAgcHRyICs9IGhkcmxlbjsKKwkJaWYgKCBwdHIgPiBza2ItPmxlbiApIHsKKwkJCURFQlVHUCgiaXB2Nl9ydDogbmV3IHBvaW50ZXIgaXMgdG9vIGxhcmdlISBcbiIpOworCQkJYnJlYWs7CisJCX0KKyAgICAgICAgfQorCisgICAgICAgLyogUk9VVElORyBoZWFkZXIgbm90IGZvdW5kICovCisgICAgICAgaWYgKCB0ZW1wICE9IE1BU0tfUk9VVElORyApIHJldHVybiAwOworCisgICAgICAgaWYgKGxlbiA8IChpbnQpc2l6ZW9mKHN0cnVjdCBpcHY2X3J0X2hkcikpeworCSAgICAgICAqaG90ZHJvcCA9IDE7CisgICAgICAgCQlyZXR1cm4gMDsKKyAgICAgICB9CisKKyAgICAgICBpZiAobGVuIDwgaGRybGVuKXsKKwkgICAgICAgLyogUGNrZXQgc21hbGxlciB0aGFuIGl0cyBsZW5ndGggZmllbGQgKi8KKyAgICAgICAJCXJldHVybiAwOworICAgICAgIH0KKworICAgICAgIHJoID0gc2tiX2hlYWRlcl9wb2ludGVyKHNrYiwgcHRyLCBzaXplb2YoX3JvdXRlKSwgJl9yb3V0ZSk7CisgICAgICAgQlVHX09OKHJoID09IE5VTEwpOworCisgICAgICAgREVCVUdQKCJJUHY2IFJUIExFTiAldSAldSAiLCBoZHJsZW4sIHJoLT5oZHJsZW4pOworICAgICAgIERFQlVHUCgiVFlQRSAlMDRYICIsIHJoLT50eXBlKTsKKyAgICAgICBERUJVR1AoIlNHU19MRUZUICV1ICUwMlhcbiIsIHJoLT5zZWdtZW50c19sZWZ0LCByaC0+c2VnbWVudHNfbGVmdCk7CisKKyAgICAgICBERUJVR1AoIklQdjYgUlQgc2Vnc2xlZnQgJTAyWCAiLAorICAgICAgIAkJKHNlZ3NsZWZ0X21hdGNoKHJ0aW5mby0+c2Vnc2xlZnRbMF0sIHJ0aW5mby0+c2Vnc2xlZnRbMV0sCisgICAgICAgICAgICAgICAgICAgICAgICAgICByaC0+c2VnbWVudHNfbGVmdCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICEhKHJ0aW5mby0+aW52ZmxhZ3MgJiBJUDZUX1JUX0lOVl9TR1MpKSkpOworICAgICAgIERFQlVHUCgidHlwZSAlMDJYICUwMlggJTAyWCAiLAorICAgICAgIAkJcnRpbmZvLT5ydF90eXBlLCByaC0+dHlwZSwgCisgICAgICAgCQkoIShydGluZm8tPmZsYWdzICYgSVA2VF9SVF9UWVApIHx8CisgICAgICAgICAgICAgICAgICAgICAgICAgICAoKHJ0aW5mby0+cnRfdHlwZSA9PSByaC0+dHlwZSkgXgorICAgICAgICAgICAgICAgICAgICAgICAgICAgISEocnRpbmZvLT5pbnZmbGFncyAmIElQNlRfUlRfSU5WX1RZUCkpKSk7CisgICAgICAgREVCVUdQKCJsZW4gJTAyWCAlMDRYICUwMlggIiwKKyAgICAgICAJCXJ0aW5mby0+aGRybGVuLCBoZHJsZW4sCisgICAgICAgCQkoIShydGluZm8tPmZsYWdzICYgSVA2VF9SVF9MRU4pIHx8CisgICAgICAgICAgICAgICAgICAgICAgICAgICAoKHJ0aW5mby0+aGRybGVuID09IGhkcmxlbikgXgorICAgICAgICAgICAgICAgICAgICAgICAgICAgISEocnRpbmZvLT5pbnZmbGFncyAmIElQNlRfUlRfSU5WX0xFTikpKSk7CisgICAgICAgREVCVUdQKCJyZXMgJTAyWCAlMDJYICUwMlggIiwgCisgICAgICAgCQkocnRpbmZvLT5mbGFncyAmIElQNlRfUlRfUkVTKSwgKChzdHJ1Y3QgcnQwX2hkciAqKXJoKS0+Yml0bWFwLAorICAgICAgIAkJISgocnRpbmZvLT5mbGFncyAmIElQNlRfUlRfUkVTKSAmJiAoKChzdHJ1Y3QgcnQwX2hkciAqKXJoKS0+Yml0bWFwKSkpOworCisgICAgICAgcmV0ID0gKHJoICE9IE5VTEwpCisgICAgICAgCQkmJgorICAgICAgIAkJKHNlZ3NsZWZ0X21hdGNoKHJ0aW5mby0+c2Vnc2xlZnRbMF0sIHJ0aW5mby0+c2Vnc2xlZnRbMV0sCisgICAgICAgICAgICAgICAgICAgICAgICAgICByaC0+c2VnbWVudHNfbGVmdCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICEhKHJ0aW5mby0+aW52ZmxhZ3MgJiBJUDZUX1JUX0lOVl9TR1MpKSkKKwkJJiYKKwkgICAgICAJKCEocnRpbmZvLT5mbGFncyAmIElQNlRfUlRfTEVOKSB8fAorICAgICAgICAgICAgICAgICAgICAgICAgICAgKChydGluZm8tPmhkcmxlbiA9PSBoZHJsZW4pIF4KKyAgICAgICAgICAgICAgICAgICAgICAgICAgICEhKHJ0aW5mby0+aW52ZmxhZ3MgJiBJUDZUX1JUX0lOVl9MRU4pKSkKKwkJJiYKKyAgICAgICAJCSghKHJ0aW5mby0+ZmxhZ3MgJiBJUDZUX1JUX1RZUCkgfHwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICgocnRpbmZvLT5ydF90eXBlID09IHJoLT50eXBlKSBeCisgICAgICAgICAgICAgICAgICAgICAgICAgICAhIShydGluZm8tPmludmZsYWdzICYgSVA2VF9SVF9JTlZfVFlQKSkpOworCisJaWYgKHJldCAmJiAocnRpbmZvLT5mbGFncyAmIElQNlRfUlRfUkVTKSkgeworCQl1X2ludDMyX3QgKmJwLCBfYml0bWFwOworCQlicCA9IHNrYl9oZWFkZXJfcG9pbnRlcihza2IsCisJCQkJCXB0ciArIG9mZnNldG9mKHN0cnVjdCBydDBfaGRyLCBiaXRtYXApLAorCQkJCQlzaXplb2YoX2JpdG1hcCksICZfYml0bWFwKTsKKworCQlyZXQgPSAoKmJwID09IDApOworCX0KKworCURFQlVHUCgiIyVkICIscnRpbmZvLT5hZGRybnIpOworICAgICAgIGlmICggIShydGluZm8tPmZsYWdzICYgSVA2VF9SVF9GU1QpICl7CisJICAgICAgIHJldHVybiByZXQ7CisJfSBlbHNlIGlmIChydGluZm8tPmZsYWdzICYgSVA2VF9SVF9GU1RfTlNUUklDVCkgeworCQlERUJVR1AoIk5vdCBzdHJpY3QgIik7CisJCWlmICggcnRpbmZvLT5hZGRybnIgPiAodW5zaWduZWQgaW50KSgoaGRybGVuLTgpLzE2KSApeworCQkJREVCVUdQKCJUaGVyZSBpc24ndCBlbm91Z2ggc3BhY2VcbiIpOworCQkJcmV0dXJuIDA7CisJCX0gZWxzZSB7CisJCQl1bnNpZ25lZCBpbnQgaSA9IDA7CisKKwkJCURFQlVHUCgiIyVkICIscnRpbmZvLT5hZGRybnIpOworCQkJZm9yKHRlbXA9MDsgdGVtcDwodW5zaWduZWQgaW50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pKTsKKyAgICAgICAgICAgICAgcmV0dXJuIDA7CisgICAgICAgfQorICAgICAgIGlmIChydGluZm8tPmludmZsYWdzICYgfklQNlRfUlRfSU5WX01BU0spIHsKKyAgICAgICAgICAgICAgREVCVUdQKCJpcDZ0X3J0OiB1bmtub3duIGZsYWdzICVYXG4iLAorICAgICAgICAgICAgICAgICAgICAgIHJ0aW5mby0+aW52ZmxhZ3MpOworICAgICAgICAgICAgICByZXR1cm4gMDsKKyAgICAgICB9CisgICAgICAgaWYgKCAocnRpbmZvLT5mbGFncyAmIChJUDZUX1JUX1JFU3xJUDZUX1JUX0ZTVF9NQVNLKSkgJiYgCisJCSAgICAgICAoIShydGluZm8tPmZsYWdzICYgSVA2VF9SVF9UWVApIHx8IAorCQkgICAgICAgKHJ0aW5mby0+cnRfdHlwZSAhPSAwKSB8fCAKKwkJICAgICAgIChydGluZm8tPmludmZsYWdzICYgSVA2VF9SVF9JTlZfVFlQKSkgKSB7CisJICAgICAgREVCVUdQKCJgLS1ydC10eXBlIDAnIHJlcXVpcmVkIGJlZm9yZSBgLS1ydC0wLSonIik7CisgICAgICAgICAgICAgIHJldHVybiAwOworICAgICAgIH0KKworICAgICAgIHJldHVybiAxOworfQorCitzdGF0aWMgc3RydWN0IGlwNnRfbWF0Y2ggcnRfbWF0Y2ggPSB7CisJLm5hbWUJCT0gInJ0IiwKKwkubWF0Y2gJCT0gJm1hdGNoLAorCS5jaGVja2VudHJ5CT0gJmNoZWNrZW50cnksCisJLm1lCQk9IFRISVNfTU9EVUxFLAorfTsKKworc3RhdGljIGludCBfX2luaXQgaW5pdCh2b2lkKQoreworICAgICAgIHJldHVybiBpcDZ0X3JlZ2lzdGVyX21hdGNoKCZydF9tYXRjaCk7Cit9CisKK3N0YXRpYyB2b2lkIF9fZXhpdCBjbGVhbnVwKHZvaWQpCit7CisgICAgICAgaXA2dF91bnJlZ2lzdGVyX21hdGNoKCZydF9tYXRjaCk7Cit9CisKK21vZHVsZV9pbml0KGluaXQpO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mFuc21pdHMsCisJCSAgIHNvY2tfaV91aWQoc3ApLAorCQkgICB0cC0+cHJvYmVzX291dCwKKwkJICAgc29ja19pX2lubyhzcCksCisJCSAgIGF0b21pY19yZWFkKCZzcC0+c2tfcmVmY250KSwgc3AsCisJCSAgIHRwLT5ydG8sIHRwLT5hY2suYXRvLCAodHAtPmFjay5xdWljazw8MSl8dHAtPmFjay5waW5ncG9uZywKKwkJICAgdHAtPnNuZF9jd25kLCB0cC0+c25kX3NzdGhyZXNoPj0weEZGRkY/LTE6dHAtPnNuZF9zc3RocmVzaAorCQkgICApOworfQorCitzdGF0aWMgdm9pZCBnZXRfdGltZXdhaXQ2X3NvY2soc3RydWN0IHNlcV9maWxlICpzZXEsIAorCQkJICAgICAgIHN0cnVjdCB0Y3BfdHdfYnVja2V0ICp0dywgaW50IGkpCit7CisJc3RydWN0IGluNl9hZGRyICpkZXN0LCAqc3JjOworCV9fdTE2IGRlc3RwLCBzcmNwOworCWludCB0dGQgPSB0dy0+dHdfdHRkIC0gamlmZmllczsKKworCWlmICh0dGQgPCAwKQorCQl0dGQgPSAwOworCisJZGVzdCAgPSAmdHctPnR3X3Y2X2RhZGRyOworCXNyYyAgID0gJnR3LT50d192Nl9yY3Zfc2FkZHI7CisJZGVzdHAgPSBudG9ocyh0dy0+dHdfZHBvcnQpOworCXNyY3AgID0gbnRvaHModHctPnR3X3Nwb3J0KTsKKworCXNlcV9wcmludGYoc2VxLAorCQkgICAiJTRkOiAlMDhYJTA4WCUwOFglMDhYOiUwNFggJTA4WCUwOFglMDhYJTA4WDolMDRYICIKKwkJICAgIiUwMlggJTA4WDolMDhYICUwMlg6JTA4bFggJTA4WCAlNWQgJThkICVkICVkICVwXG4iLAorCQkgICBpLAorCQkgICBzcmMtPnM2X2FkZHIzMlswXSwgc3JjLT5zNl9hZGRyMzJbMV0sCisJCSAgIHNyYy0+czZfYWRkcjMyWzJdLCBzcmMtPnM2X2FkZHIzMlszXSwgc3JjcCwKKwkJICAgZGVzd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OworCQlpcHhpdGZfaG9sZChpbnRyZmMpOworCQlpcHhpdGZfaW5zZXJ0KGludHJmYyk7CisJfQorCisKKwkvKiBJZiB0aGUgbmV0d29yayBudW1iZXIgaXMga25vd24sIGFkZCBhIHJvdXRlICovCisJcmMgPSAwOworCWlmICghaW50cmZjLT5pZl9uZXRudW0pCisJCWdvdG8gb3V0X2ludHJmYzsKKworCXJjID0gaXB4aXRmX2FkZF9sb2NhbF9yb3V0ZShpbnRyZmMpOworb3V0X2ludHJmYzoKKwlpcHhpdGZfcHV0KGludHJmYyk7CisJZ290byBvdXQ7CitvdXRfZGV2OgorCWRldl9wdXQoZGV2KTsKK291dDoKKwlyZXR1cm4gcmM7Cit9CisKK3N0YXRpYyBpbnQgaXB4aXRmX2RlbGV0ZShzdHJ1Y3QgaXB4X2ludGVyZmFjZV9kZWZpbml0aW9uICppZGVmKQoreworCXN0cnVjdCBuZXRfZGV2aWNlICpkZXYgPSBOVUxMOworCXVuc2lnbmVkIHNob3J0IGRsaW5rX3R5cGUgPSAwOworCXN0cnVjdCBpcHhfaW50ZXJmYWNlICppbnRyZmM7CisJaW50IHJjID0gMDsKKworCXNwaW5fbG9ja19iaCgmaXB4X2ludGVyZmFjZXNfbG9jayk7CisJaWYgKGlkZWYtPmlweF9zcGVjaWFsID09IElQWF9JTlRFUk5BTCkgeworCQlpZiAoaXB4X2ludGVybmFsX25ldCkgeworCQkJX19pcHhpdGZfcHV0KGlweF9pbnRlcm5hbF9uZXQpOworCQkJZ290byBvdXQ7CisJCX0KKwkJcmMgPSAtRU5PRU5UOworCQlnb3RvIG91dDsKKwl9CisKKwlkbGlua190eXBlID0gaXB4X21hcF9mcmFtZV90eXBlKGlkZWYtPmlweF9kbGlua190eXBlKTsKKwlyYyA9IC1FUFJPVE9OT1NVUFBPUlQ7CisJaWYgKCFkbGlua190eXBlKQorCQlnb3RvIG91dDsKKworCWRldiA9IF9fZGV2X2dldF9ieV9uYW1lKGlkZWYtPmlweF9kZXZpY2UpO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pZHgoLS1sKSA6IFNFUV9TVEFSVF9UT0tFTjsKK30KKworc3RhdGljIHZvaWQgKmlweF9zZXFfc29ja2V0X25leHQoc3RydWN0IHNlcV9maWxlICpzZXEsIHZvaWQgKnYsIGxvZmZfdCAqcG9zKQoreworCXN0cnVjdCBzb2NrKiBzaywgKm5leHQ7CisJc3RydWN0IGlweF9pbnRlcmZhY2UgKmk7CisJc3RydWN0IGlweF9zb2NrICppcHhzOworCisJKysqcG9zOworCWlmICh2ID09IFNFUV9TVEFSVF9UT0tFTikgeworCQlzayA9IE5VTEw7CisJCWkgPSBpcHhfaW50ZXJmYWNlc19oZWFkKCk7CisJCWlmICghaSkKKwkJCWdvdG8gb3V0OworCQlzayA9IHNrX2hlYWQoJmktPmlmX3NrbGlzdCk7CisJCWlmIChzaykKKwkJCXNwaW5fbG9ja19iaCgmaS0+aWZfc2tsaXN0X2xvY2spOworCQlnb3RvIG91dDsKKwl9CisJc2sgPSB2OworCW5leHQgPSBza19uZXh0KHNrKTsKKwlpZiAobmV4dCkgeworCQlzayA9IG5leHQ7CisJCWdvdG8gb3V0OworCX0KKwlpcHhzID0gaXB4X3NrKHNrKTsKKwlpID0gaXB4cy0+aW50cmZjOworCXNwaW5fdW5sb2NrX2JoKCZpLT5pZl9za2xpc3RfbG9jayk7CisJc2sgPSBOVUxMOworCWZvciAoOzspIHsKKwkJaSA9IGlweF9pbnRlcmZhY2VzX25leHQoaSk7CisJCWlmICghaSkKKwkJCWJyZWFrOworCQlzcGluX2xvY2tfYmgoJmktPmlmX3NrbGlzdF9sb2NrKTsKKwkJaWYgKCFobGlzdF9lbXB0eSgmaS0+aWZfc2tsaXN0KSkgeworCQkJc2sgPSBza19oZWFkKCZpLT5pZl9za2xpc3QpOworCQkJYnJlYWs7CisJCX0KKwkJc3Bpbl91bmxvY2tfYmgoJmktPmlmX3NrbGlzdF9sb2NrKTsKKwl9CitvdXQ6CisJcmV0dXJuIHNrOworfQorCitzdGF0aWMgaW50IGlweF9zZXF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nJlZSBTb2Z0d2FyZQorICogICAgIEZvdW5kYXRpb24sIEluYy4sIDU5IFRlbXBsZSBQbGFjZSwgU3VpdGUgMzMwLCBCb3N0b24sCisgKiAgICAgTUEgMDIxMTEtMTMwNyBVU0EKKyAqCisgKiAgICAgTGludXgtSXJEQSBub3cgc3VwcG9ydHMgZm91ciBkaWZmZXJlbnQgdHlwZXMgb2YgSXJEQSBzb2NrZXRzOgorICoKKyAqICAgICBvIFNPQ0tfU1RSRUFNOiAgICBUaW55VFAgY29ubmVjdGlvbnMgd2l0aCBTQVIgZGlzYWJsZWQuIFRoZQorICogICAgICAgICAgICAgICAgICAgICAgIG1heCBTRFUgc2l6ZSBpcyAwIGZvciBjb25uLiBvZiB0aGlzIHR5cGUKKyAqICAgICBvIFNPQ0tfU0VRUEFDS0VUOiBUaW55VFAgY29ubmVjdGlvbnMgd2l0aCBTQVIgZW5hYmxlZC4gVFRQIG1heQorICogICAgICAgICAgICAgICAgICAgICAgIGZyYWdtZW50IHRoZSBtZXNzYWdlcywgYnV0IHdpbGwgcHJlc2VydmUKKyAqICAgICAgICAgICAgICAgICAgICAgICB0aGUgbWVzc2FnZSBib3VuZGFyaWVzCisgKiAgICAgbyBTT0NLX0RHUkFNOiAgICAgSVJEQVBST1RPX1VOSVREQVRBOiBUaW55VFAgY29ubmVjdGlvbnMgd2l0aCBVbml0ZGF0YQorICogICAgICAgICAgICAgICAgICAgICAgICh1bnJlbGlhYmxlKSB0cmFuc2ZlcnMKKyAqICAgICAgICAgICAgICAgICAgICAgICBJUkRBUFJPVE9fVUxUUkE6IENvbm5lY3Rpb25sZXNzIGFuZCB1bnJlbGlhYmxlIGRhdGEKKyAqCisgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisKKyNpbmNsdWRlIDxsaW51eC9jb25maWcuaD4KKyNpbmNsdWRlIDxsaW51eC9tb2R1bGUuaD4KKyNpbmNsdWRlIDxsaW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X3R5cGUpCit7CisJc3RydWN0IGlyY29tbV9pbmZvIGluZm87CisJaW50IHJldDsKKworCUlSREFfREVCVUcoMiAsICIlcygpXG4iLCBfX0ZVTkNUSU9OX18gKTsKKworCUlSREFfQVNTRVJUKHNlbGYgIT0gTlVMTCwgcmV0dXJuIC0xOyk7CisJSVJEQV9BU1NFUlQoc2VsZi0+bWFnaWMgPT0gSVJDT01NX01BR0lDLCByZXR1cm4gLTE7KTsKKworCXNlbGYtPnNlcnZpY2VfdHlwZT0gc2VydmljZV90eXBlOworCisJaW5mby5kbHNhcF9zZWwgPSBkbHNhcF9zZWw7CisJaW5mby5zYWRkciA9IHNhZGRyOworCWluZm8uZGFkZHIgPSBkYWRkcjsKKworCXJldCA9IGlyY29tbV9kb19ldmVudChzZWxmLCBJUkNPTU1fQ09OTkVDVF9SRVFVRVNULCBza2IsICZpbmZvKTsKKworCXJldHVybiByZXQ7Cit9CisKK0VYUE9SVF9TWU1CT0woaXJjb21tX2Nvbm5lY3RfcmVxdWVzdCk7CisKKy8qCisgKiBGdW5jdGlvbiBpcmNvbW1fY29ubmVjdF9pbmRpY2F0aW9uIChzZWxmLCBxb3MsIHNrYikKKyAqCisgKiAgICBOb3RpZnkgdXNlciBsYXllciBhYm91dCB0aGUgaW5jb21pbmcgY29ubmVjdGlvbgorICoKKyAqLwordm9pZCBpcmNvbW1fY29ubmVjdF9pbmRpY2F0aW9uKHN0cnVjdCBpcmNvbW1fY2IgKnNlbGYsIHN0cnVjdCBza19idWZmICpza2IsCisJCQkgICAgICAgc3RydWN0IGlyY29tbV9pbmZvICppbmZvKQoreworCWludCBjbGVuID0gMDsKKwkKKwlJUkRBX0RFQlVHKDIsICIlcygpXG4iLCBfX0ZVTkNUSU9OX18gKTsKKworCS8qIENoZWNrIGlmIHRoZSBwYWNrZXQgY29udGFpbnMgZGF0YSBvbiB0aGUgY29udHJvbCBjaGFubmVsICovCisJaWYgKHNrYi0+bGVuID4gMCkKKwkJY2xlbiA9IHNrYi0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21tX2NiICpzZWxmID0gKHN0cnVjdCBpcmNvbW1fY2IgKikgaW5zdGFuY2U7CisJc3RydWN0IGlyY29tbV9pbmZvIGluZm87CisKKwlJUkRBX0RFQlVHKDAsICIlcygpXG4iLCBfX0ZVTkNUSU9OX18gKTsKKworCUlSREFfQVNTRVJUKHNlbGYgIT0gTlVMTCwgcmV0dXJuOyk7CisJSVJEQV9BU1NFUlQoc2VsZi0+bWFnaWMgPT0gSVJDT01NX01BR0lDLCByZXR1cm47KTsKKwlJUkRBX0FTU0VSVChza2IgIT0gTlVMTCwgcmV0dXJuOyk7CisJSVJEQV9BU1NFUlQocW9zICE9IE5VTEwsIHJldHVybjspOworCisJaW5mby5tYXhfZGF0YV9zaXplID0gbWF4X3NlZ19zaXplOworCWluZm8ubWF4X2hlYWRlcl9zaXplID0gbWF4X2hlYWRlcl9zaXplOworCWluZm8ucW9zID0gcW9zOworCisJaXJjb21tX2RvX2V2ZW50KHNlbGYsIElSQ09NTV9MTVBfQ09OTkVDVF9DT05GSVJNLCBza2IsICZpbmZvKTsKKworCS8qIERyb3AgcmVmZXJlbmNlIGNvdW50IC0gc2VlIGlyY29tbV90dHlfY29ubmVjdF9jb25maXJtKCkuICovCisJZGV2X2tmcmVlX3NrYihza2IpOworfQorCisvKgorICogRnVuY3Rpb24gaXJjb21tX2xtcF9jb25uZWN0X2luZGljYXRpb24gKGluc3RhbmNlLCBzYXAsIHFvcywgbWF4X3NkdV9zaXplLAorICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1heF9oZWFkZXJfc2l6ZSwgc2tiKQorICoKKyAqICAgIFBlZXIgZGV2aWNlIHdhbnRzIHRvIG1ha2UgYSBjb25uZWN0aW9uIHdpdGggdXMKKyAqCisgKi8KK3N0YXRpYyB2b2lkIGlyY29tbV9sbXBfY29ubmVjdF9pbmRpY2F0aW9uKHZvaWQgKmluc3RhbmNlLCB2b2lkICpzYXAsCisJCQkJCSAgc3RydWN0IHFvc19pbmZvICpxb3MsCisJCQkJCSAgX191MzIgbWF4X3NlZ19zaXplLAorCQkJCQkgIF9fdTggbWF4X2hlYWRlcl9zaXplLAorCQkJCQkgIHN0cnVjdCBza19idWZmICpza2IpCit7CisJc3RydWN0IGlyY29tbV9jYiAqc2VsZiA9IChzdHJ1Y3QgaXJjb21tX2NiICopaW5zdGFuY2U7CisJc3RydWN0IGlyY29tbV9pbmZvIGluZm87CisKKwlJUkRBX0RFQlVHKDAsICIlcygpXG4iLCBfX0ZVTkNUSU9OX18gKTsKKworCUlSREFfQVNTRVJUKHNlbGYgIT0gTlVMTCwgcmV0dXJuOyk7CisJSVJEQV9BU1NFUlQoc2VsZi0+bWFnaWMgPT0gSVJDT01NX01BR0lDLCByZXR1cm47KTsKKwlJUkRBX0FTU0VSVChza2IgIT0gTlVMTCwgcmV0dXJuOyk7CisJSVJEQV9BU1NFUlQocW9zICE9IE5VTEwsIHJldHVybjspOworCisJaW5mby5tYXhfZGF0YV9zaXplID0gbWF4X3NlZ19zaXplOworCWluZm8ubWF4X2hlYWRlcl9zaXplID0gbWF4X2hlYWRlcl9zaXplOworCWluZm8ucW9zID0gcW9zOworCisJaXJjb21tX2RvX2V2ZW50KHNlbGYsIElSQ09NTV9MTVBfQ09OTkVDVF9JTkRJQ0FUSU9OLCBza2IsICZpbmZvKTsKKworCS8qIERyb3AgcmVmZXJlbmNlIGNvdW50IC0gc2VlIGlyY29tbV90dHlfY29ubmVjdF9pbmRpY2F0aW9uKCkuICovCisJZGV2X2tmcmVlX3NrYihza2IpOworfQorCisvKgorICogRnVuY3Rpb24gaXJjb21tX2xtcF9kaXNjb25uZWN0X2luZGljYXRpb24gKGluc3RhbmNlLCBzYXAsIHJlYXNvbiwgc2tiKQorICoKKyAqICAgIFBlZXIgZGV2aWNlIGhhcyBjbG9zZWQgdGhlIGNvbm5lY3Rpb24sIG9yIHRoZSBsaW5rIHdlbnQgZG93biBmb3Igc29tZQorICogICAgb3RoZXIgcmVhc29uCisgKi8KK3N0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cm1hdCh2b2lkICppbnN0YW5jZSwgaXJkYV9wYXJhbV90ICpwYXJhbSwgCisJCQkJICAgIGludCBnZXQpCit7CisJc3RydWN0IGlyY29tbV90dHlfY2IgKnNlbGYgPSAoc3RydWN0IGlyY29tbV90dHlfY2IgKikgaW5zdGFuY2U7CisKKwlJUkRBX0FTU0VSVChzZWxmICE9IE5VTEwsIHJldHVybiAtMTspOworCUlSREFfQVNTRVJUKHNlbGYtPm1hZ2ljID09IElSQ09NTV9UVFlfTUFHSUMsIHJldHVybiAtMTspOworCisJaWYgKGdldCkKKwkJcGFyYW0tPnB2LmkgPSBzZWxmLT5zZXR0aW5ncy5kYXRhX2Zvcm1hdDsKKwllbHNlCisJCXNlbGYtPnNldHRpbmdzLmRhdGFfZm9ybWF0ID0gKF9fdTgpIHBhcmFtLT5wdi5pOworCQorCXJldHVybiAwOworfQorCisvKgorICogRnVuY3Rpb24gaXJjb21tX3BhcmFtX2Zsb3dfY29udHJvbCAoc2VsZiwgcGFyYW0pCisgKgorICogICAgRXhjaGFuZ2UgZmxvdyBjb250cm9sIHNldHRpbmdzIHRvIGJlIHVzZWQgaW4gdGhpcyBzZXR0aW5ncworICoKKyAqLworc3RhdGljIGludCBpcmNvbW1fcGFyYW1fZmxvd19jb250cm9sKHZvaWQgKmluc3RhbmNlLCBpcmRhX3BhcmFtX3QgKnBhcmFtLCAKKwkJCQkgICAgIGludCBnZXQpCit7CisJc3RydWN0IGlyY29tbV90dHlfY2IgKnNlbGYgPSAoc3RydWN0IGlyY29tbV90dHlfY2IgKikgaW5zdGFuY2U7CisKKwlJUkRBX0FTU0VSVChzZWxmICE9IE5VTEwsIHJldHVybiAtMTspOworCUlSREFfQVNTRVJUKHNlbGYtPm1hZ2ljID09IElSQ09NTV9UVFlfTUFHSUMsIHJldHVybiAtMTspOworCQorCWlmIChnZXQpCisJCXBhcmFtLT5wdi5pID0gc2VsZi0+c2V0dGluZ3MuZmxvd19jb250cm9sOworCWVsc2UKKwkJc2VsZi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VuZ2h0IDAgKGp1c3QgYSBzaWduYWwpICovCisJaWYgKCFnZXQpIHsKKwkJLyogUmVzcG9uZCB3aXRoIERURSBsaW5lIHNldHRpbmdzICovCisJCWlyY29tbV9wYXJhbV9yZXF1ZXN0KHNlbGYsIElSQ09NTV9EVEUsIFRSVUUpOworCX0KKwlyZXR1cm4gMDsKK30KKworCisKKworCmRpZmYgLS1naXQgYS9uZXQvaXJkYS9pcmNvbW0vaXJjb21tX3R0cC5jIGIvbmV0L2lyZGEvaXJjb21tL2lyY29tbV90dHAuYwpuZXcgZmlsZSBtb2RlIDEwMDY0NAppbmRleCAwMDAwMDAwLi5kOThiZjM1Ci0tLSAvZGV2L251bGwKKysrIGIvbmV0L2lyZGEvaXJjb21tL2lyY29tbV90dHAuYwpAQCAtMCwwICsxLDM2OSBAQAorLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorICogICAgICAgICAgICAgICAgCisgKiBGaWxlbmFtZTogICAgICBpcmNvbW1fdHRwLmMKKyAqIFZlcnNpb246ICAgICAgIDEuMAorICogRGVzY3JpcHRpb246ICAgSW50ZXJmYWNlIGJldHdlZW4gSXJDT01NIGFuZCBJclRUUAorICogU3RhdHVzOiAgICAgICAgU3RhYmxlCisgKiBBdXRob3I6ICAgICAgICBEYWcgQnJhdHRsaSA8ZGFnYkBjcy51aXQubm8+CisgKiBDcmVhdGVkIGF0OiAgICBTdW4gSnVuICA2IDIwOjQ4OjI3IDE5OTkKKyAqIE1vZGlmaWVkIGF0OiAgIE1vbiBEZWMgMTMgMTE6MzU6MTMgMTk5OQorICogTW9kaWZpZWQgYnk6ICAgRGFnIEJyYXR0bGkgPGRhZ2JAY3MudWl0Lm5vPgorICogCisgKiAgICAgQ29weXJpZ2h0IChjKSAxOTk5IERhZyBCcmF0dGxpLCBBbGwgUmlnaHRzIFJlc2VydmVkLgorICogICAgIENvcHlyaWdodCAoYykgMjAwMC0yMD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RpY2F0aW9uIChpbnN0YW5jZSwgc2FwLCBza2IpCisgKgorICogICAgSW5jb21pbmcgZGF0YQorICoKKyAqLworc3RhdGljIGludCBpcmNvbW1fdHRwX2RhdGFfaW5kaWNhdGlvbih2b2lkICppbnN0YW5jZSwgdm9pZCAqc2FwLAorCQkJCSAgICAgIHN0cnVjdCBza19idWZmICpza2IpCit7CisJc3RydWN0IGlyY29tbV9jYiAqc2VsZiA9IChzdHJ1Y3QgaXJjb21tX2NiICopIGluc3RhbmNlOworCisJSVJEQV9ERUJVRyg0LCAiJXMoKVxuIiwgX19GVU5DVElPTl9fICk7CisJCisJSVJEQV9BU1NFUlQoc2VsZiAhPSBOVUxMLCByZXR1cm4gLTE7KTsKKwlJUkRBX0FTU0VSVChzZWxmLT5tYWdpYyA9PSBJUkNPTU1fTUFHSUMsIHJldHVybiAtMTspOworCUlSREFfQVNTRVJUKHNrYiAhPSBOVUxMLCByZXR1cm4gLTE7KTsKKworCWlyY29tbV9kb19ldmVudChzZWxmLCBJUkNPTU1fVFRQX0RBVEFfSU5ESUNBVElPTiwgc2tiLCBOVUxMKTsKKworCS8qIERyb3AgcmVmZXJlbmNlIGNvdW50IC0gc2VlIGlyY29tbV90dHlfZGF0YV9pbmRpY2F0aW9uKCkuICovCisJZGV2X2tmcmVlX3NrYihza2IpOworCisJcmV0dXJuIDA7Cit9CisKK3N0YXRpYyB2b2lkIGlyY29tbV90dHBfY29ubmVjdF9jb25maXJtKHZvaWQgKmluc3RhbmNlLCB2b2lkICpzYXAsCisJCQkJICAgICAgIHN0cnVjdCBxb3NfaW5mbyAqcW9zLCAKKwkJCQkgICAgICAgX191MzIgbWF4X3NkdV9zaXplLCAKKwkJCQkgICAgICAgX191OCBtYXhfaGVhZGVyX3NpemUsCisJCQkJICAgICAgIHN0cnVjdCBza19idWZmICpza2IpCit7CisJc3RydWN0IGlyY29tbV9jYiAqc2VsZiA9IChzdHJ1Y3QgaXJjb21tX2NiICopIGluc3RhbmNlOworCXN0cn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PSBpcmNvbW1fdHR5X2lvY3RsLAkvKiBpcmNvbW1fdHR5X2lvY3RsLmMgKi8KKwkudGlvY21nZXQgICAgICAgID0gaXJjb21tX3R0eV90aW9jbWdldCwJLyogaXJjb21tX3R0eV9pb2N0bC5jICovCisJLnRpb2Ntc2V0ICAgICAgICA9IGlyY29tbV90dHlfdGlvY21zZXQsCS8qIGlyY29tbV90dHlfaW9jdGwuYyAqLworCS50aHJvdHRsZSAgICAgICAgPSBpcmNvbW1fdHR5X3Rocm90dGxlLAorCS51bnRocm90dGxlICAgICAgPSBpcmNvbW1fdHR5X3VudGhyb3R0bGUsCisJLnNlbmRfeGNoYXIgICAgICA9IGlyY29tbV90dHlfc2VuZF94Y2hhciwKKwkuc2V0X3Rlcm1pb3MgICAgID0gaXJjb21tX3R0eV9zZXRfdGVybWlvcywKKwkuc3RvcCAgICAgICAgICAgID0gaXJjb21tX3R0eV9zdG9wLAorCS5zdGFydCAgICAgICAgICAgPSBpcmNvbW1fdHR5X3N0YXJ0LAorCS5oYW5ndXAgICAgICAgICAgPSBpcmNvbW1fdHR5X2hhbmd1cCwKKwkud2FpdF91bnRpbF9zZW50ID0gaXJjb21tX3R0eV93YWl0X3VudGlsX3NlbnQsCisjaWZkZWYgQ09ORklHX1BST0NfRlMKKwkucmVhZF9wcm9jICAgICAgID0gaXJjb21tX3R0eV9yZWFkX3Byb2MsCisjZW5kaWYgLyogQ09ORklHX1BST0NfRlMgKi8KK307CisKKy8qCisgKiBGdW5jdGlvbiBpcmNvbW1fdHR5X2luaXQoKQorICoKKyAqICAgIEluaXQgSXJDT01NIFRUWSBsYXllci9kcml2ZXIKKyAqCisgKi8KK3N0YXRpYyBpbnQgX19pbml0IGlyY29tbV90dHlfaW5pdCh2b2lkKQoreworCWRyaXZlciA9IGFsbG9jX3R0eV9kcml2ZXIoSVJDT01NX1RUWV9QT1JUUyk7CisJaWYgKCFkcml2ZXIpCisJCXJldHVybiAtRU5PTUVNOworCWlyY29tbV90dHkgPSB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X2RyaXZlcihkcml2ZXIpOworCQlyZXR1cm4gLTE7CisJfQorCXJldHVybiAwOworfQorCitzdGF0aWMgdm9pZCBfX2V4aXQgX19pcmNvbW1fdHR5X2NsZWFudXAoc3RydWN0IGlyY29tbV90dHlfY2IgKnNlbGYpCit7CisJSVJEQV9ERUJVRygwLCAiJXMoKVxuIiwgX19GVU5DVElPTl9fICk7CisKKwlJUkRBX0FTU0VSVChzZWxmICE9IE5VTEwsIHJldHVybjspOworCUlSREFfQVNTRVJUKHNlbGYtPm1hZ2ljID09IElSQ09NTV9UVFlfTUFHSUMsIHJldHVybjspOworCisJaXJjb21tX3R0eV9zaHV0ZG93bihzZWxmKTsKKworCXNlbGYtPm1hZ2ljID0gMDsKKwlrZnJlZShzZWxmKTsKK30KKworLyoKKyAqIEZ1bmN0aW9uIGlyY29tbV90dHlfY2xlYW51cCAoKQorICoKKyAqICAgIFJlbW92ZSBJckNPTU0gVFRZIGxheWVyL2RyaXZlcgorICoKKyAqLworc3RhdGljIHZvaWQgX19leGl0IGlyY29tbV90dHlfY2xlYW51cCh2b2lkKQoreworCWludCByZXQ7CisKKwlJUkRBX0RFQlVHKDQsICIlcygpXG4iLCBfX0ZVTkNUSU9OX18gKTsJCisKKwlyZXQgPSB0dHlfdW5yZWdpc3Rlcl9kcml2ZXIoZHJpdmVyKTsKKyAgICAgICAgaWYgKHJldCkgeworICAgICAgICAgICAgICAgIElSREFfRVJST1IoIiVzKCksIGZhaWxlZCB0byB1bnJlZ2lzdGVyIGRyaXZlclxuIiwKKwkJCSAgIF9fRlVOQ1RJT05fXyk7CisJCXJldHVybjsKKwl9CisKKwloYXNoYmluX2RlbGV0ZShpcmNvbW1fdHR5LCAoRlJFRV9GVU5DKSBfX2lyY29tbV90dHlfY2xlYW51cCk7CisJcHV0X3R0eV9kcml2ZXIoZHJpdmVyKTsKK30KKworLyoKKyAqIEZ1bmN0aW9uIGlyY29tbV9zdGFydHVwIChzZWxmKQorICoKKyAqICAgIAorICoKKyA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1fUlRTKQorICAgICAgICAgICAgICAgIHJldCArPSBzcHJpbnRmKGJ1ZityZXQsICJSVFN8Iik7CisgICAgICAgIGlmIChzZWxmLT5zZXR0aW5ncy5kdGUgJiBJUkNPTU1fRFRSKQorICAgICAgICAgICAgICAgIHJldCArPSBzcHJpbnRmKGJ1ZityZXQsICJEVFJ8Iik7CisJaWYgKHNlbGYtPnNldHRpbmdzLmR0ZSkKKwkJcmV0LS07IC8qIHJlbW92ZSB0aGUgbGFzdCB8ICovCisgICAgICAgIHJldCArPSBzcHJpbnRmKGJ1ZityZXQsICJcbiIpOworCisJcmV0ICs9IHNwcmludGYoYnVmK3JldCwgIkRDRSBzdGF0dXM6ICIpOworICAgICAgICBpZiAoc2VsZi0+c2V0dGluZ3MuZGNlICYgSVJDT01NX0NUUykKKyAgICAgICAgICAgICAgICByZXQgKz0gc3ByaW50ZihidWYrcmV0LCAiQ1RTfCIpOworICAgICAgICBpZiAoc2VsZi0+c2V0dGluZ3MuZGNlICYgSVJDT01NX0RTUikKKyAgICAgICAgICAgICAgICByZXQgKz0gc3ByaW50ZihidWYrcmV0LCAiRFNSfCIpOworICAgICAgICBpZiAoc2VsZi0+c2V0dGluZ3MuZGNlICYgSVJDT01NX0NEKQorICAgICAgICAgICAgICAgIHJldCArPSBzcHJpbnRmKGJ1ZityZXQsICJDRHwiKTsKKyAgICAgICAgaWYgKHNlbGYtPnNldHRpbmdzLmRjZSAmIElSQ09NTV9SSSkgCisgICAgICAgICAgICAgICAgcmV0ICs9IHNwcmludGYoYnVmK3JldCwgIlJJfCIpOworCWlmIChzZWxmLT5zZXR0aW5ncy5kY2UpCisJCXJldC0tOyAvKiByZW1vdmUgdGhlIGxhc3QgfCAqLworICAgICAgICByZXQgKz0gc3ByaW50ZihidWYrcmV0LCAiXG4iKTsKKworCXJldCArPSBzcHJpbnRmKGJ1ZityZXQsICJDb25maWd1cmF0aW9uOiAiKTsKKwlpZiAoIXNlbGYtPnNldHRpbmdzLm51bGxfbW9kZ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nVmLCBjaGFyICoqc3RhcnQsIG9mZl90IG9mZnNldCwgaW50IGxlbiwKKwkJCQlpbnQgKmVvZiwgdm9pZCAqdW51c2VkKQoreworCXN0cnVjdCBpcmNvbW1fdHR5X2NiICpzZWxmOworICAgICAgICBpbnQgY291bnQgPSAwLCBsOworICAgICAgICBvZmZfdCBiZWdpbiA9IDA7CisJdW5zaWduZWQgbG9uZyBmbGFnczsKKworCXNwaW5fbG9ja19pcnFzYXZlKCZpcmNvbW1fdHR5LT5oYl9zcGlubG9jaywgZmxhZ3MpOworCisJc2VsZiA9IChzdHJ1Y3QgaXJjb21tX3R0eV9jYiAqKSBoYXNoYmluX2dldF9maXJzdChpcmNvbW1fdHR5KTsKKwl3aGlsZSAoKHNlbGYgIT0gTlVMTCkgJiYgKGNvdW50IDwgNDAwMCkpIHsKKwkJaWYgKHNlbGYtPm1hZ2ljICE9IElSQ09NTV9UVFlfTUFHSUMpCisJCQlicmVhazsKKworICAgICAgICAgICAgICAgIGwgPSBpcmNvbW1fdHR5X2xpbmVfaW5mbyhzZWxmLCBidWYgKyBjb3VudCk7CisgICAgICAgICAgICAgICAgY291bnQgKz0gbDsKKyAgICAgICAgICAgICAgICBpZiAoY291bnQrYmVnaW4gPiBvZmZzZXQrbGVuKQorICAgICAgICAgICAgICAgICAgICAgICAgZ290byBkb25lOworICAgICAgICAgICAgICAgIGlmIChjb3VudCtiZWdpbiA8IG9mZnNldCkgeworICAgICAgICAgICAgICAgICAgICAgICAgYmVnaW4gKz0gY291bnQ7CisgICAgICAgICAgICAgICAgICAgICAgICBjb3VudCA9IDA7CisgICAgICAgICAgICAgICAgfQorCQkJCQorCQlzZWxmID0gKHN0cnVjdCBpcmNvbW1fdHR5X2NiICopIGhhc2hiaW5fZ2V0X25leHQoaXJjb21tX3R0eSk7CisgICAgICAgIH0KKyAgICAgICAgKmVvZiA9IDE7Citkb25lOgorCXNwaW5fdW5sb2NrX2lycXJlc3RvcmUoJmlyY29tbV90dHktPmhiX3NwaW5sb2NrLCBmbGFncyk7CisKKyAgICAgICAgaWYgKG9mZnNldCA+PSBjb3VudCtiZWdpbikKKyAgICAgICAgICAgICAgICByZXR1cm4gMDsKKyAgICAgICAgKnN0YXJ0ID0gYnVmICsgKG9mZnNldC1iZWdpbik7CisgICAgICAgIHJldHVybiAoKGxlbiA8IGJlZ2luK2NvdW50LW9mZnNldCkgPyBsZW4gOiBiZWdpbitjb3VudC1vZmZzZXQpOworfQorI2VuZGlmIC8qIENPTkZJR19QUk9DX0ZTICovCisKK01PRFVMRV9BVVRIT1IoIkRhZyBCcmF0dGxpIDxkYWdiQGNzLnVpdC5ubz4iKTsKK01PRFVMRV9ERVNDUklQVElPTigiSXJDT01NIHNlcmlhbCBUVFkgZHJpdmVyIik7CitNT0RVTEVfTElDRU5TRSgiR1BMIik7CitNT0RVTEVfQUxJQVNfQ0hBUkRFVl9NQUpPUihJUkNPTU1fVFRZX01BSk9SKTsKKworbW9kdWxlX2luaXQoaXJjb21tX3R0eV9pbml0KTsKK21vZHVsZV9leGl0KGlyY29tbV90dHlfY2xlYW51cCk7CmRpZmYgLS1naXQgYS9uZXQvaXJkYS9pcmNvbW0vaXJjb21tX3R0eV9hdHRhY2guYyBiL25ldC9pcmRhL2lyY29tbS9pcmNvbW1fdHR5X2F0dGFjaC5jCm5ldyBmaWxlIG1vZGUgMTAwNjQ0CmluZGV4IDAwMDAwMDAuLjk5ZjVlZGQKLS0tIC9kZXYvbnVsbAorKysgYi9uZXQvaXJkYS9pcmNvbW0vaXJjb21tX3R0eV9hdHRhY2guYwpAQCAtMCwwICsxLDEwMDYgQEAKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyAqICAgICAgICAgICAgICAgIAorICogRmlsZW5hbWU6ICAgICAgaXJjb21tX3R0eV9hdHRhY2guYworICogVmVyc2lvbjogICAgICAgCisgKiBEZXNjcmlwdGlvbjogICBDb2RlIGZvciBhdH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mluZGV4IDAwMDAwMDAuLmY4ZTZjYjAKLS0tIC9kZXYvbnVsbAorKysgYi9uZXQvaXJkYS9pcmxhbi9pcmxhbl9jbGllbnQuYwpAQCAtMCwwICsxLDU3NiBAQAorLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorICogICAgICAgICAgICAgICAgCisgKiBGaWxlbmFtZTogICAgICBpcmxhbl9jbGllbnQuYworICogVmVyc2lvbjogICAgICAgMC45CisgKiBEZXNjcmlwdGlvbjogICBJckRBIExBTiBBY2Nlc3MgUHJvdG9jb2wgKElyTEFOKSBDbGllbnQKKyAqIFN0YXR1czogICAgICAgIEV4cGVyaW1lbnRhbC4KKyAqIEF1dGhvcjogICAgICAgIERhZyBCcmF0dGxpIDxkYWdiQGNzLnVpdC5ubz4KKyAqIENyZWF0ZWQgYXQ6ICAgIFN1biBBdWcgMzEgMjA6MTQ6MzcgMTk5NworICogTW9kaWZpZWQgYXQ6ICAgVHVlIERlYyAxNCAxNTo0NzowMiAxOTk5CisgKiBNb2RpZmllZCBieTogICBEYWcgQnJhdHRsaSA8ZGFnYkBjcy51aXQubm8+CisgKiBTb3VyY2VzOiAgICAgICBza2VsZXRvbi5jIGJ5IERvbmFsZCBCZWNrZXIgPGJlY2tlckBDRVNESVMuZ3NmYy5uYXNhLmdvdj4KKyAqICAgICAgICAgICAgICAgIHNsaXAuYyBieSBMYXVyZW5jZSBDdWxoYW5lLCA8bG96QGhvbG1lcy5kZW1vbi5jby51az4KKyAqICAgICAgICAgICAgICAgICAgICAgICAgICBGcmVkIE4uIHZhbiBLZW1wZW4sIDx3YWx0amVAdXdhbHQubmwubXVnbmV0Lm9yZz4KKyAqIAorICogICAgIENvcHlyaWdodCAoYykgMTk5OC0xOTk5IERhZyBCcmF0dGxpIDxkYWdiQGNzLnVpdC5ubz4sIAorICogICAgIEFsbCBSaWdodHMgUmVzZXJ2ZWQuCisgKiAgICAgCisgK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3N5bmMgKHNlbGYsIGV2ZW50LCBza2IsIGluZm8pCisgKgorICogICAgCisgKgorICovCitzdGF0aWMgaW50IGlybGFuX2NsaWVudF9zdGF0ZV9zeW5jKHN0cnVjdCBpcmxhbl9jYiAqc2VsZiwgSVJMQU5fRVZFTlQgZXZlbnQsIAorCQkJCSAgIHN0cnVjdCBza19idWZmICpza2IpIAoreworCUlSREFfREVCVUcoMiwgIiVzKClcbiIsIF9fRlVOQ1RJT05fXyApOworCQorCWlmIChza2IpCisJCWRldl9rZnJlZV9za2Ioc2tiKTsKKwkKKwlyZXR1cm4gMDsKK30KKworCisKKworCisKKworCisKKworCisKKwpkaWZmIC0tZ2l0IGEvbmV0L2lyZGEvaXJsYW4vaXJsYW5fY29tbW9uLmMgYi9uZXQvaXJkYS9pcmxhbi9pcmxhbl9jb21tb24uYwpuZXcgZmlsZSBtb2RlIDEwMDY0NAppbmRleCAwMDAwMDAwLi42NTdkMTIyCi0tLSAvZGV2L251bGwKKysrIGIvbmV0L2lyZGEvaXJsYW4vaXJsYW5fY29tbW9uLmMKQEAgLTAsMCArMSwxMjAwIEBACisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgKiAgICAgICAgICAgICAgICAKKyAqIEZpbGVuYW1lOiAgICAgIGlybGFuX2NvbW1vbi5jCisgKiBWZXJzaW9uOiAgICAgICAwLjkKKyAqIERlc2NyaXB0aW9uOiAgIElyREEgTEFOIEFjY2VzcyBQcm90b2NvbCBJbXBsZW1lbnRhdGlvbgorICogU3RhdHVzOiAgICAgICAgRXhwZXJpbWVudGFsLgorICogQXV0aG9yOiAgICAgICAgRGFnIEJyYXR0bGkgPGRhZ2JAY3MudWl0Lm5vPgorICogQ3JlYXRlZCBhdDogICAgU3VuIEF1ZyAzMSAyMDoxNDozNyAxOTk3CisgKiBNb2RpZmllZCBhdDogICBTdW4gRGVjIDI2IDIxOjUzOjEwIDE5OTkKKyAq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QvaXJkYS9pcmxhbi9pcmxhbl9wcm92aWRlci5jCkBAIC0wLDAgKzEsNDEzIEBACisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgKiAgICAgICAgICAgICAgICAKKyAqIEZpbGVuYW1lOiAgICAgIGlybGFuX3Byb3ZpZGVyLmMKKyAqIFZlcnNpb246ICAgICAgIDAuOQorICogRGVzY3JpcHRpb246ICAgSXJEQSBMQU4gQWNjZXNzIFByb3RvY29sIEltcGxlbWVudGF0aW9uCisgKiBTdGF0dXM6ICAgICAgICBFeHBlcmltZW50YWwuCisgKiBBdXRob3I6ICAgICAgICBEYWcgQnJhdHRsaSA8ZGFnYkBjcy51aXQubm8+CisgKiBDcmVhdGVkIGF0OiAgICBTdW4gQXVnIDMxIDIwOjE0OjM3IDE5OTcKKyAqIE1vZGlmaWVkIGF0OiAgIFNhdCBPY3QgMzAgMTI6NTI6MTAgMTk5OQorICogTW9kaWZpZWQgYnk6ICAgRGFnIEJyYXR0bGkgPGRhZ2JAY3MudWl0Lm5vPgorICogU291cmNlczogICAgICAgc2tlbGV0b24uYyBieSBEb25hbGQgQmVja2VyIDxiZWNrZXJAQ0VTRElTLmdzZmMubmFzYS5nb3Y+CisgKiAgICAgICAgICAgICAgICBzbGlwLmMgYnkgTGF1cmVuY2UgQ3VsaGFuZSwgICA8bG96QGhvbG1lcy5kZW1vbi5jby51az4KKyAqICAgICAgICAgICAgICAgICAgICAgICAgICBGcmVkIE4uIHZhbiBLZW1wZW4sIDx3YWx0amVAdXdhbHQubmwubXVnbmV0Lm9yZz4KKyAqIAorICogICAgIENvcHlyaWdodCAoYykgMTk5OC0xOTk5IERhZyBCcmF0dGxpIDxkYWdiQGNzLnVpdC5ubz4sIAorICogICAgIEFsbCBSaWdodHMgUmVzZXJ2ZWQuCisgKiAgICAgCisgKiAgICAgVGhpcyBwcm9ncmFtIGlzIGZyZWUgc29mdHdhcmU7IHlv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50LmMKbmV3IGZpbGUgbW9kZSAxMDA2NDQKaW5kZXggMDAwMDAwMC4uMWNkODlmNQotLS0gL2Rldi9udWxsCisrKyBiL25ldC9pcmRhL2lybGFwX2V2ZW50LmMKQEAgLTAsMCArMSwyMzM0IEBACisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgKgorICogRmlsZW5hbWU6ICAgICAgaXJsYXBfZXZlbnQuYworICogVmVyc2lvbjogICAgICAgMC45CisgKiBEZXNjcmlwdGlvbjogICBJckxBUCBzdGF0ZSBtYWNoaW5lIGltcGxlbWVudGF0aW9uCisgKiBTdGF0dXM6ICAgICAgICBFeHBlcmltZW50YWwuCisgKiBBdXRob3I6ICAgICAgICBEYWcgQnJhdHRsaSA8ZGFnQGJyYXR0bGkubmV0PgorICogQ3JlYXRlZCBhdDogICAgU2F0IEF1ZyAxNiAwMDo1OToyOSAxOTk3CisgKiBNb2RpZmllZCBhdDogICBTYXQgRGVjIDI1IDIxOjA3OjU3IDE5OTkKKyAqIE1vZGlmaWVkIGJ5OiAgIERhZyBCcmF0dGxpIDxkYWdAYnJhdHRsaS5uZXQ+CisgKgorICogICAgIENvcHlyaWdodCAoYykgMTk5OC0yMDAwIERhZyBCcmF0dGxpIDxkYWdAYnJhdHRsaS5uZXQ+LAorICogICAgIENvcHlyaWdodCAoYykgMTk5OCAgICAgIFRob21hcyBEYXZpcyA8cmF0YmVydEByYWRpa3MubmV0PgorICogICAgIEFsbCBSaWdodHMgUmVzZXJ2ZWQuCisgKiAgICAgQ29weXJpZ2h0IChjKSAyMDAwLTIwMDMgSmVhbiBUb3VycmlsaGVzIDxqdEBocGwuaHAuY29tPgorICoKKyAqICAgICBUaGlzIHByb2dyYW0gaXMgZnJlZSBzb2Z0d2FyZTsgeW91IGNhbiByZWRpc3RyaWJ1dGUgaXQgYW5kL29yCisgKiAgICAgbW9kaWZ5IGl0IHVuZGVyIHRoZSB0ZX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pKytdID0gU19BTlk7CisKKwlzZXJ2aWNlW2ldID0gU19FTkQ7CisKKwlyZXR1cm4gc2VydmljZTsKK30KKyNlbmRpZgorCitzdGF0aWMgY29uc3QgX191MTYgc2VydmljZV9oaW50X21hcHBpbmdbU19FTkRdWzJdID0geworCXsgSElOVF9QTlAsCQkwIH0sCQkJLyogU19QTlAgKi8KKwl7IEhJTlRfUERBLAkJMCB9LAkJCS8qIFNfUERBICovCisJeyBISU5UX0NPTVBVVEVSLAkwIH0sCQkJLyogU19DT01QVVRFUiAqLworCXsgSElOVF9QUklOVEVSLAkJMCB9LAkJCS8qIFNfUFJJTlRFUiAqLworCXsgSElOVF9NT0RFTSwJCTAgfSwJCQkvKiBTX01PREVNICovCisJeyBISU5UX0ZBWCwJCTAgfSwJCQkvKiBTX0ZBWCAqLworCXsgSElOVF9MQU4sCQkwIH0sCQkJLyogU19MQU4gKi8KKwl7IEhJTlRfRVhURU5TSU9OLAlISU5UX1RFTEVQSE9OWSB9LAkvKiBTX1RFTEVQSE9OWSAqLworCXsgSElOVF9FWFRFTlNJT04sCUhJTlRfQ09NTSB9LAkJLyogU19DT01NICovCisJeyBISU5UX0VYVEVOU0lPTiwJSElOVF9PQkVYIH0sCQkvKiBTX09CRVggKi8KKwl7IDB4RkYsCQkJMHhGRiB9LAkJCS8qIFNfQU5ZICovCit9OworCisvKgorICogRnVuY3Rpb24gaXJsbXBfc2VydmljZV90b19oaW50IChzZXJ2aWNlKQorICoKKyAqICAgIENvbnZlcnRzIGEgc2VydmljZSB0eXBlLCB0byBhIGhpbnQgYml0CisgKgorICogICAgUmV0dXJuczogYSAxNiBiaXQgaGludCB2YWx1ZSwgd2l0aCB0aGUgc2VydmljZSBiaXQgc2V0CisgKi8KK19fdTE2IGlybG1wX3NlcnZpY2VfdG9faGludChpbnQgc2VydmljZSkKK3sKKwlfX3UxNl9ob3N0X29yZGVyIGhpbnQ7CisKKwloaW50LmJ5dGVbMF0gPSBzZXJ2aWNlX2hpbnRfbW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XNoYmluX2dldF9maXJzdChsc2FwX2hhc2hiaW4pOworCisJd2hpbGUgKE5VTEwgIT0gaGFzaGJpbl9maW5kX25leHQobHNhcF9oYXNoYmluLAorCQkJCQkgKGxvbmcpIGxzYXAsCisJCQkJCSBOVUxMLAorCQkJCQkgKHZvaWQgKikgJmxzYXBfbmV4dCkgKSB7CisJCWlybG1wX2RvX2xzYXBfZXZlbnQobHNhcCwgZXZlbnQsIE5VTEwpOworCQlsc2FwID0gbHNhcF9uZXh0OworCX0KK30KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorICoKKyAqICAgIExBUCBjb25uZWN0aW9uIGNvbnRyb2wgc3RhdGVzCisgKgorICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworCisvKgorICogRnVuY3Rpb24gaXJsbXBfc3RhdGVfc3RhbmRieSAoZXZlbnQsIHNrYiwgaW5mbykKKyAqCisgKiAgICBTVEFOREJZLCBUaGUgSXJMQVAgY29ubmVjdGlvbiBkb2VzIG5vdCBleGlzdC4KKyAqCisgKi8KK3N0YXRpYyB2b2lkIGlybG1wX3N0YXRlX3N0YW5kYnkoc3RydWN0IGxhcF9jYiAqc2VsZiwgSVJMTVBfRVZFTlQgZXZlbnQsCisJCQkJc3RydWN0IHNrX2J1ZmYgKnNrYikKK3sKKwlJUkRBX0RFQlVHKDQsICIlcygpXG4iLCBfX0ZVTkNUSU9OX18pOworCUlSREFfQVNTRVJUKHNlbGYtPmlybGFwICE9IE5VTEwsIHJldHVybjspOworCisJc3dpdGNoIChldmVudCkgeworCWNhc2UgTE1fTEFQX0RJU0NPVkVSWV9SRVFVRVNUOgorCQkvKiBpcmxtcF9uZXh0X3N0YXRpb25fc3RhdGUoIExNUF9ESVNDT1ZFUik7ICovCisKKwkJaXJsYXBfZGlzY292ZXJ5X3JlcXVlc3Qoc2Vs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PC0lcygpIiBmb3JtYXQsIF9fRlVOQ1RJT05fXyAsICMjYXJncyk7fQorCisvKiBFeGl0IGEgZnVuY3Rpb24gd2l0aCBkZWJ1ZyAqLworI2RlZmluZSBEUkVUVVJOKHJldCwgZGJnLCBhcmdzLi4uKSBcCisJe0RFWElUKGRiZywgIjogIiBhcmdzKTtcCisJcmV0dXJuIHJldDsgfQorCisvKiBFeGl0IGEgZnVuY3Rpb24gb24gZmFpbGVkIGNvbmRpdGlvbiAqLworI2RlZmluZSBEQUJPUlQoY29uZCwgcmV0LCBkYmcsIGFyZ3MuLi4pIFwKKwl7aWYoY29uZCkge1wKKwkJREVSUk9SKGRiZywgYXJncyk7XAorCQlyZXR1cm4gcmV0OyB9fQorCisvKiBJbnZhbGlkIGFzc2VydGlvbiwgcHJpbnQgb3V0IGFuIGVycm9yIGFuZCBleGl0Li4uICovCisjZGVmaW5lIERBU1NFUlQoY29uZCwgcmV0LCBkYmcsIGFyZ3MuLi4pIFwKKwl7aWYoKERFQlVHX0FTU0VSVCkgJiYgIShjb25kKSkge1wKKwkJREVSUk9SKGRiZywgIkludmFsaWQgYXNzZXJ0aW9uOiAiIGFyZ3MpO1wKKwkJcmV0dXJuIHJldDsgfX0KKworLyoqKioqKioqKioqKioqKioqKioqKioqKiBDT05TVEFOVFMgJiBNQUNST1MgKioqKioqKioqKioqKioqKioqKioqKioqLworCisvKiBQYXJhbm9pYSAqLworI2RlZmluZSBJUk5FVF9NQUdJQwkweEIwMDc1NAorCisvKiBOdW1iZXIgb2YgY29udHJvbCBldmVudHMgaW4gdGhlIGNvbnRyb2wgY2hhbm5lbCBidWZmZXIuLi4gKi8KKyNkZWZpbmUgSVJORVRfTUFYX0VWRU5UUwk4CS8qIFNob3VsZCBiZSBtb3JlIHRoYW4gZW5vdWdoLi4uICovCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKiogVFlQRVMgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworCisvKgorICogVGhpcyBpc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ChzZWxmLT50c2FwICE9IE5VTEwsIC1FQlVTWSwgSVJEQV9TUl9FUlJPUiwgIkFscmVhZHkgYnVzeSAhXG4iKTsKKworICAvKiBJbml0aWFsaXplIElyVFRQIGNhbGxiYWNrcyB0byBiZSB1c2VkIGJ5IHRoZSBJckRBIHN0YWNrICovCisgIGlyZGFfbm90aWZ5X2luaXQoJm5vdGlmeSk7CisgIG5vdGlmeS5jb25uZWN0X2NvbmZpcm0JPSBpcm5ldF9jb25uZWN0X2NvbmZpcm07CisgIG5vdGlmeS5jb25uZWN0X2luZGljYXRpb24JPSBpcm5ldF9jb25uZWN0X2luZGljYXRpb247CisgIG5vdGlmeS5kaXNjb25uZWN0X2luZGljYXRpb24JPSBpcm5ldF9kaXNjb25uZWN0X2luZGljYXRpb247CisgIG5vdGlmeS5kYXRhX2luZGljYXRpb24JPSBpcm5ldF9kYXRhX2luZGljYXRpb247CisgIC8qbm90aWZ5LnVkYXRhX2luZGljYXRpb24JPSBOVUxMOyovCisgIG5vdGlmeS5mbG93X2luZGljYXRpb24JPSBpcm5ldF9mbG93X2luZGljYXRpb247CisgIG5vdGlmeS5zdGF0dXNfaW5kaWNhdGlvbgk9IGlybmV0X3N0YXR1c19pbmRpY2F0aW9uOworICBub3RpZnkuaW5zdGFuY2UJCT0gc2VsZjsKKyAgc3RybGNweShub3RpZnkubmFtZSwgSVJORVRfTk9USUZZX05BTUUsIHNpemVvZihub3RpZnkubmFtZSkpOworCisgIC8qIE9wZW4gYW4gSXJUVFAgaW5zdGFuY2UgKi8KKyAgc2VsZi0+dHNhcCA9IGlydHRwX29wZW5fdHNhcChMU0FQX0FOWSwgREVGQVVMVF9JTklUSUFMX0NSRURJVCwKKwkJCSAgICAgICAmbm90aWZ5KTsJCisgIERBQk9SVChzZWxmLT50c2FwID09IE5VTEwsIC1FTk9NRU0sCisJIElSREFfU1JfRVJST1IsICJVbmFibGUgdG8gYWxsb2NhdGUgVFNBUCAhXG4iKTsKKworICAvKiBSZW1lbWJl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fdTgJZHRzYXBfc2VsID0gMDsJCS8qIFRTQVAgd2UgYXJlIGxvb2tpbmcgZm9yICovCisKKyAgREVOVEVSKElSREFfU1JfVFJBQ0UsICIoc2VsZj0weCVwKVxuIiwgc2VsZik7CisKKyAgLyogQnkgZGVmYXVsdCwgbm8gZXJyb3IgKi8KKyAgc2VsZi0+ZXJybm8gPSAwOworCisgIC8qIENoZWNrIGlmIHJlcXVlc3Qgc3VjY2VlZGVkICovCisgIHN3aXRjaChyZXN1bHQpCisgICAgeworICAgICAgLyogU3RhbmRhcmQgZXJyb3JzIDogc2VydmljZSBub3QgYXZhaWxhYmxlICovCisgICAgY2FzZSBJQVNfQ0xBU1NfVU5LTk9XTjoKKyAgICBjYXNlIElBU19BVFRSSUJfVU5LTk9XTjoKKyAgICAgIERFQlVHKElSREFfU1JfSU5GTywgIklBUyBvYmplY3QgZG9lc24ndCBleGlzdCAhICglZClcbiIsIHJlc3VsdCk7CisgICAgICBzZWxmLT5lcnJubyA9IC1FQUREUk5PVEFWQUlMOworICAgICAgYnJlYWs7CisKKyAgICAgIC8qIE90aGVyIGVycm9ycywgbW9zdCBsaWtlbHkgSXJEQSBzdGFjayBmYWlsdXJlICovCisgICAgZGVmYXVsdCA6CisgICAgICBERUJVRyhJUkRBX1NSX0lORk8sICJJQVMgcXVlcnkgZmFpbGVkICEgKCVkKVxuIiwgcmVzdWx0KTsKKyAgICAgIHNlbGYtPmVycm5vID0gLUVIT1NUVU5SRUFDSDsKKyAgICAgIGJyZWFrOworCisgICAgICAvKiBTdWNjZXNzIDogd2UgZ290IHdoYXQgd2Ugd2FudGVkICovCisgICAgY2FzZSBJQVNfU1VDQ0VTUzoKKyAgICAgIGJyZWFrOworICAgIH0KKworICAvKiBDaGVjayB3aGF0IHdhcyByZXR1cm5lZCB0byB1cyAqLworICBpZih2YWx1ZSAhPSBOVUxMKQorICAgIHsKKyAgICAgIC8qIFdoYXQgdHlwZSBvZiBhcmd1bWVudCBoYXZlIHdlIGdvdCA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XZlbnQoTlVMTCwgSVJORVRfRElTQ09OTkVDVF9UTywKKwkJICAgICAgIHNlbGYtPnNhZGRyLCBzZWxmLT5kYWRkciwgc2VsZi0+cm5hbWUsIDApOworICAgIH0KKworICAvKiBQcmV2ZW50IHZhcmlvdXMgSXJEQSBjYWxsYmFja3MgZnJvbSBtZXNzaW5nIHVwIHRoaW5ncworICAgKiBOZWVkIHRvIGJlIGZpcnN0ICovCisgIGNsZWFyX2JpdCgwLCAmc2VsZi0+dHRwX2Nvbm5lY3QpOworCisgIC8qIFByZXZlbnQgaGlnaGVyIGxheWVyIGZyb20gYWNjZXNzaW5nIElyVFRQICovCisgIGNsZWFyX2JpdCgwLCAmc2VsZi0+dHRwX29wZW4pOworCisgIC8qIFVucmVnaXN0ZXIgd2l0aCBJckxNUCAqLworICBpcmxtcF91bnJlZ2lzdGVyX2NsaWVudChzZWxmLT5ja2V5KTsKKworICAvKiBVbnJlZ2lzdGVyIHdpdGggTE0tSUFTICovCisgIGlmKHNlbGYtPmlyaWFwKQorICAgIHsgCisgICAgICBpcmlhcF9jbG9zZShzZWxmLT5pcmlhcCk7CisgICAgICBzZWxmLT5pcmlhcCA9IE5VTEw7CisgICAgfQorCisgIC8qIENsZWFudXAgZXZlbnR1YWwgZGlzY292ZXJpZXMgZnJvbSBjb25uZWN0aW9uIGF0dGVtcHQgb3IgY29udHJvbCBjaGFubmVsICovCisgIGlmKHNlbGYtPmRpc2NvdmVyaWVzICE9IE5VTEwpCisgICAgeworICAgICAgLyogQ2xlYW51cCBvdXIgY29weSBvZiB0aGUgZGlzY292ZXJ5IGxvZyAqLworICAgICAga2ZyZWUoc2VsZi0+ZGlzY292ZXJpZXMpOworICAgICAgc2VsZi0+ZGlzY292ZXJpZXMgPSBOVUxMOworICAgIH0KKworICAvKiBDbG9zZSBvdXIgSXJUVFAgY29ubmVjdGlvbiAqLworICBpZihzZWxmLT50c2FwKQorICAgIHsKKyAgICAgIERFQlVHKElSREFfU09DS19JTkZPLCAiQ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iBmbG93IGNvbnRyb2wgcmVxdWVzdC4uLiAqLworICAgICAgcmV0dXJuIC1FTk9NRU07CisgICAgfQorCisgIC8qIHN0cmlwIGFkZHJlc3MvY29udHJvbCBmaWVsZCBpZiBwcmVzZW50ICovCisgIHAgPSBza2ItPmRhdGE7CisgIGlmKChwWzBdID09IFBQUF9BTExTVEFUSU9OUykgJiYgKHBbMV0gPT0gUFBQX1VJKSkKKyAgICB7CisgICAgICAvKiBjaG9wIG9mZiBhZGRyZXNzL2NvbnRyb2wgKi8KKyAgICAgIGlmKHNrYi0+bGVuIDwgMykKKwlnb3RvIGVycl9leGl0OworICAgICAgcCA9IHNrYl9wdWxsKHNrYiwgMik7CisgICAgfQorCisgIC8qIGRlY29tcHJlc3MgcHJvdG9jb2wgZmllbGQgaWYgY29tcHJlc3NlZCAqLworICBpZihwWzBdICYgMSkKKyAgICB7CisgICAgICAvKiBwcm90b2NvbCBpcyBjb21wcmVzc2VkICovCisgICAgICBza2JfcHVzaChza2IsIDEpWzBdID0gMDsKKyAgICB9CisgIGVsc2UKKyAgICBpZihza2ItPmxlbiA8IDIpCisgICAgICBnb3RvIGVycl9leGl0OworCisgIC8qIHBhc3MgdG8gZ2VuZXJpYyBwcHAgbGF5ZXIgKi8KKyAgLyogTm90ZSA6IGhvdyBkbyBJIGtub3cgaWYgcHBwIGNhbiBhY2NlcHQgb3Igbm90IHRoZSBwYWNrZXQgPyBUaGlzIGlzCisgICAqIGVzc2VudGlhbCBpZiBJIHdhbnQgdG8gbWFuYWdlIGZsb3cgY29udHJvbCBzbW9vdGhseS4uLiAqLworICBwcHBfaW5wdXQoJmFwLT5jaGFuLCBza2IpOworCisgIERFWElUKElSREFfVENCX1RSQUNFLCAiXG4iKTsKKyAgcmV0dXJuIDA7CisKKyBlcnJfZXhpdDoKKyAgREVSUk9SKElSREFfQ0JfRVJST1IsICJQYWNrZXQgdG9vIHNtYWxsLCBkcm9wcGluZy4uLlxuIik7CisgIGtmcmVlX3NrYihza2IpO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lbC4uLlxuIik7CisJfQorICAgICAgZWxzZQorCXsKKwkgIC8qIEluIHRoZW9yeSwgc2hvdWxkIGJlIE5fVFRZICovCisJICBERUJVRyhGU19JTkZPLCAiRXhpdGluZyBQUFAgZGlzY2lwbGluZS5cbiIpOworCSAgLyogRGlzY29ubmVjdCBmcm9tIHRoZSBnZW5lcmljIFBQUCBsYXllciAqLworCSAgaWYoYXAtPnBwcF9vcGVuKQorCSAgICB7CisJICAgICAgYXAtPnBwcF9vcGVuID0gMDsKKwkgICAgICBwcHBfdW5yZWdpc3Rlcl9jaGFubmVsKCZhcC0+Y2hhbik7CisJICAgIH0KKwkgIGVsc2UKKwkgICAgREVSUk9SKEZTX0VSUk9SLCAiQ2hhbm5lbCBub3QgcmVnaXN0ZXJlZCAhXG4iKTsKKwkgIGVyciA9IDA7CisJfQorICAgICAgYnJlYWs7CisKKyAgICAgIC8qIFF1ZXJ5IFBQUCBjaGFubmVsIGFuZCB1bml0IG51bWJlciAqLworICAgIGNhc2UgUFBQSU9DR0NIQU46CisgICAgICBpZighYXAtPnBwcF9vcGVuKQorCWJyZWFrOworICAgICAgaWYocHV0X3VzZXIocHBwX2NoYW5uZWxfaW5kZXgoJmFwLT5jaGFuKSwgKGludCBfX3VzZXIgKilhcmdwKSkKKwlicmVhazsKKyAgICAgIERFQlVHKEZTX0lORk8sICJRdWVyeSBjaGFubmVsLlxuIik7CisgICAgICBlcnIgPSAwOworICAgICAgYnJlYWs7CisgICAgY2FzZSBQUFBJT0NHVU5JVDoKKyAgICAgIGlmKCFhcC0+cHBwX29wZW4pCisJYnJlYWs7CisgICAgICBpZihwdXRfdXNlcihwcHBfdW5pdF9udW1iZXIoJmFwLT5jaGFuKSwgKGludCBfX3VzZXIgKilhcmdwKSkKKwlicmVhazsKKyAgICAgIERFQlVHKEZTX0lORk8sICJRdWVyeSB1bml0IG51bWJlci5cbiIpOworICAgICAgZXJyID0gMDsKKyAgICAgIGJyZWFrOworCisgICAgICAvKiBBbGwgdGh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MDsKKyAgICAgIGJyZWFrOworICAgICAgLyogU2V0IHRlcm1pb3MgKi8KKyAgICBjYXNlIFRDU0VUU0Y6CisgICAgICBERUJVRyhGU19JTkZPLCAiU2V0IHRlcm1pb3MuXG4iKTsKKyAgICAgIGlmKHVzZXJfdGVybWlvc190b19rZXJuZWxfdGVybWlvcygmYXAtPnRlcm1pb3MsIChzdHJ1Y3QgdGVybWlvcyBfX3VzZXIgKilhcmdwKSkKKwlicmVhazsKKyAgICAgIGVyciA9IDA7CisgICAgICBicmVhazsKKworICAgICAgLyogU2V0IERUUi9SVFMgKi8KKyAgICBjYXNlIFRJT0NNQklTOiAKKyAgICBjYXNlIFRJT0NNQklDOgorICAgICAgLyogU2V0IGV4Y2x1c2l2ZS9ub24tZXhjbHVzaXZlIG1vZGUgKi8KKyAgICBjYXNlIFRJT0NFWENMOgorICAgIGNhc2UgVElPQ05YQ0w6CisgICAgICBERUJVRyhGU19JTkZPLCAiVFRZIGNvbXBhdGliaWxpdHkuXG4iKTsKKyAgICAgIGVyciA9IDA7CisgICAgICBicmVhazsKKworICAgIGNhc2UgVENHRVRBOgorICAgICAgREVCVUcoRlNfSU5GTywgIlRDR0VUQVxuIik7CisgICAgICBicmVhazsKKworICAgIGNhc2UgVENGTFNIOgorICAgICAgREVCVUcoRlNfSU5GTywgIlRDRkxTSFxuIik7CisgICAgICAvKiBOb3RlIDogdGhpcyB3aWxsIGZsdXNoIGJ1ZmZlcnMgaW4gUFBQLCBzbyBpdCAqbXVzdCogYmUgZG9uZQorICAgICAgICogV2Ugc2hvdWxkIGFsc28gd29ycnkgdGhhdCB3ZSBkb24ndCBhY2NlcHQganVuayBoZXJlIGFuZCB0aGF0CisgICAgICAgKiB3ZSBnZXQgcmlkIG9mIG91ciBvd24gYnVmZmVycyAqLworI2lmZGVmIEZMVVNIX1RPX1BQUAorICAgICAgcHBwX291dHB1dF93YWtldXAoJmFwLT5jaGFuKTsKKyNlbmRpZiAvKiBGTFVTSF9UT19QUFAgKi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mZsYWdzID0gdmFsICYgflNDX1JDVl9CSVRTOworICAgICAgYXAtPnJiaXRzID0gdmFsICYgU0NfUkNWX0JJVFM7CisgICAgICBlcnIgPSAwOworICAgICAgYnJlYWs7CisKKyAgICAgIC8qIEFzeW5jIG1hcCBzdHVmZiAtIGFsbCBkdW1teSB0byBwbGVhc2UgcHBwZCAqLworICAgIGNhc2UgUFBQSU9DR0FTWU5DTUFQOgorICAgICAgaWYocHV0X3VzZXIoYXAtPnhhY2NtWzBdLCAodTMyIF9fdXNlciAqKSBhcmdwKSkKKwlicmVhazsKKyAgICAgIGVyciA9IDA7CisgICAgICBicmVhazsKKyAgICBjYXNlIFBQUElPQ1NBU1lOQ01BUDoKKyAgICAgIGlmKGdldF91c2VyKGFwLT54YWNjbVswXSwgKHUzMiBfX3VzZXIgKikgYXJncCkpCisJYnJlYWs7CisgICAgICBlcnIgPSAwOworICAgICAgYnJlYWs7CisgICAgY2FzZSBQUFBJT0NHUkFTWU5DTUFQOgorICAgICAgaWYocHV0X3VzZXIoYXAtPnJhY2NtLCAodTMyIF9fdXNlciAqKSBhcmdwKSkKKwlicmVhazsKKyAgICAgIGVyciA9IDA7CisgICAgICBicmVhazsKKyAgICBjYXNlIFBQUElPQ1NSQVNZTkNNQVA6CisgICAgICBpZihnZXRfdXNlcihhcC0+cmFjY20sICh1MzIgX191c2VyICopIGFyZ3ApKQorCWJyZWFrOworICAgICAgZXJyID0gMDsKKyAgICAgIGJyZWFrOworICAgIGNhc2UgUFBQSU9DR1hBU1lOQ01BUDoKKyAgICAgIGlmKGNvcHlfdG9fdXNlcihhcmdwLCBhcC0+eGFjY20sIHNpemVvZihhcC0+eGFjY20pKSkKKwlicmVhazsKKyAgICAgIGVyciA9IDA7CisgICAgICBicmVhazsKKyAgICBjYXNlIFBQUElPQ1NYQVNZTkNNQVA6CisgICAgICBpZihjb3B5X2Zyb21fdXNlcihhY2NtLCBhcmdwLCBzaXplb2YoYWNjbSkpKQorCWJyZWFrOworICAgICAgYWNjbVsyXSAmPSB+MHg0MDAwMDAwMFU7CQkvKiBjYW4ndCBlc2NhcGUgMHg1ZSAqLworICAgICAgYWNjbVszXSB8PSAweDYwMDAwMDAwVTsJCS8qIG11c3QgZXNjYXBlIDB4N2QsIDB4N2UgKi8KKyAgICAgIG1lbWNweShhcC0+eGFjY20sIGFjY20sIHNpemVvZihhcC0+eGFjY20pKTsKKyAgICAgIGVyciA9IDA7CisgICAgICBicmVhazsKKworICAgICAgLyogTWF4IFBQUCBmcmFtZSBzaXplICovCisgICAgY2FzZSBQUFBJT0NHTVJVOgorICAgICAgaWYocHV0X3VzZXIoYXAtPm1ydSwgKGludCBfX3VzZXIgKikgYXJncCkpCisJYnJlYWs7CisgICAgICBlcnIgPSAwOworICAgICAgYnJlYWs7CisgICAgY2FzZSBQUFBJT0NTTVJVOgorICAgICAgaWYoZ2V0X3VzZXIodmFsLCAoaW50IF9fdXNlciAqKSBhcmdwKSkKKwlicmVhazsKKyAgICAgIGlmKHZhbCA8IFBQUF9NUlUpCisJdmFsID0gUFBQX01SVTsKKyAgICAgIGFwLT5tcnUgPSB2YWw7CisgICAgICBlcnIgPSAwOworICAgICAgYnJlYWs7CisKKyAgICBkZWZhdWx0OgorICAgICAgREVCVUcoUFBQX0lORk8sICJVbnN1cHBvcnRlZCBpb2N0bCAoMHglWClcbiIsIGNtZCk7CisgICAgICBlcnIgPSAtRU5PSU9DVExDTUQ7CisgICAgfQorCisgIERFWElUKFBQUF9UUkFDRSwgIiAtIGVyciA9IDB4JVhcbiIsIGVycik7CisgIHJldHVybiBlcnI7Cit9CisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKiBJTklUSUFMSVNBVElPTiAqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKy8qCisgKiBNb2R1bGUgaW5pdGlhbGlzYXRpb24gYW5kIGFsbCB0aGF0IGphenouLi4KKyAqLworCisvKi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t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5oCkBAIC0wLDAgKzEsMTE5IEBACisvKgorICoJSXJORVQgcHJvdG9jb2wgbW9kdWxlIDogU3luY2hyb25vdXMgUFBQIG92ZXIgYW4gSXJEQSBzb2NrZXQuCisgKgorICoJCUplYW4gSUkgLSBIUEwgYDAwIC0gPGp0QGhwbC5ocC5jb20+CisgKgorICogVGhpcyBmaWxlIGNvbnRhaW5zIGFsbCBkZWZpbml0aW9ucyBhbmQgZGVjbGFyYXRpb25zIG5lY2Vzc2FyeSBmb3IgdGhlCisgKiBQUFAgcGFydCBvZiB0aGUgSXJORVQgbW9kdWxlLgorICogVGhpcyBmaWxlIGlzIGEgcHJpdmF0ZSBoZWFkZXIsIHNvIG90aGVyIG1vZHVsZXMgZG9uJ3Qgd2FudCB0byBrbm93CisgKiB3aGF0J3MgaW4gdGhlcmUuLi4KKyAqLworCisjaWZuZGVmIElSTkVUX1BQUF9ICisjZGVmaW5lIElSTkVUX1BQUF9ICisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKiBJTkNMVURFUyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKworI2luY2x1ZGUgImlybmV0LmgiCQkvKiBNb2R1bGUgZ2xvYmFsIGluY2x1ZGUgKi8KKworLyoqKioqKioqKioqKioqKioqKioqKioqKiBDT05TVEFOVFMgJiBNQUNST1MgKioqKioqKioqKioqKioqKioqKioqKioqLworCisvKiAvZGV2L2lybmV0IGZpbGUgY29uc3RhbnRzICovCisjZGVmaW5lIElSTkVUX01BSk9SCTEwCS8qIE1pc2MgcmFuZ2UgKi8KKyNkZWZpbmUgSVJORVRfTUlOT1IJMTg3CS8qIE9mZmljaWFsIGFsbG9jYXRpb24gKi8KKworLyogSXJORVQgY29udHJvbCBjaGFubmVsIHN0dWZmICovCisjZGVmaW5lIElSTkVUX01BWF9DT01NQU5ECTI1NgkvKiBNYXggbGVuZ3RoIG9mIGEgY29tbWFuZCBsaW5lICovCisKKy8qIFBQUCBoYXJkY29yZSBzdHVmZiAqLwor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RhX3Byb2NfdW5yZWdpc3RlciAodm9pZCkKKyAqCisgKiAgICBVbnJlZ2lzdGVyIGlyZGEgZW50cnkgaW4gL3Byb2MgZmlsZSBzeXN0ZW0KKyAqCisgKi8KK3ZvaWQgX19leGl0IGlyZGFfcHJvY191bnJlZ2lzdGVyKHZvaWQpIAoreworCWludCBpOworCisgICAgICAgIGlmIChwcm9jX2lyZGEpIHsKKyAgICAgICAgICAgICAgICBmb3IgKGk9MDsgaTxBUlJBWV9TSVpFKGlyZGFfZGlycyk7IGkrKykKKyAgICAgICAgICAgICAgICAgICAgICAgIHJlbW92ZV9wcm9jX2VudHJ5KGlyZGFfZGlyc1tpXS5uYW1lLCBwcm9jX2lyZGEpOworCisgICAgICAgICAgICAgICAgcmVtb3ZlX3Byb2NfZW50cnkoImlyZGEiLCBwcm9jX25ldCk7CisgICAgICAgICAgICAgICAgcHJvY19pcmRhID0gTlVMTDsKKyAgICAgICAgfQorfQorCisKZGlmZiAtLWdpdCBhL25ldC9pcmRhL2lycXVldWUuYyBiL25ldC9pcmRhL2lycXVldWUuYwpuZXcgZmlsZSBtb2RlIDEwMDY0NAppbmRleCAwMDAwMDAwLi5iMGRkM2VhCi0tLSAvZGV2L251bGwKKysrIGIvbmV0L2lyZGEvaXJxdWV1ZS5jCkBAIC0wLDAgKzEsOTE1IEBACisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgKiAgICAgICAgICAgICAgICAKKyAqIEZpbGVuYW1lOiAgICAgIGlycXVldWUuYworICogVmVyc2lvbjogICAgICAgMC4zCisgKiBEZXNjcmlwdGlvbjogICBHZW5lcmFsIHF1ZXVlIGltcGxlbWVudGF0aW9uCisgKiBTdGF0dXM6ICAgICAgICBFeHBlcmltZW50YWwuCisgKiBBdXRob3I6ICAgICAgICBEYWcgQnJhdHRsaSA8ZGFnYkBjcy51aXQubm8+CisgKiBDcmVhdGVkIGF0OiAgICBUdWU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nBma2V5X3RhYmxlX2xvY2spOworCQl9CisKKwkJX19zZXRfY3VycmVudF9zdGF0ZShUQVNLX1JVTk5JTkcpOworCQlyZW1vdmVfd2FpdF9xdWV1ZSgmcGZrZXlfdGFibGVfd2FpdCwgJndhaXQpOworCX0KK30KKworc3RhdGljIF9faW5saW5lX18gdm9pZCBwZmtleV90YWJsZV91bmdyYWIodm9pZCkKK3sKKwl3cml0ZV91bmxvY2tfYmgoJnBma2V5X3RhYmxlX2xvY2spOworCXdha2VfdXAoJnBma2V5X3RhYmxlX3dhaXQpOworfQorCitzdGF0aWMgX19pbmxpbmVfXyB2b2lkIHBma2V5X2xvY2tfdGFibGUodm9pZCkKK3sKKwkvKiByZWFkX2xvY2soKSBzeW5jaHJvbml6ZXMgdXMgdG8gcGZrZXlfdGFibGVfZ3JhYiAqLworCisJcmVhZF9sb2NrKCZwZmtleV90YWJsZV9sb2NrKTsKKwlhdG9taWNfaW5jKCZwZmtleV90YWJsZV91c2Vycyk7CisJcmVhZF91bmxvY2soJnBma2V5X3RhYmxlX2xvY2spOworfQorCitzdGF0aWMgX19pbmxpbmVfXyB2b2lkIHBma2V5X3VubG9ja190YWJsZSh2b2lkKQoreworCWlmIChhdG9taWNfZGVjX2FuZF90ZXN0KCZwZmtleV90YWJsZV91c2VycykpCisJCXdha2VfdXAoJnBma2V5X3RhYmxlX3dhaXQpOworfQorCisKK3N0YXRpYyBzdHJ1Y3QgcHJvdG9fb3BzIHBma2V5X29wczsKKworc3RhdGljIHZvaWQgcGZrZXlfaW5zZXJ0KHN0cnVjdCBzb2NrICpzaykKK3sKKwlwZmtleV90YWJsZV9ncmFiKCk7CisJc2tfYWRkX25vZGUoc2ssICZwZmtleV90YWJsZSk7CisJcGZrZXlfdGFibGVfdW5ncmFiKCk7Cit9CisKK3N0YXRpYyB2b2lkIHBma2V5X3JlbW92ZShzdHJ1Y3Qgc29jayAqc2spCit7CisJcGZrZXlfdGFibGVfZ3JhYigpOworCXNrX2RlbF9ub2RlX2luaXQoc2spOworCXBma2V5X3RhYmxlX3VuZ3JhYigpOworfQorCitzdGF0aWMgc3RydWN0IHByb3RvIGtleV9wcm90byA9IHsKKwkubmFtZQkgID0gIktFWSIsCisJLm93bmVyCSAgPSBUSElTX01PRFVMRSwKKwkub2JqX3NpemUgPSBzaXplb2Yoc3RydWN0IHBma2V5X3NvY2spLAorfTsKKworc3RhdGljIGludCBwZmtleV9jcmVhdGUoc3RydWN0IHNvY2tldCAqc29jaywgaW50IHByb3RvY29sKQoreworCXN0cnVjdCBzb2NrICpzazsKKwlpbnQgZXJyOworCisJaWYgKCFjYXBhYmxlKENBUF9ORVRfQURNSU4pKQorCQlyZXR1cm4gLUVQRVJNOworCWlmIChzb2NrLT50eXBlICE9IFNPQ0tfUkFXKQorCQlyZXR1cm4gLUVTT0NLVE5PU1VQUE9SVDsKKwlpZiAocHJvdG9jb2wgIT0gUEZfS0VZX1YyKQorCQlyZXR1cm4gLUVQUk9UT05PU1VQUE9SVDsKKworCWVyciA9IC1FTk9NRU07CisJc2sgPSBza19hbGxvYyhQRl9LRVksIEdGUF9LRVJORUwsICZrZXlfcHJvdG8sIDEpOworCWlmIChzayA9PSBOVUxMKQorCQlnb3RvIG91dDsKKwkKKwlzb2NrLT5vcHMgPSAmcGZrZXlfb3BzOworCXNvY2tfaW5pdF9kYXRhKHNvY2ssIHNrKTsKKworCXNrLT5za19mYW1pbHkgPSBQRl9LRVk7CisJc2stPnNrX2Rlc3RydWN0ID0gcGZrZXlfc29ja19kZXN0cnVjdDsKKworCWF0b21pY19pbmMoJnBma2V5X3NvY2tzX25yKTsKKworCXBma2V5X2luc2VydChzayk7CisKKwlyZXR1cm4gMDsKK291dDoKKwlyZXR1cm4gZXJyOworfQorCitzdGF0aWMgaW50IHBma2V5X3JlbGVhc2Uoc3RydWN0IHNvY2tldCAqc29jaykKK3sKKwlzdHJ1Y3Qgc29jayAqc2sgPSBzb2NrLT5zazsKKworCWlmICghc2spCisJCXJldHVybiAwOworCisJc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KTsKKworCXNwaW5fbG9ja19iaCgmYWNxc2VxX2xvY2spOworCXJlcyA9ICgrK2FjcXNlcSA/IDogKythY3FzZXEpOworCXNwaW5fdW5sb2NrX2JoKCZhY3FzZXFfbG9jayk7CisJcmV0dXJuIHJlczsKK30KKworc3RhdGljIGludCBwZmtleV9zZW5kX2FjcXVpcmUoc3RydWN0IHhmcm1fc3RhdGUgKngsIHN0cnVjdCB4ZnJtX3RtcGwgKnQsIHN0cnVjdCB4ZnJtX3BvbGljeSAqeHAsIGludCBkaXIpCit7CisJc3RydWN0IHNrX2J1ZmYgKnNrYjsKKwlzdHJ1Y3Qgc2FkYl9tc2cgKmhkcjsKKwlzdHJ1Y3Qgc2FkYl9hZGRyZXNzICphZGRyOworCXN0cnVjdCBzYWRiX3hfcG9saWN5ICpwb2w7CisJc3RydWN0IHNvY2thZGRyX2luICpzaW47CisjaWYgZGVmaW5lZChDT05GSUdfSVBWNikgfHwgZGVmaW5lZChDT05GSUdfSVBWNl9NT0RVTEUpCisJc3RydWN0IHNvY2thZGRyX2luNiAqc2luNjsKKyNlbmRpZgorCWludCBzb2NrYWRkcl9zaXplOworCWludCBzaXplOworCQorCXNvY2thZGRyX3NpemUgPSBwZmtleV9zb2NrYWRkcl9zaXplKHgtPnByb3BzLmZhbWlseSk7CisJaWYgKCFzb2NrYWRkcl9zaXplKQorCQlyZXR1cm4gLUVJTlZBTDsKKworCXNpemUgPSBzaXplb2Yoc3RydWN0IHNhZGJfbXNnKSArCisJCShzaXplb2Yoc3RydWN0IHNhZGJfYWRkcmVzcykgKiAyKSArCisJCShzb2NrYWRkcl9zaXplICogMikgKworCQlzaXplb2Yoc3RydWN0IHNhZGJfeF9wb2xpY3kpOworCQorCWlmICh4LT5pZC5wcm90byA9PSBJUFBST1RPX0FIKQorCQlzaXplICs9IGNvdW50X2FoX2NvbWJzKHQpOworCWVsc2UgaWYgKHgtPmlkLnByb3RvID09IElQUFJPVE9fRVNQKQorCQlzaXplICs9IGNvdW50X2V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JPQlUSElTX01PRFVMRSwKK307CisKKyNpZmRlZiBDT05GSUdfUFJPQ19GUworc3RhdGljIGludCBwZmtleV9yZWFkX3Byb2MoY2hhciAqYnVmZmVyLCBjaGFyICoqc3RhcnQsIG9mZl90IG9mZnNldCwKKwkJCSAgIGludCBsZW5ndGgsIGludCAqZW9mLCB2b2lkICpkYXRhKQoreworCW9mZl90IHBvcyA9IDA7CisJb2ZmX3QgYmVnaW4gPSAwOworCWludCBsZW4gPSAwOworCXN0cnVjdCBzb2NrICpzOworCXN0cnVjdCBobGlzdF9ub2RlICpub2RlOworCisJbGVuICs9IHNwcmludGYoYnVmZmVyLCJzayAgICAgICBSZWZDbnQgUm1lbSAgIFdtZW0gICBVc2VyICAgSW5vZGVcbiIpOworCisJcmVhZF9sb2NrKCZwZmtleV90YWJsZV9sb2NrKTsKKworCXNrX2Zvcl9lYWNoKHMsIG5vZGUsICZwZmtleV90YWJsZSkgeworCQlsZW4gKz0gc3ByaW50ZihidWZmZXIrbGVuLCIlcCAlLTZkICUtNnUgJS02dSAlLTZ1ICUtNmx1IiwKKwkJCSAgICAgICBzLAorCQkJICAgICAgIGF0b21pY19yZWFkKCZzLT5za19yZWZjbnQpLAorCQkJICAgICAgIGF0b21pY19yZWFkKCZzLT5za19ybWVtX2FsbG9jKSwKKwkJCSAgICAgICBhdG9taWNfcmVhZCgmcy0+c2tfd21lbV9hbGxvYyksCisJCQkgICAgICAgc29ja19pX3VpZChzKSwKKwkJCSAgICAgICBzb2NrX2lfaW5vKHMpCisJCQkgICAgICAgKTsKKworCQlidWZmZXJbbGVuKytdID0gJ1xuJzsKKwkJCisJCXBvcyA9IGJlZ2luICsgbGVuOworCQlpZiAocG9zIDwgb2Zmc2V0KSB7CisJCQlsZW4gPSAwOworCQkJYmVnaW4gPSBwb3M7CisJCX0KKwkJaWYocG9zID4gb2Zmc2V0ICsgbGVuZ3RoKQorCQkJZ290byBkb25lOworCX0KKwkqZW9mID0gMTsKKworZG9uZToKKwlyZWF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CXJldHVybiByYzsKK30KKworaW50IGxhcGJfZGF0YV9yZXF1ZXN0KHN0cnVjdCBuZXRfZGV2aWNlICpkZXYsIHN0cnVjdCBza19idWZmICpza2IpCit7CisJc3RydWN0IGxhcGJfY2IgKmxhcGIgPSBsYXBiX2RldnRvc3RydWN0KGRldik7CisJaW50IHJjID0gTEFQQl9CQURUT0tFTjsKKworCWlmICghbGFwYikKKwkJZ290byBvdXQ7CisKKwlyYyA9IExBUEJfTk9UQ09OTkVDVEVEOworCWlmIChsYXBiLT5zdGF0ZSAhPSBMQVBCX1NUQVRFXzMgJiYgbGFwYi0+c3RhdGUgIT0gTEFQQl9TVEFURV80KQorCQlnb3RvIG91dF9wdXQ7CisKKwlza2JfcXVldWVfdGFpbCgmbGFwYi0+d3JpdGVfcXVldWUsIHNrYik7CisJbGFwYl9raWNrKGxhcGIpOworCXJjID0gTEFQQl9PSzsKK291dF9wdXQ6CisJbGFwYl9wdXQobGFwYik7CitvdXQ6CisJcmV0dXJuIHJjOworfQorCitpbnQgbGFwYl9kYXRhX3JlY2VpdmVkKHN0cnVjdCBuZXRfZGV2aWNlICpkZXYsIHN0cnVjdCBza19idWZmICpza2IpCit7CisJc3RydWN0IGxhcGJfY2IgKmxhcGIgPSBsYXBiX2RldnRvc3RydWN0KGRldik7CisJaW50IHJjID0gTEFQQl9CQURUT0tFTjsKKworCWlmIChsYXBiKSB7CisJCWxhcGJfZGF0YV9pbnB1dChsYXBiLCBza2IpOworCQlsYXBiX3B1dChsYXBiKTsKKwkJcmMgPSBMQVBCX09LOworCX0KKworCXJldHVybiByYzsKK30KKwordm9pZCBsYXBiX2Nvbm5lY3RfY29uZmlybWF0aW9uKHN0cnVjdCBsYXBiX2NiICpsYXBiLCBpbnQgcmVhc29uKQoreworCWlmIChsYXBiLT5jYWxsYmFja3MuY29ubmVjdF9jb25maXJtYXRpb24pCisJCWxhcGItPmNhbGxiYWNrcy5jb25uZWN0X2NvbmZpcm1hdGlvbihsYXBiLT5kZXYs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ZyhjdXJyZW50KSkKKwkJCWJyZWFrOworCQlyYyA9IC1FQUdBSU47CisJCWlmICghdGltZW91dCkKKwkJCWJyZWFrOworCX0KKwlfX3NldF9jdXJyZW50X3N0YXRlKFRBU0tfUlVOTklORyk7CisJcmVtb3ZlX3dhaXRfcXVldWUoc2stPnNrX3NsZWVwLCAmd2FpdCk7CisJcmV0dXJuIHJjOworfQorCitzdGF0aWMgaW50IGxsY191aV93YWl0X2Zvcl9jb25uKHN0cnVjdCBzb2NrICpzaywgaW50IHRpbWVvdXQpCit7CisJREVDTEFSRV9XQUlUUVVFVUUod2FpdCwgY3VycmVudCk7CisJaW50IHJjOworCisJYWRkX3dhaXRfcXVldWVfZXhjbHVzaXZlKHNrLT5za19zbGVlcCwgJndhaXQpOworCWZvciAoOzspIHsKKwkJX19zZXRfY3VycmVudF9zdGF0ZShUQVNLX0lOVEVSUlVQVElCTEUpOworCQlyYyA9IC1FQUdBSU47CisJCWlmIChzay0+c2tfc3RhdGUgPT0gVENQX0NMT1NFKQorCQkJYnJlYWs7CisJCXJjID0gMDsKKwkJaWYgKHNrLT5za19zdGF0ZSAhPSBUQ1BfRVNUQUJMSVNIRUQpIHsKKwkJCXJlbGVhc2Vfc29jayhzayk7CisJCQl0aW1lb3V0ID0gc2NoZWR1bGVfdGltZW91dCh0aW1lb3V0KTsKKwkJCWxvY2tfc29jayhzayk7CisJCX0gZWxzZQorCQkJYnJlYWs7CisJCXJjID0gLUVSRVNUQVJUU1lTOworCQlpZiAoc2lnbmFsX3BlbmRpbmcoY3VycmVudCkpCisJCQlicmVhazsKKwkJcmMgPSAtRUFHQUlOOworCQlpZiAoIXRpbWVvdXQpCisJCQlicmVhazsKKwl9CisJX19zZXRfY3VycmVudF9zdGF0ZShUQVNLX1JVTk5JTkcpOworCXJlbW92ZV93YWl0X3F1ZXVlKHNrLT5za19zbGVlcCwgJndhaXQpOworCXJldHVybiByYzsKK30KKworc3RhdGljIGludCBsbGNfdWlfd2FpdF9mb3JfZG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gICAgICBMTENfSV9HRVRfTlMocGR1KSA9PSBsbGNfc2soc2spLT52UiA/IDAgOiAxOworfQorCitpbnQgbGxjX2Nvbm5fZXZfcnhfaV9yc3BfZmJpdF9zZXRfMF91bmV4cGRfbnMoc3RydWN0IHNvY2sgKnNrLAorCQkJCQkgICAgICBzdHJ1Y3Qgc2tfYnVmZiAqc2tiKQoreworCXN0cnVjdCBsbGNfcGR1X3NuICpwZHUgPSBsbGNfcGR1X3NuX2hkcihza2IpOworCXU4IHZyID0gbGxjX3NrKHNrKS0+dlI7CisJdTggbnMgPSBMTENfSV9HRVRfTlMocGR1KTsKKworCXJldHVybiBMTENfUERVX0lTX1JTUChwZHUpICYmIExMQ19QRFVfVFlQRV9JU19JKHBkdSkgJiYKKwkgICAgICAgTExDX0lfUEZfSVNfMChwZHUpICYmIG5zICE9IHZyICYmCisJICAgICAgICFsbGNfdXRpbF9uc19pbnNpZGVfcnhfd2luZG93KG5zLCB2ciwgbGxjX3NrKHNrKS0+cncpID8gMCA6IDE7Cit9CisKK2ludCBsbGNfY29ubl9ldl9yeF9pX3JzcF9mYml0X3NldF8xX3VuZXhwZF9ucyhzdHJ1Y3Qgc29jayAqc2ssCisJCQkJCSAgICAgIHN0cnVjdCBza19idWZmICpza2IpCit7CisJc3RydWN0IGxsY19wZHVfc24gKnBkdSA9IGxsY19wZHVfc25faGRyKHNrYik7CisJdTggdnIgPSBsbGNfc2soc2spLT52UjsKKwl1OCBucyA9IExMQ19JX0dFVF9OUyhwZHUpOworCisJcmV0dXJuIExMQ19QRFVfSVNfUlNQKHBkdSkgJiYgTExDX1BEVV9UWVBFX0lTX0kocGR1KSAmJgorCSAgICAgICBMTENfSV9QRl9JU18xKHBkdSkgJiYgbnMgIT0gdnIgJiYKKwkgICAgICAgIWxsY191dGlsX25zX2luc2lkZV9yeF93aW5kb3cobnMsIHZyLCBsbGNfc2soc2spLT5ydykgPyAwIDogMTsKK30KKworaW50IGxsY19jb25uX2V2X3J4X2lfcnNwX2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wkJCWJyZWFrOworfQorCitzdGF0aWMgaW50IGxsY19zdGF0aW9uX2FjX3N0YXJ0X2Fja190aW1lcihzdHJ1Y3Qgc2tfYnVmZiAqc2tiKQoreworCW1vZF90aW1lcigmbGxjX21haW5fc3RhdGlvbi5hY2tfdGltZXIsIGppZmZpZXMgKyBMTENfQUNLX1RJTUUgKiBIWik7CisJcmV0dXJuIDA7Cit9CisKK3N0YXRpYyBpbnQgbGxjX3N0YXRpb25fYWNfc2V0X3JldHJ5X2NudF8wKHN0cnVjdCBza19idWZmICpza2IpCit7CisJbGxjX21haW5fc3RhdGlvbi5yZXRyeV9jb3VudCA9IDA7CisJcmV0dXJuIDA7Cit9CisKK3N0YXRpYyBpbnQgbGxjX3N0YXRpb25fYWNfaW5jX3JldHJ5X2NudF9ieV8xKHN0cnVjdCBza19idWZmICpza2IpCit7CisJbGxjX21haW5fc3RhdGlvbi5yZXRyeV9jb3VudCsrOworCXJldHVybiAwOworfQorCitzdGF0aWMgaW50IGxsY19zdGF0aW9uX2FjX3NldF94aWRfcl9jbnRfMChzdHJ1Y3Qgc2tfYnVmZiAqc2tiKQoreworCWxsY19tYWluX3N0YXRpb24ueGlkX3JfY291bnQgPSAwOworCXJldHVybiAwOworfQorCitzdGF0aWMgaW50IGxsY19zdGF0aW9uX2FjX2luY194aWRfcl9jbnRfYnlfMShzdHJ1Y3Qgc2tfYnVmZiAqc2tiKQoreworCWxsY19tYWluX3N0YXRpb24ueGlkX3JfY291bnQrKzsKKwlyZXR1cm4gMDsKK30KKworc3RhdGljIGludCBsbGNfc3RhdGlvbl9hY19zZW5kX251bGxfZHNhcF94aWRfYyhzdHJ1Y3Qgc2tfYnVmZiAqc2tiKQoreworCWludCByYyA9IDE7CisJc3RydWN0IHNrX2J1ZmYgKm5za2IgPSBsbGNfYWxsb2NfZnJhbWUoKTsKKworCWlmICghbnNrYikKKwkJZ290byBvdXQ7CisJbGxjX3BkdV9oZWFkZXJfaW5pdChuc2tiLCBMTENfUERVX1R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VudCk7CisKKwkJYWRkX3dhaXRfcXVldWVfZXhjbHVzaXZlKCZubF90YWJsZV93YWl0LCAmd2FpdCk7CisJCWZvcig7OykgeworCQkJc2V0X2N1cnJlbnRfc3RhdGUoVEFTS19VTklOVEVSUlVQVElCTEUpOworCQkJaWYgKGF0b21pY19yZWFkKCZubF90YWJsZV91c2VycykgPT0gMCkKKwkJCQlicmVhazsKKwkJCXdyaXRlX3VubG9ja19iaCgmbmxfdGFibGVfbG9jayk7CisJCQlzY2hlZHVsZSgpOworCQkJd3JpdGVfbG9ja19iaCgmbmxfdGFibGVfbG9jayk7CisJCX0KKworCQlfX3NldF9jdXJyZW50X3N0YXRlKFRBU0tfUlVOTklORyk7CisJCXJlbW92ZV93YWl0X3F1ZXVlKCZubF90YWJsZV93YWl0LCAmd2FpdCk7CisJfQorfQorCitzdGF0aWMgX19pbmxpbmVfXyB2b2lkIG5ldGxpbmtfdGFibGVfdW5ncmFiKHZvaWQpCit7CisJd3JpdGVfdW5sb2NrX2JoKCZubF90YWJsZV9sb2NrKTsKKwl3YWtlX3VwKCZubF90YWJsZV93YWl0KTsKK30KKworc3RhdGljIF9faW5saW5lX18gdm9pZAorbmV0bGlua19sb2NrX3RhYmxlKHZvaWQpCit7CisJLyogcmVhZF9sb2NrKCkgc3luY2hyb25pemVzIHVzIHRvIG5ldGxpbmtfdGFibGVfZ3JhYiAqLworCisJcmVhZF9sb2NrKCZubF90YWJsZV9sb2NrKTsKKwlhdG9taWNfaW5jKCZubF90YWJsZV91c2Vycyk7CisJcmVhZF91bmxvY2soJm5sX3RhYmxlX2xvY2spOworfQorCitzdGF0aWMgX19pbmxpbmVfXyB2b2lkCituZXRsaW5rX3VubG9ja190YWJsZSh2b2lkKQoreworCWlmIChhdG9taWNfZGVjX2FuZF90ZXN0KCZubF90YWJsZV91c2VycykpCisJCXdha2VfdXAoJm5sX3RhYmxlX3dhaXQpOworfQorCitzdGF0aWMgX19pbmxpbmVfXyBzdHJ1Y3Qgc29jayAq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XN0cnVjdCBuZXRsaW5rX3NvY2sgKm5sazsKKworCXNvY2stPnN0YXRlID0gU1NfVU5DT05ORUNURUQ7CisKKwlpZiAoc29jay0+dHlwZSAhPSBTT0NLX1JBVyAmJiBzb2NrLT50eXBlICE9IFNPQ0tfREdSQU0pCisJCXJldHVybiAtRVNPQ0tUTk9TVVBQT1JUOworCisJaWYgKHByb3RvY29sPDAgfHwgcHJvdG9jb2wgPj0gTUFYX0xJTktTKQorCQlyZXR1cm4gLUVQUk9UT05PU1VQUE9SVDsKKworCXNvY2stPm9wcyA9ICZuZXRsaW5rX29wczsKKworCXNrID0gc2tfYWxsb2MoUEZfTkVUTElOSywgR0ZQX0tFUk5FTCwgJm5ldGxpbmtfcHJvdG8sIDEpOworCWlmICghc2spCisJCXJldHVybiAtRU5PTUVNOworCisJc29ja19pbml0X2RhdGEoc29jaywgc2spOworCisJbmxrID0gbmxrX3NrKHNrKTsKKworCXNwaW5fbG9ja19pbml0KCZubGstPmNiX2xvY2spOworCWluaXRfd2FpdHF1ZXVlX2hlYWQoJm5say0+d2FpdCk7CisJc2stPnNrX2Rlc3RydWN0ID0gbmV0bGlua19zb2NrX2Rlc3RydWN0OworCisJc2stPnNrX3Byb3RvY29sID0gcHJvdG9jb2w7CisJcmV0dXJuIDA7Cit9CisKK3N0YXRpYyBpbnQgbmV0bGlua19yZWxlYXNlKHN0cnVjdCBzb2NrZXQgKnNvY2spCit7CisJc3RydWN0IHNvY2sgKnNrID0gc29jay0+c2s7CisJc3RydWN0IG5ldGxpbmtfc29jayAqbmxrOworCisJaWYgKCFzaykKKwkJcmV0dXJuIDA7CisKKwluZXRsaW5rX3JlbW92ZShzayk7CisJbmxrID0gbmxrX3NrKHNrKTsKKworCXNwaW5fbG9jaygmbmxrLT5jYl9sb2NrKTsKKwlpZiAobmxrLT5jYikgeworCQlubGstPmNiLT5kb25lKG5say0+Y2IpOworCQluZXRsaW5rX2Rlc3Ryb3lfY2FsbGJhY2sobmxrLT5jYik7CisJC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aW50IGVycikKK3sKKwlzdHJ1Y3Qgc2tfYnVmZiAqc2tiOworCXN0cnVjdCBubG1zZ2hkciAqcmVwOworCXN0cnVjdCBubG1zZ2VyciAqZXJybXNnOworCWludCBzaXplOworCisJaWYgKGVyciA9PSAwKQorCQlzaXplID0gTkxNU0dfU1BBQ0Uoc2l6ZW9mKHN0cnVjdCBubG1zZ2VycikpOworCWVsc2UKKwkJc2l6ZSA9IE5MTVNHX1NQQUNFKDQgKyBOTE1TR19BTElHTihubGgtPm5sbXNnX2xlbikpOworCisJc2tiID0gYWxsb2Nfc2tiKHNpemUsIEdGUF9LRVJORUwpOworCWlmICghc2tiKSB7CisJCXN0cnVjdCBzb2NrICpzazsKKworCQlzayA9IG5ldGxpbmtfbG9va3VwKGluX3NrYi0+c2stPnNrX3Byb3RvY29sLAorCQkJCSAgICBORVRMSU5LX0NCKGluX3NrYikucGlkKTsKKwkJaWYgKHNrKSB7CisJCQlzay0+c2tfZXJyID0gRU5PQlVGUzsKKwkJCXNrLT5za19lcnJvcl9yZXBvcnQoc2spOworCQkJc29ja19wdXQoc2spOworCQl9CisJCXJldHVybjsKKwl9CisKKwlyZXAgPSBfX25sbXNnX3B1dChza2IsIE5FVExJTktfQ0IoaW5fc2tiKS5waWQsIG5saC0+bmxtc2dfc2VxLAorCQkJICBOTE1TR19FUlJPUiwgc2l6ZW9mKHN0cnVjdCBubG1zZ2VycikpOworCWVycm1zZyA9IE5MTVNHX0RBVEEocmVwKTsKKwllcnJtc2ctPmVycm9yID0gZXJyOworCW1lbWNweSgmZXJybXNnLT5tc2csIG5saCwgZXJyID8gbmxoLT5ubG1zZ19sZW4gOiBzaXplb2Yoc3RydWN0IG5sbXNnaGRyKSk7CisJbmV0bGlua191bmljYXN0KGluX3NrYi0+c2ssIHNrYiwgTkVUTElOS19DQihpbl9za2IpLnBpZCwgTVNHX0RPTlRXQUlUKTsKK30KKworCisjaWZkZWYgQ09ORklHX1BST0NfRlMKK3N0cnVjdCBubF9zZXFf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S19TRVFQQUNLRVQpCisJCXJldHVybiBOVUxMOworCisJaWYgKChzayA9IHNrX2FsbG9jKFBGX05FVFJPTSwgR0ZQX0FUT01JQywgb3NrLT5za19wcm90LCAxKSkgPT0gTlVMTCkKKwkJcmV0dXJuIE5VTEw7CisKKwluciA9IG5yX3NrKHNrKTsKKworCXNvY2tfaW5pdF9kYXRhKE5VTEwsIHNrKTsKKworCXNrLT5za190eXBlICAgICA9IG9zay0+c2tfdHlwZTsKKwlzay0+c2tfc29ja2V0ICAgPSBvc2stPnNrX3NvY2tldDsKKwlzay0+c2tfcHJpb3JpdHkgPSBvc2stPnNrX3ByaW9yaXR5OworCXNrLT5za19wcm90b2NvbCA9IG9zay0+c2tfcHJvdG9jb2w7CisJc2stPnNrX3JjdmJ1ZiAgID0gb3NrLT5za19yY3ZidWY7CisJc2stPnNrX3NuZGJ1ZiAgID0gb3NrLT5za19zbmRidWY7CisJc2stPnNrX3N0YXRlICAgID0gVENQX0VTVEFCTElTSEVEOworCXNrLT5za19zbGVlcCAgICA9IG9zay0+c2tfc2xlZXA7CisKKwlpZiAoc29ja19mbGFnKG9zaywgU09DS19aQVBQRUQpKQorCQlzb2NrX3NldF9mbGFnKHNrLCBTT0NLX1pBUFBFRCk7CisKKwlpZiAoc29ja19mbGFnKG9zaywgU09DS19EQkcpKQorCQlzb2NrX3NldF9mbGFnKHNrLCBTT0NLX0RCRyk7CisKKwlza2JfcXVldWVfaGVhZF9pbml0KCZuci0+YWNrX3F1ZXVlKTsKKwlza2JfcXVldWVfaGVhZF9pbml0KCZuci0+cmVzZXFfcXVldWUpOworCXNrYl9xdWV1ZV9oZWFkX2luaXQoJm5yLT5mcmFnX3F1ZXVlKTsKKworCW5yX2luaXRfdGltZXJzKHNrKTsKKworCW9uciA9IG5yX3NrKG9zayk7CisKKwluci0+dDEgICAgICA9IG9uci0+dDE7CisJbnItPnQyICAgICAgPSBvbnItPnQyOworCW5yLT5uMiAgICAgID0gb25yLT5uMjsKKwluci0+dDQgICAgICA9IG9uci0+dDQ7CisJbnItPmlkbGUgICAgPSBvbnItPmlkbGU7CisJbnItPndpbmRvdyAgPSBvbnItPndpbmRvdzsKKworCW5yLT5kZXZpY2UgID0gb25yLT5kZXZpY2U7CisJbnItPmJwcWV4dCAgPSBvbnItPmJwcWV4dDsKKworCXJldHVybiBzazsKK30KKworc3RhdGljIGludCBucl9yZWxlYXNlKHN0cnVjdCBzb2NrZXQgKnNvY2spCit7CisJc3RydWN0IHNvY2sgKnNrID0gc29jay0+c2s7CisJc3RydWN0IG5yX3NvY2sgKm5yOworCisJaWYgKHNrID09IE5VTEwpIHJldHVybiAwOworCisJc29ja19ob2xkKHNrKTsKKwlsb2NrX3NvY2soc2spOworCW5yID0gbnJfc2soc2spOworCisJc3dpdGNoIChuci0+c3RhdGUpIHsKKwljYXNlIE5SX1NUQVRFXzA6CisJY2FzZSBOUl9TVEFURV8xOgorCWNhc2UgTlJfU1RBVEVfMjoKKwkJbnJfZGlzY29ubmVjdChzaywgMCk7CisJCW5yX2Rlc3Ryb3lfc29ja2V0KHNrKTsKKwkJYnJlYWs7CisKKwljYXNlIE5SX1NUQVRFXzM6CisJCW5yX2NsZWFyX3F1ZXVlcyhzayk7CisJCW5yLT5uMmNvdW50ID0gMDsKKwkJbnJfd3JpdGVfaW50ZXJuYWwoc2ssIE5SX0RJU0NSRVEpOworCQlucl9zdGFydF90MXRpbWVyKHNrKTsKKwkJbnJfc3RvcF90MnRpbWVyKHNrKTsKKwkJbnJfc3RvcF90NHRpbWVyKHNrKTsKKwkJbnJfc3RvcF9pZGxldGltZXIoc2spOworCQluci0+c3RhdGUgICAgPSBOUl9TVEFURV8yOworCQlzay0+c2tfc3RhdGUgICAgPSBUQ1BfQ0xPU0U7CisJCXNrLT5za19zaHV0ZG93biB8PSBTRU5EX1NIVVRET1dOOworCQlzay0+c2tfc3RhdGVfY2hhbmdlKHNrKTsKKwkJc29ja19vcnBoYW4oc2spOworCQlzb2NrX3NldF9mbGFnKHNrL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3B1dChkZXYpOworCQkJCXJldHVybiAtRVBFUk07CisJCQl9CisJCQl1c2VyID0gc291cmNlOworCQl9CisKKwkJbnItPnVzZXJfYWRkciAgID0gKnVzZXI7CisJCW5yLT5zb3VyY2VfYWRkciA9ICpzb3VyY2U7CisJfQorCisJbnItPmRldmljZSA9IGRldjsKKwlucl9pbnNlcnRfc29ja2V0KHNrKTsKKworCXNvY2tfcmVzZXRfZmxhZyhzaywgU09DS19aQVBQRUQpOworCWRldl9wdXQoZGV2KTsKKwlyZWxlYXNlX3NvY2soc2spOworCVNPQ0tfREVCVUcoc2ssICJORVQvUk9NOiBzb2NrZXQgaXMgYm91bmRcbiIpOworCXJldHVybiAwOworfQorCitzdGF0aWMgaW50IG5yX2Nvbm5lY3Qoc3RydWN0IHNvY2tldCAqc29jaywgc3RydWN0IHNvY2thZGRyICp1YWRkciwKKwlpbnQgYWRkcl9sZW4sIGludCBmbGFncykKK3sKKwlzdHJ1Y3Qgc29jayAqc2sgPSBzb2NrLT5zazsKKwlzdHJ1Y3QgbnJfc29jayAqbnIgPSBucl9zayhzayk7CisJc3RydWN0IHNvY2thZGRyX2F4MjUgKmFkZHIgPSAoc3RydWN0IHNvY2thZGRyX2F4MjUgKil1YWRkcjsKKwlheDI1X2FkZHJlc3MgKnVzZXIsICpzb3VyY2UgPSBOVUxMOworCXN0cnVjdCBuZXRfZGV2aWNlICpkZXY7CisKKwlsb2NrX3NvY2soc2spOworCWlmIChzay0+c2tfc3RhdGUgPT0gVENQX0VTVEFCTElTSEVEICYmIHNvY2stPnN0YXRlID09IFNTX0NPTk5FQ1RJTkcpIHsKKwkJc29jay0+c3RhdGUgPSBTU19DT05ORUNURUQ7CisJCXJlbGVhc2Vfc29jayhzayk7CisJCXJldHVybiAwOwkvKiBDb25uZWN0IGNvbXBsZXRlZCBkdXJpbmcgYSBFUkVTVEFSVFNZUyBldmVudCAqLworCX0KKworCWlmIChzay0+c2tfc3RhdGUgPT0gVENQX0NMT1NFICYmIHNvY2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dCB0aGUgdmFsdWUgb2YgbnIgaXMgYmV0d2VlbiB2YSBhbmQgdnMuIFJldHVybiB0cnVlIG9yCisgKglmYWxzZSBmb3IgdGVzdGluZy4KKyAqLworaW50IG5yX3ZhbGlkYXRlX25yKHN0cnVjdCBzb2NrICpzaywgdW5zaWduZWQgc2hvcnQgbnIpCit7CisJc3RydWN0IG5yX3NvY2sgKm5yb20gPSBucl9zayhzayk7CisJdW5zaWduZWQgc2hvcnQgdmMgPSBucm9tLT52YTsKKworCXdoaWxlICh2YyAhPSBucm9tLT52cykgeworCQlpZiAobnIgPT0gdmMpIHJldHVybiAxOworCQl2YyA9ICh2YyArIDEpICUgTlJfTU9EVUxVUzsKKwl9CisKKwlyZXR1cm4gbnIgPT0gbnJvbS0+dnM7Cit9CisKKy8qCisgKglDaGVjayB0aGF0IG5zIGlzIHdpdGhpbiB0aGUgcmVjZWl2ZSB3aW5kb3cuCisgKi8KK2ludCBucl9pbl9yeF93aW5kb3coc3RydWN0IHNvY2sgKnNrLCB1bnNpZ25lZCBzaG9ydCBucykKK3sKKwlzdHJ1Y3QgbnJfc29jayAqbnIgPSBucl9zayhzayk7CisJdW5zaWduZWQgc2hvcnQgdmMgPSBuci0+dnI7CisJdW5zaWduZWQgc2hvcnQgdnQgPSAobnItPnZsICsgbnItPndpbmRvdykgJSBOUl9NT0RVTFVTOworCisJd2hpbGUgKHZjICE9IHZ0KSB7CisJCWlmIChucyA9PSB2YykgcmV0dXJuIDE7CisJCXZjID0gKHZjICsgMSkgJSBOUl9NT0RVTFVTOworCX0KKworCXJldHVybiAwOworfQorCisvKgorICogIFRoaXMgcm91dGluZSBpcyBjYWxsZWQgd2hlbiB0aGUgSERMQyBsYXllciBpbnRlcm5hbGx5IGdlbmVyYXRlcyBhCisgKiAgY29udHJvbCBmcmFtZS4KKyAqLwordm9pZCBucl93cml0ZV9pbnRlcm5hbChzdHJ1Y3Qgc29jayAqc2ssIGludCBmcmFtZXR5cGUpCit7CisJc3RydWN0IG5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ICsgMCwgQVgyNV9BRERSX0xFTik7CisJZHB0cls2XSAmPSB+QVgyNV9DQklUOworCWRwdHJbNl0gfD0gQVgyNV9FQklUOworCWRwdHJbNl0gfD0gQVgyNV9TU1NJRF9TUEFSRTsKKwlkcHRyICs9IEFYMjVfQUREUl9MRU47CisKKwkqZHB0cisrID0gc3lzY3RsX25ldHJvbV9uZXR3b3JrX3R0bF9pbml0aWFsaXNlcjsKKworCWlmIChtaW5lKSB7CisJCSpkcHRyKysgPSAwOworCQkqZHB0cisrID0gMDsKKwkJKmRwdHIrKyA9IHNrYi0+ZGF0YVsxNV07CisJCSpkcHRyKysgPSBza2ItPmRhdGFbMTZdOworCX0gZWxzZSB7CisJCSpkcHRyKysgPSBza2ItPmRhdGFbMTVdOworCQkqZHB0cisrID0gc2tiLT5kYXRhWzE2XTsKKwkJKmRwdHIrKyA9IDA7CisJCSpkcHRyKysgPSAwOworCX0KKworCSpkcHRyKysgPSBOUl9DT05OQUNLIHwgTlJfQ0hPS0VfRkxBRzsKKwkqZHB0cisrID0gMDsKKworCWlmICghbnJfcm91dGVfZnJhbWUoc2tibiwgTlVMTCkpCisJCWtmcmVlX3NrYihza2JuKTsKK30KKwordm9pZCBucl9kaXNjb25uZWN0KHN0cnVjdCBzb2NrICpzaywgaW50IHJlYXNvbikKK3sKKwlucl9zdG9wX3QxdGltZXIoc2spOworCW5yX3N0b3BfdDJ0aW1lcihzayk7CisJbnJfc3RvcF90NHRpbWVyKHNrKTsKKwlucl9zdG9wX2lkbGV0aW1lcihzayk7CisKKwlucl9jbGVhcl9xdWV1ZXMoc2spOworCisJbnJfc2soc2spLT5zdGF0ZSA9IE5SX1NUQVRFXzA7CisKKwlzay0+c2tfc3RhdGUgICAgID0gVENQX0NMT1NFOworCXNrLT5za19lcnIgICAgICAgPSByZWFzb247CisJc2stPnNrX3NodXRkb3duIHw9IFNFTkRfU0hVVERPV047CisKKwlpZiAoIXNvY2tfZmxhZyhzaywgU09DS19ERUFEKSkgeworCQl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isJCisJaW5pdF90aW1lcigmbnItPnQydGltZXIpOworCW5yLT50MnRpbWVyLmRhdGEgICAgID0gKHVuc2lnbmVkIGxvbmcpc2s7CisJbnItPnQydGltZXIuZnVuY3Rpb24gPSAmbnJfdDJ0aW1lcl9leHBpcnk7CisKKwlpbml0X3RpbWVyKCZuci0+dDR0aW1lcik7CisJbnItPnQ0dGltZXIuZGF0YSAgICAgPSAodW5zaWduZWQgbG9uZylzazsKKwluci0+dDR0aW1lci5mdW5jdGlvbiA9ICZucl90NHRpbWVyX2V4cGlyeTsKKworCWluaXRfdGltZXIoJm5yLT5pZGxldGltZXIpOworCW5yLT5pZGxldGltZXIuZGF0YSAgICAgPSAodW5zaWduZWQgbG9uZylzazsKKwluci0+aWRsZXRpbWVyLmZ1bmN0aW9uID0gJm5yX2lkbGV0aW1lcl9leHBpcnk7CisKKwkvKiBpbml0aWFsaXplZCBieSBzb2NrX2luaXRfZGF0YSAqLworCXNrLT5za190aW1lci5kYXRhICAgICA9ICh1bnNpZ25lZCBsb25nKXNrOworCXNrLT5za190aW1lci5mdW5jdGlvbiA9ICZucl9oZWFydGJlYXRfZXhwaXJ5OworfQorCit2b2lkIG5yX3N0YXJ0X3QxdGltZXIoc3RydWN0IHNvY2sgKnNrKQoreworCXN0cnVjdCBucl9zb2NrICpuciA9IG5yX3NrKHNrKTsKKworCW1vZF90aW1lcigmbnItPnQxdGltZXIsIGppZmZpZXMgKyBuci0+dDEpOworfQorCit2b2lkIG5yX3N0YXJ0X3QydGltZXIoc3RydWN0IHNvY2sgKnNrKQoreworCXN0cnVjdCBucl9zb2NrICpuciA9IG5yX3NrKHNrKTsKKworCW1vZF90aW1lcigmbnItPnQydGltZXIsIGppZmZpZXMgKyBuci0+dDIpOworfQorCit2b2lkIG5yX3N0YXJ0X3Q0dGltZXIoc3RydWN0IHNvY2sgKnNrKQoreworCXN0cnVjdCBucl9zb2NrICpuciA9IG5yX3NrKHNrKTsKKworCW1vZF90aW1lcigmbnItPnQ0dG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RBVEVfMjsKKworCW5yX3N0YXJ0X3QxdGltZXIoc2spOworCW5yX3N0b3BfdDJ0aW1lcihzayk7CisJbnJfc3RvcF90NHRpbWVyKHNrKTsKKworCXNrLT5za19zdGF0ZSAgICAgPSBUQ1BfQ0xPU0U7CisJc2stPnNrX2VyciAgICAgICA9IDA7CisJc2stPnNrX3NodXRkb3duIHw9IFNFTkRfU0hVVERPV047CisKKwlpZiAoIXNvY2tfZmxhZyhzaywgU09DS19ERUFEKSkgeworCQlzay0+c2tfc3RhdGVfY2hhbmdlKHNrKTsKKwkJc29ja19zZXRfZmxhZyhzaywgU09DS19ERUFEKTsKKwl9CisJYmhfdW5sb2NrX3NvY2soc2spOworfQorCitzdGF0aWMgdm9pZCBucl90MXRpbWVyX2V4cGlyeSh1bnNpZ25lZCBsb25nIHBhcmFtKQoreworCXN0cnVjdCBzb2NrICpzayA9IChzdHJ1Y3Qgc29jayAqKXBhcmFtOworCXN0cnVjdCBucl9zb2NrICpuciA9IG5yX3NrKHNrKTsKKworCWJoX2xvY2tfc29jayhzayk7CisJc3dpdGNoIChuci0+c3RhdGUpIHsKKwljYXNlIE5SX1NUQVRFXzE6CisJCWlmIChuci0+bjJjb3VudCA9PSBuci0+bjIpIHsKKwkJCW5yX2Rpc2Nvbm5lY3Qoc2ssIEVUSU1FRE9VVCk7CisJCQliaF91bmxvY2tfc29jayhzayk7CisJCQlyZXR1cm47CisJCX0gZWxzZSB7CisJCQluci0+bjJjb3VudCsrOworCQkJbnJfd3JpdGVfaW50ZXJuYWwoc2ssIE5SX0NPTk5SRVEpOworCQl9CisJCWJyZWFrOworCisJY2FzZSBOUl9TVEFURV8yOgorCQlpZiAobnItPm4yY291bnQgPT0gbnItPm4yKSB7CisJCQlucl9kaXNjb25uZWN0KHNrLCBFVElNRURPVVQpOworCQkJYmhfdW5sb2NrX3NvY2soc2spOworCQkJcmV0dXJuOworCQl9IGVsc2UgeworCQkJbnItPm4yY291bnQrKzsKKwkJCW5yX3dyaXRlX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aW5jbHVkZSA8bGludXgvbW0uaD4KKyNpbmNsdWRlIDxsaW51eC9zeXNjdGwuaD4KKyNpbmNsdWRlIDxsaW51eC9pbml0Lmg+CisjaW5jbHVkZSA8bmV0L2F4MjUuaD4KKyNpbmNsdWRlIDxuZXQvbmV0cm9tLmg+CisKKy8qCisgKglWYWx1ZXMgdGFrZW4gZnJvbSBORVQvUk9NIGRvY3VtZW50YXRpb24uCisgKi8KK3N0YXRpYyBpbnQgbWluX3F1YWxpdHlbXSA9IHswfSwgbWF4X3F1YWxpdHlbXSA9IHsyNTV9Oworc3RhdGljIGludCBtaW5fb2JzW10gICAgID0gezB9LCBtYXhfb2JzW10gICAgID0gezI1NX07CitzdGF0aWMgaW50IG1pbl90dGxbXSAgICAgPSB7MH0sIG1heF90dGxbXSAgICAgPSB7MjU1fTsKK3N0YXRpYyBpbnQgbWluX3QxW10gICAgICA9IHs1ICogSFp9Oworc3RhdGljIGludCBtYXhfdDFbXSAgICAgID0gezYwMCAqIEhafTsKK3N0YXRpYyBpbnQgbWluX24yW10gICAgICA9IHsyfSwgbWF4X24yW10gICAgICA9IHsxMjd9Oworc3RhdGljIGludCBtaW5fdDJbXSAgICAgID0gezEgKiBIWn07CitzdGF0aWMgaW50IG1heF90MltdICAgICAgPSB7NjAgKiBIWn07CitzdGF0aWMgaW50IG1pbl90NFtdICAgICAgPSB7MSAqIEhafTsKK3N0YXRpYyBpbnQgbWF4X3Q0W10gICAgICA9IHsxMDAwICogSFp9Oworc3RhdGljIGludCBtaW5fd2luZG93W10gID0gezF9LCBtYXhfd2luZG93W10gID0gezEyN307CitzdGF0aWMgaW50IG1pbl9pZGxlW10gICAgPSB7MCAqIEhafTsKK3N0YXRpYyBpbnQgbWF4X2lkbGVbXSAgICA9IHs2NTUzNSAqIEhafTsKK3N0YXRpYyBpbnQgbWluX3JvdXRlW10gICA9IHswfSwgbWF4X3JvdXRlW10gICA9IHsxfTsKK3N0YXRpYyBpbnQgbWluX2ZhaWxzW10gICA9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90b2NvbCBob29rCisJCSAqLworCQlkZXZfcmVtb3ZlX3BhY2soJnBvLT5wcm90X2hvb2spOworCQlwby0+cnVubmluZyA9IDA7CisJCXBvLT5udW0gPSAwOworCQlfX3NvY2tfcHV0KHNrKTsKKwl9CisKKyNpZmRlZiBDT05GSUdfUEFDS0VUX01VTFRJQ0FTVAorCXBhY2tldF9mbHVzaF9tY2xpc3Qoc2spOworI2VuZGlmCisKKyNpZmRlZiBDT05GSUdfUEFDS0VUX01NQVAKKwlpZiAocG8tPnBnX3ZlYykgeworCQlzdHJ1Y3QgdHBhY2tldF9yZXEgcmVxOworCQltZW1zZXQoJnJlcSwgMCwgc2l6ZW9mKHJlcSkpOworCQlwYWNrZXRfc2V0X3Jpbmcoc2ssICZyZXEsIDEpOworCX0KKyNlbmRpZgorCisJLyoKKwkgKglOb3cgdGhlIHNvY2tldCBpcyBkZWFkLiBObyBtb3JlIGlucHV0IHdpbGwgYXBwZWFyLgorCSAqLworCisJc29ja19vcnBoYW4oc2spOworCXNvY2stPnNrID0gTlVMTDsKKworCS8qIFB1cmdlIHF1ZXVlcyAqLworCisJc2tiX3F1ZXVlX3B1cmdlKCZzay0+c2tfcmVjZWl2ZV9xdWV1ZSk7CisKKwlzb2NrX3B1dChzayk7CisJcmV0dXJuIDA7Cit9CisKKy8qCisgKglBdHRhY2ggYSBwYWNrZXQgaG9vay4KKyAqLworCitzdGF0aWMgaW50IHBhY2tldF9kb19iaW5kKHN0cnVjdCBzb2NrICpzaywgc3RydWN0IG5ldF9kZXZpY2UgKmRldiwgaW50IHByb3RvY29sKQoreworCXN0cnVjdCBwYWNrZXRfc29jayAqcG8gPSBwa3Rfc2soc2spOworCS8qCisJICoJRGV0YWNoIGFuIGV4aXN0aW5nIGhvb2sgaWYgcHJlc2VudC4KKwkgKi8KKworCWxvY2tfc29jayhzayk7CisKKwlzcGluX2xvY2soJnBvLT5iaW5kX2xvY2spOworCWlmIChwby0+cnVubmluZykgeworCQlfX3NvY2tfcHV0KHNrKTsKKwkJcG8tPnJ1bm5pbmcgPSAwOworCQlwby0+bnVtID0gMDsKKwkJc3Bpbl91bmxvY2soJnBvLT5iaW5kX2xvY2spOworCQlkZXZfcmVtb3ZlX3BhY2soJnBvLT5wcm90X2hvb2spOworCQlzcGluX2xvY2soJnBvLT5iaW5kX2xvY2spOworCX0KKworCXBvLT5udW0gPSBwcm90b2NvbDsKKwlwby0+cHJvdF9ob29rLnR5cGUgPSBwcm90b2NvbDsKKwlwby0+cHJvdF9ob29rLmRldiA9IGRldjsKKworCXBvLT5pZmluZGV4ID0gZGV2ID8gZGV2LT5pZmluZGV4IDogMDsKKworCWlmIChwcm90b2NvbCA9PSAwKQorCQlnb3RvIG91dF91bmxvY2s7CisKKwlpZiAoZGV2KSB7CisJCWlmIChkZXYtPmZsYWdzJklGRl9VUCkgeworCQkJZGV2X2FkZF9wYWNrKCZwby0+cHJvdF9ob29rKTsKKwkJCXNvY2tfaG9sZChzayk7CisJCQlwby0+cnVubmluZyA9IDE7CisJCX0gZWxzZSB7CisJCQlzay0+c2tfZXJyID0gRU5FVERPV047CisJCQlpZiAoIXNvY2tfZmxhZyhzaywgU09DS19ERUFEKSkKKwkJCQlzay0+c2tfZXJyb3JfcmVwb3J0KHNrKTsKKwkJfQorCX0gZWxzZSB7CisJCWRldl9hZGRfcGFjaygmcG8tPnByb3RfaG9vayk7CisJCXNvY2tfaG9sZChzayk7CisJCXBvLT5ydW5uaW5nID0gMTsKKwl9CisKK291dF91bmxvY2s6CisJc3Bpbl91bmxvY2soJnBvLT5iaW5kX2xvY2spOworCXJlbGVhc2Vfc29jayhzayk7CisJcmV0dXJuIDA7Cit9CisKKy8qCisgKglCaW5kIGEgcGFja2V0IHNvY2tldCB0byBhIGRldmljZQorICovCisKKyNpZmRlZiBDT05GSUdfU09DS19QQUNLRVQKKworc3RhdGljIGludCBwYWNrZXRfYmluZF9zcGt0KHN0cnVjdCBzb2NrZXQgKnNvY2ssIHN0cnVjdCBzb2NrYWRkciA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SAtRU5PREVWOworCQlkZXYgPSBkZXZfZ2V0X2J5X2luZGV4KHNsbC0+c2xsX2lmaW5kZXgpOworCQlpZiAoZGV2ID09IE5VTEwpCisJCQlnb3RvIG91dDsKKwl9CisJZXJyID0gcGFja2V0X2RvX2JpbmQoc2ssIGRldiwgc2xsLT5zbGxfcHJvdG9jb2wgPyA6IHBrdF9zayhzayktPm51bSk7CisJaWYgKGRldikKKwkJZGV2X3B1dChkZXYpOworCitvdXQ6CisJcmV0dXJuIGVycjsKK30KKworc3RhdGljIHN0cnVjdCBwcm90byBwYWNrZXRfcHJvdG8gPSB7CisJLm5hbWUJICA9ICJQQUNLRVQiLAorCS5vd25lcgkgID0gVEhJU19NT0RVTEUsCisJLm9ial9zaXplID0gc2l6ZW9mKHN0cnVjdCBwYWNrZXRfc29jayksCit9OworCisvKgorICoJQ3JlYXRlIGEgcGFja2V0IG9mIHR5cGUgU09DS19QQUNLRVQuIAorICovCisKK3N0YXRpYyBpbnQgcGFja2V0X2NyZWF0ZShzdHJ1Y3Qgc29ja2V0ICpzb2NrLCBpbnQgcHJvdG9jb2wpCit7CisJc3RydWN0IHNvY2sgKnNrOworCXN0cnVjdCBwYWNrZXRfc29jayAqcG87CisJaW50IGVycjsKKworCWlmICghY2FwYWJsZShDQVBfTkVUX1JBVykpCisJCXJldHVybiAtRVBFUk07CisJaWYgKHNvY2stPnR5cGUgIT0gU09DS19ER1JBTSAmJiBzb2NrLT50eXBlICE9IFNPQ0tfUkFXCisjaWZkZWYgQ09ORklHX1NPQ0tfUEFDS0VUCisJICAgICYmIHNvY2stPnR5cGUgIT0gU09DS19QQUNLRVQKKyNlbmRpZgorCSAgICApCisJCXJldHVybiAtRVNPQ0tUTk9TVVBQT1JUOworCisJc29jay0+c3RhdGUgPSBTU19VTkNPTk5FQ1RFRDsKKworCWVyciA9IC1FTk9CVUZTOworCXNrID0gc2tfYWxsb2MoUEZfUEFDS0VULCBHRlBfS0VSTkVMLCAmcGFja2V0X3Byb3RvL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DsKKworCXJldHVybiBjb3B5X3RvX3VzZXIob3B0dmFsLCAmdmFsLCBsZW4pID8gLUVGQVVMVCA6IDA7Cit9CisKK3N0YXRpYyBpbnQgcm9zZV9saXN0ZW4oc3RydWN0IHNvY2tldCAqc29jaywgaW50IGJhY2tsb2cpCit7CisJc3RydWN0IHNvY2sgKnNrID0gc29jay0+c2s7CisKKwlpZiAoc2stPnNrX3N0YXRlICE9IFRDUF9MSVNURU4pIHsKKwkJc3RydWN0IHJvc2Vfc29jayAqcm9zZSA9IHJvc2Vfc2soc2spOworCisJCXJvc2UtPmRlc3RfbmRpZ2lzID0gMDsKKwkJbWVtc2V0KCZyb3NlLT5kZXN0X2FkZHIsIDAsIFJPU0VfQUREUl9MRU4pOworCQltZW1zZXQoJnJvc2UtPmRlc3RfY2FsbCwgMCwgQVgyNV9BRERSX0xFTik7CisJCW1lbXNldChyb3NlLT5kZXN0X2RpZ2lzLCAwLCBBWDI1X0FERFJfTEVOICogUk9TRV9NQVhfRElHSVMpOworCQlzay0+c2tfbWF4X2Fja19iYWNrbG9nID0gYmFja2xvZzsKKwkJc2stPnNrX3N0YXRlICAgICAgICAgICA9IFRDUF9MSVNURU47CisJCXJldHVybiAwOworCX0KKworCXJldHVybiAtRU9QTk9UU1VQUDsKK30KKworc3RhdGljIHN0cnVjdCBwcm90byByb3NlX3Byb3RvID0geworCS5uYW1lCSAgPSAiUk9TRSIsCisJLm93bmVyCSAgPSBUSElTX01PRFVMRSwKKwkub2JqX3NpemUgPSBzaXplb2Yoc3RydWN0IHJvc2Vfc29jayksCit9OworCitzdGF0aWMgaW50IHJvc2VfY3JlYXRlKHN0cnVjdCBzb2NrZXQgKnNvY2ssIGludCBwcm90b2NvbCkKK3sKKwlzdHJ1Y3Qgc29jayAqc2s7CisJc3RydWN0IHJvc2Vfc29jayAqcm9zZTsKKworCWlmIChzb2NrLT50eXBlICE9IFNPQ0tfU0VRUEFDS0VUIHx8IHByb3RvY29sICE9IDApCisJCXJldHVybiAt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ZJOworCWFzbXB0clsxXSA9IChyb3NlLT5sY2kgPj4gMCkgJiAweEZGOworCWFzbXB0clsyXSA9IFJPU0VfREFUQTsKKworCWlmIChxYml0KQorCQlhc21wdHJbMF0gfD0gUk9TRV9RX0JJVDsKKworCVNPQ0tfREVCVUcoc2ssICJST1NFOiBCdWlsdCBoZWFkZXIuXG4iKTsKKworCVNPQ0tfREVCVUcoc2ssICJST1NFOiBUcmFuc21pdHRpbmcgYnVmZmVyXG4iKTsKKworCWlmIChzay0+c2tfc3RhdGUgIT0gVENQX0VTVEFCTElTSEVEKSB7CisJCWtmcmVlX3NrYihza2IpOworCQlyZXR1cm4gLUVOT1RDT05OOworCX0KKworI2lmZGVmIE1fQklUCisjZGVmaW5lIFJPU0VfUEFDTEVOICgyNTYtUk9TRV9NSU5fTEVOKQorCWlmIChza2ItPmxlbiAtIFJPU0VfTUlOX0xFTiA+IFJPU0VfUEFDTEVOKSB7CisJCXVuc2lnbmVkIGNoYXIgaGVhZGVyW1JPU0VfTUlOX0xFTl07CisJCXN0cnVjdCBza19idWZmICpza2JuOworCQlpbnQgZnJvbnRsZW47CisJCWludCBsZzsKKworCQkvKiBTYXZlIGEgY29weSBvZiB0aGUgSGVhZGVyICovCisJCW1lbWNweShoZWFkZXIsIHNrYi0+ZGF0YSwgUk9TRV9NSU5fTEVOKTsKKwkJc2tiX3B1bGwoc2tiLCBST1NFX01JTl9MRU4pOworCisJCWZyb250bGVuID0gc2tiX2hlYWRyb29tKHNrYik7CisKKwkJd2hpbGUgKHNrYi0+bGVuID4gMCkgeworCQkJaWYgKChza2JuID0gc29ja19hbGxvY19zZW5kX3NrYihzaywgZnJvbnRsZW4gKyBST1NFX1BBQ0xFTiwgMCwgJmVycikpID09IE5VTEwpIHsKKwkJCQlrZnJlZV9za2Ioc2tiKTsKKwkJCQlyZXR1cm4gZXJyOworCQkJfQorCisJCQlza2JuLT5zayAgID0gc2s7CisJCQlza2JuLT5mcmVlID0gMTsKKwkJCXNrYm4tP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sbHNpZ25bMTFdOworCisJZG8geworCQlzd2l0Y2ggKCpwICYgMHhDMCkgeworCQljYXNlIDB4MDA6CisJCQlwICAgKz0gMjsKKwkJCW4gICArPSAyOworCQkJbGVuIC09IDI7CisJCQlicmVhazsKKworCQljYXNlIDB4NDA6CisJCQlwICAgKz0gMzsKKwkJCW4gICArPSAzOworCQkJbGVuIC09IDM7CisJCQlicmVhazsKKworCQljYXNlIDB4ODA6CisJCQlwICAgKz0gNDsKKwkJCW4gICArPSA0OworCQkJbGVuIC09IDQ7CisJCQlicmVhazsKKworCQljYXNlIDB4QzA6CisJCQlsID0gcFsxXTsKKwkJCWlmICgqcCA9PSBGQUNfQ0NJVFRfREVTVF9OU0FQKSB7CisJCQkJbWVtY3B5KCZmYWNpbGl0aWVzLT5zb3VyY2VfYWRkciwgcCArIDcsIFJPU0VfQUREUl9MRU4pOworCQkJCW1lbWNweShjYWxsc2lnbiwgcCArIDEyLCAgIGwgLSAxMCk7CisJCQkJY2FsbHNpZ25bbCAtIDEwXSA9ICdcMCc7CisJCQkJZmFjaWxpdGllcy0+c291cmNlX2NhbGwgPSAqYXNjMmF4KGNhbGxzaWduKTsKKwkJCX0KKwkJCWlmICgqcCA9PSBGQUNfQ0NJVFRfU1JDX05TQVApIHsKKwkJCQltZW1jcHkoJmZhY2lsaXRpZXMtPmRlc3RfYWRkciwgcCArIDcsIFJPU0VfQUREUl9MRU4pOworCQkJCW1lbWNweShjYWxsc2lnbiwgcCArIDEyLCBsIC0gMTApOworCQkJCWNhbGxzaWduW2wgLSAxMF0gPSAnXDAnOworCQkJCWZhY2lsaXRpZXMtPmRlc3RfY2FsbCA9ICphc2MyYXgoY2FsbHNpZ24pOworCQkJfQorCQkJcCAgICs9IGwgKyAyOworCQkJbiAgICs9IGwgKyAyOworCQkJbGVuIC09IGwgKyAyOworCQkJYnJlYWs7CisJCX0KKwl9IHdoaWxlICgqcCAhPSAweDAwICYmIGxlbiA+IDApOworCisJcmV0dXJuIG47Cit9CisK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vY2spOworCisJZnJlZV9wYWdlKCh1bnNpZ25lZCBsb25nKSBjYWxsKTsKKwlfbGVhdmUoIiA9ICVkIiwgcmV0KTsKKwlyZXR1cm4gcmV0OworfSAvKiBlbmQgcnhycGNfY3JlYXRlX2NhbGwoKSAqLworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisvKgorICogY3JlYXRlIGEgbmV3IGNhbGwgcmVjb3JkIGZvciBpbmNvbWluZyBjYWxscworICovCitpbnQgcnhycGNfaW5jb21pbmdfY2FsbChzdHJ1Y3QgcnhycGNfY29ubmVjdGlvbiAqY29ubiwKKwkJCXN0cnVjdCByeHJwY19tZXNzYWdlICptc2csCisJCQlzdHJ1Y3QgcnhycGNfY2FsbCAqKl9jYWxsKQoreworCXN0cnVjdCByeHJwY19jYWxsICpjYWxsOworCXVuc2lnbmVkIGNpeDsKKwlpbnQgcmV0OworCisJY2l4ID0gbnRvaGwobXNnLT5oZHIuY2lkKSAmIFJYUlBDX0NIQU5ORUxNQVNLOworCisJX2VudGVyKCIlcCwldSwldSIsIGNvbm4sIG50b2hsKG1zZy0+aGRyLmNhbGxOdW1iZXIpLCBjaXgpOworCisJLyogYWxsb2NhdGUgYW5kIGluaXRpYWxpc2UgYSBjYWxsIHJlY29yZCAqLworCXJldCA9IF9fcnhycGNfY3JlYXRlX2NhbGwoY29ubiwgJmNhbGwpOworCWlmIChyZXQgPCAwKSB7CisJCV9sZWF2ZSgiID0gJWQiLCByZXQpOworCQlyZXR1cm4gcmV0OworCX0KKworCWNhbGwtPnBrdF9yY3ZfY291bnQgPSAxOworCWNhbGwtPmFwcF9jYWxsX3N0YXRlID0gUlhSUENfQ1NUQVRFX1NSVlJfUkNWX09QSUQ7CisJY2FsbC0+YXBwX21hcmsgPSBzaXplb2YodWludDMyX3QpOworCisJX3N0YXRlKGNhbGwpOworCisJLyogYXR0YWNoIHRvIHRoZSBjb25u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bMF0uaW92X2Jhc2UgPSAmYWNrOworCQlkaW92WzFdLmlvdl9sZW4gID0gc2l6ZW9mKGFja3MpOworCQlkaW92WzFdLmlvdl9iYXNlID0gYWNrczsKKworCQkvKiBidWlsZCBhbmQgc2VuZCB0aGUgbWVzc2FnZSAqLworCQllcnIgPSByeHJwY19jb25uX25ld21zZyhjYWxsLT5jb25uLGNhbGwsIFJYUlBDX1BBQ0tFVF9UWVBFX0FDSywKKwkJCQkJaGRyLT5zZXEgPyAyIDogMSwgZGlvdiwKKwkJCQkJR0ZQX0tFUk5FTCwKKwkJCQkJJm1zZyk7CisJCWlmIChlcnIgPCAwKSB7CisJCQlyZXQgPSBlcnI7CisJCQlnb3RvIG91dDsKKwkJfQorCisJCW1zZy0+c2VxID0gc2VxOworCQltc2ctPmhkci5zZXEgPSBodG9ubChzZXEpOworCQltc2ctPmhkci5mbGFncyB8PSBSWFJQQ19TTE9XX1NUQVJUX09LOworCisJCWVyciA9IHJ4cnBjX2Nvbm5fc2VuZG1zZyhjYWxsLT5jb25uLCBtc2cpOworCQlyeHJwY19wdXRfbWVzc2FnZShtc2cpOworCQlpZiAoZXJyIDwgMCkgeworCQkJcmV0ID0gZXJyOworCQkJZ290byBvdXQ7CisJCX0KKwkJY2FsbC0+cGt0X3NuZF9jb3VudCsrOworCX0KKworIG91dDoKKwlpZiAoaGRyLT5zZXEpCisJCWNhbGwtPmFja3JfcHJldl9zZXEgPSBoZHItPnNlcTsKKworCV9sZWF2ZSgiID0gJWQiLCByZXQpOworCXJldHVybiByZXQ7Cit9IC8qIGVuZCByeHJwY19jYWxsX2dlbmVyYXRlX0FDSygpICovCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKy8qCisgKiBoYW5kbGUgd29yayB0byBiZSBkb25lIG9uIGEgY2FsbAorICogLSBpbmNsdWRlcyBwYWNrZXQgcmVjZXB0aW9uIGFuZCB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hycGNfcHV0X21lc3NhZ2UobXNnKTsKKwkJfQorCX0KKworCS8qIHRlbGwgdGhlIGFwcCBsYXllciB0byBsZXQgZ28gKi8KKwljYWxsLT5hcHBfZXJyb3JfZnVuYyhjYWxsKTsKKworCXJ4cnBjX3B1dF9jYWxsKGNhbGwpOworCisJX2xlYXZlKCIgPSAlZCIsIHJldCk7CisJcmV0dXJuIHJldDsKK30gLyogZW5kIF9fcnhycGNfY2FsbF9hYm9ydCgpICovCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKy8qCisgKiBzZW5kIGFuIGFib3J0IG1lc3NhZ2UgYXQgY2FsbCBvciBjb25uZWN0aW9uIGxldmVsCisgKiAtIHRoZSBzdXBwbGllZCBlcnJvciBjb2RlIGlzIHNlbnQgYXMgdGhlIHBhY2tldCBkYXRhCisgKi8KK2ludCByeHJwY19jYWxsX2Fib3J0KHN0cnVjdCByeHJwY19jYWxsICpjYWxsLCBpbnQgZXJyb3IpCit7CisJc3Bpbl9sb2NrKCZjYWxsLT5sb2NrKTsKKworCXJldHVybiBfX3J4cnBjX2NhbGxfYWJvcnQoY2FsbCwgZXJyb3IpOworCit9IC8qIGVuZCByeHJwY19jYWxsX2Fib3J0KCkgKi8KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworLyoKKyAqIHByb2Nlc3MgcGFja2V0cyB3YWl0aW5nIGZvciB0aGlzIGNhbGwKKyAqLworc3RhdGljIHZvaWQgcnhycGNfY2FsbF9yZWNlaXZlX3BhY2tldChzdHJ1Y3QgcnhycGNfY2FsbCAqY2FsbCkKK3sKKwlzdHJ1Y3QgcnhycGNfbWVzc2FnZSAqbXNnOworCXN0cnVjdCBsaXN0X2hlYWQgKl9wOworCisJX2VudGVyKCIlcCIsIGNhbGwpOworCisJcnhycGN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kJfQorCisJCWNhbGwtPmFja3NfcGVuZF9jbnQrKzsKKworCQltb2RfdGltZXIoJmNhbGwtPmFja3NfdGltZW91dCwKKwkJCSAgX19yeHJwY19ydHRfYmFzZWRfdGltZW91dChjYWxsLAorCQkJCQkJICAgIHJ4cnBjX2NhbGxfYWNrc190aW1lb3V0KSk7CisKKwkJc3Bpbl91bmxvY2soJmNhbGwtPmxvY2spOworCisJCXJldCA9IHJ4cnBjX2Nvbm5fc2VuZG1zZyhjYWxsLT5jb25uLCBtc2cpOworCQlpZiAocmV0ID09IDApCisJCQljYWxsLT5wa3Rfc25kX2NvdW50Kys7CisJfQorCisgb3V0OgorCXJ4cnBjX3B1dF9jYWxsKGNhbGwpOworCisJX2xlYXZlKCIgPSAlZCIsIHJldCk7CisJcmV0dXJuIHJldDsKKworfSAvKiBlbmQgcnhycGNfY2FsbF9mbHVzaCgpICovCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKy8qCisgKiByZXNlbmQgTkFLJ2Qgb3IgdW5hY2tub3dsZWRnZWQgcGFja2V0cyB1cCB0byB0aGUgaGlnaGVzdCBvbmUgc3BlY2lmaWVkCisgKi8KK3N0YXRpYyB2b2lkIHJ4cnBjX2NhbGxfcmVzZW5kKHN0cnVjdCByeHJwY19jYWxsICpjYWxsLCByeHJwY19zZXFfdCBoaWdoZXN0KQoreworCXN0cnVjdCByeHJwY19tZXNzYWdlICptc2c7CisJc3RydWN0IGxpc3RfaGVhZCAqX3A7CisJcnhycGNfc2VxX3Qgc2VxID0gMDsKKworCV9lbnRlcigiJXAsJXUiLCBjYWxsLCBoaWdoZXN0KTsKKworCV9wcm90bygiUnggUmVzZW5kIHJlcXVpcmVkIik7CisKKwkvKiBoYW5kbGUgdG9vIG1hbnkgcmVzZW5kcyAqLworCWlmIChjYWxsLT5zbmRfcmVzZW5kX2NudCA+PSByeHJwY19jYWxsX21heF9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W1lb3V0KGNvbm4pOworfQorCitzdGF0aWMgY29uc3Qgc3RydWN0IHJ4cnBjX3RpbWVyX29wcyByeHJwY19jb25uX3RpbWVyX29wcyA9IHsKKwkudGltZWRfb3V0CT0gX19yeHJwY19jb25uX3RpbWVvdXQsCit9OworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisvKgorICogY3JlYXRlIGEgbmV3IGNvbm5lY3Rpb24gcmVjb3JkCisgKi8KK3N0YXRpYyBpbmxpbmUgaW50IF9fcnhycGNfY3JlYXRlX2Nvbm5lY3Rpb24oc3RydWN0IHJ4cnBjX3BlZXIgKnBlZXIsCisJCQkJCSAgICBzdHJ1Y3QgcnhycGNfY29ubmVjdGlvbiAqKl9jb25uKQoreworCXN0cnVjdCByeHJwY19jb25uZWN0aW9uICpjb25uOworCisJX2VudGVyKCIlcCIscGVlcik7CisKKwkvKiBhbGxvY2F0ZSBhbmQgaW5pdGlhbGlzZSBhIGNvbm5lY3Rpb24gcmVjb3JkICovCisJY29ubiA9IGttYWxsb2Moc2l6ZW9mKHN0cnVjdCByeHJwY19jb25uZWN0aW9uKSwgR0ZQX0tFUk5FTCk7CisJaWYgKCFjb25uKSB7CisJCV9sZWF2ZSgiID0gLUVOT01FTSIpOworCQlyZXR1cm4gLUVOT01FTTsKKwl9CisKKwltZW1zZXQoY29ubiwgMCwgc2l6ZW9mKHN0cnVjdCByeHJwY19jb25uZWN0aW9uKSk7CisJYXRvbWljX3NldCgmY29ubi0+dXNhZ2UsIDEpOworCisJSU5JVF9MSVNUX0hFQUQoJmNvbm4tPmxpbmspOworCUlOSVRfTElTVF9IRUFEKCZjb25uLT5pZF9saW5rKTsKKwlpbml0X3dhaXRxdWV1ZV9oZWFkKCZjb25uLT5jaGFud2FpdCk7CisJc3Bpbl9sb2NrX2luaXQoJmNvbm4tPmxvY2spOworCXJ4cnBjX3RpbWVyX2luaXQoJmNvbm4tPnRpbWVvdXQsICZyeHJwY19jb25uX3RpbWVyX29wcyk7CisKKwlkb19nZXR0aW1lb2ZkYXkoJmNvbm4tPmF0aW1lKTsKKwljb25uLT5tdHVfc2l6ZSA9IDEwMjQ7CisJY29ubi0+cGVlciA9IHBlZXI7CisJY29ubi0+dHJhbnMgPSBwZWVyLT50cmFuczsKKworCV9fUlhBQ0NUKGF0b21pY19pbmMoJnJ4cnBjX2Nvbm5lY3Rpb25fY291bnQpKTsKKwkqX2Nvbm4gPSBjb25uOworCV9sZWF2ZSgiID0gMCAoJXApIiwgY29ubik7CisKKwlyZXR1cm4gMDsKK30gLyogZW5kIF9fcnhycGNfY3JlYXRlX2Nvbm5lY3Rpb24oKSAqLworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisvKgorICogY3JlYXRlIGEgbmV3IGNvbm5lY3Rpb24gcmVjb3JkIGZvciBvdXRnb2luZyBjb25uZWN0aW9ucworICovCitpbnQgcnhycGNfY3JlYXRlX2Nvbm5lY3Rpb24oc3RydWN0IHJ4cnBjX3RyYW5zcG9ydCAqdHJhbnMsCisJCQkgICAgX19iZTE2IHBvcnQsCisJCQkgICAgX19iZTMyIGFkZHIsCisJCQkgICAgdWludDE2X3Qgc2VydmljZV9pZCwKKwkJCSAgICB2b2lkICpzZWN1cml0eSwKKwkJCSAgICBzdHJ1Y3QgcnhycGNfY29ubmVjdGlvbiAqKl9jb25uKQoreworCXN0cnVjdCByeHJwY19jb25uZWN0aW9uICpjYW5kaWRhdGUsICpjb25uOworCXN0cnVjdCByeHJwY19wZWVyICpwZWVyOworCXN0cnVjdCBsaXN0X2hlYWQgKl9wOworCV9fYmUzMiBjb25uaWQ7CisJaW50IHJldDsKKworCV9lbnRlcigiJXB7JWh1fSwldSwlaHUiLCB0cmFucywgdHJhbnMtPnBvcnQsIG50b2hzKHBvcnQpLCBzZXJ2aWNlX2lkKTs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JnBlZXItPmNvbm5fZ3lsb2NrKTsKKwlnb3RvIG1ha2VfYWN0aXZlOworCisJLyogaGFuZGxlIGZpbmRpbmcgdGhlIGNvbm5lY3Rpb24gb24gdGhlIHNlY29uZCB0aW1lIHRocm91Z2ggdGhlIGFjdGl2ZQorCSAqIGxpc3QgKi8KKyBmb3VuZF9hY3RpdmVfc2Vjb25kX2NoYW5jZToKKwlyeHJwY19nZXRfY29ubmVjdGlvbihjb25uKTsKKwlnb3RvIHN1Y2Nlc3NfdXdmcmVlOworCit9IC8qIGVuZCByeHJwY19jb25uZWN0aW9uX2xvb2t1cCgpICovCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKy8qCisgKiBmaW5pc2ggdXNpbmcgYSBjb25uZWN0aW9uIHJlY29yZAorICogLSBpdCB3aWxsIGJlIHRyYW5zZmVycmVkIHRvIHRoZSBwZWVyJ3MgY29ubmVjdGlvbiBncmF2ZXlhcmQgd2hlbiByZWZjb3VudAorICogICByZWFjaGVzIDAKKyAqLwordm9pZCByeHJwY19wdXRfY29ubmVjdGlvbihzdHJ1Y3QgcnhycGNfY29ubmVjdGlvbiAqY29ubikKK3sKKwlzdHJ1Y3QgcnhycGNfcGVlciAqcGVlcjsKKworCWlmICghY29ubikKKwkJcmV0dXJuOworCisJX2VudGVyKCIlcHt1PSVkIHA9JWh1fSIsCisJICAgICAgIGNvbm4sIGF0b21pY19yZWFkKCZjb25uLT51c2FnZSksIG50b2hzKGNvbm4tPmFkZHIuc2luX3BvcnQpKTsKKworCXBlZXIgPSBjb25uLT5wZWVyOworCXNwaW5fbG9jaygmcGVlci0+Y29ubl9neWxvY2spOworCisJLyogc2FuaXR5IGNoZWNrICovCisJaWYgKGF0b21pY19yZWFkKCZjb25uLT51c2FnZSkgPD0gMCkKKwkJQlVHKCk7CisKKwlpZiAobGlrZWx5KCFhdG9taWNfZGVjX2FuZF90ZXN0KCZjb25uLT51c2FnZSkpKSB7CisJCXNwaW5fdW5sb2NrKCZwZWVyLT5jb25uX2d5bG9jayk7CisJCV9sZWF2ZSgiIik7CisJCXJldHVybjsKKwl9CisKKwkvKiBtb3ZlIHRvIGdyYXZleWFyZCBxdWV1ZSAqLworCV9kZWJ1ZygiYnVyeWluZyBjb25uZWN0aW9uOiB7JTA4eH0iLCBudG9obChjb25uLT5jb25uX2lkKSk7CisJbGlzdF9kZWwoJmNvbm4tPmxpbmspOworCWxpc3RfYWRkX3RhaWwoJmNvbm4tPmxpbmssICZwZWVyLT5jb25uX2dyYXZleWFyZCk7CisKKwlyeHJwY19rcnh0aW1vZF9hZGRfdGltZXIoJmNvbm4tPnRpbWVvdXQsIHJ4cnBjX2Nvbm5fdGltZW91dCAqIEhaKTsKKworCXNwaW5fdW5sb2NrKCZwZWVyLT5jb25uX2d5bG9jayk7CisKKwlyeHJwY19wdXRfcGVlcihjb25uLT5wZWVyKTsKKworCV9sZWF2ZSgiIFtraWxsZWRdIik7Cit9IC8qIGVuZCByeHJwY19wdXRfY29ubmVjdGlvbigpICovCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKy8qCisgKiBmcmVlIGEgY29ubmVjdGlvbiByZWNvcmQKKyAqLworc3RhdGljIHZvaWQgcnhycGNfY29ubl9kb190aW1lb3V0KHN0cnVjdCByeHJwY19jb25uZWN0aW9uICpjb25uKQoreworCXN0cnVjdCByeHJwY19wZWVyICpwZWVyOworCisJX2VudGVyKCIlcHt1PSVkIHA9JWh1fSIsCisJICAgICAgIGNvbm4sIGF0b21pY19yZWFkKCZjb25uLT51c2FnZSksIG50b2hzKGNvbm4tPmFkZHIuc2luX3BvcnQpKTsKKworCXBlZXIgPSBjb25uLT5wZWVyOworCisJaWYgKGF0b21pY19yZWFkKCZjb25uLT51c2FnZSkgPCAwKQorCQlCVUcoKTsKKworCS8q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b3V0KCkgKi8KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworLyoKKyAqIGNsZWFyIGFsbCBjb25uZWN0aW9uIHJlY29yZHMgZnJvbSBhIHBlZXIgZW5kcG9pbnQKKyAqLwordm9pZCByeHJwY19jb25uX2NsZWFyYWxsKHN0cnVjdCByeHJwY19wZWVyICpwZWVyKQoreworCURFQ0xBUkVfV0FJVFFVRVVFKG15c2VsZiwgY3VycmVudCk7CisKKwlzdHJ1Y3QgcnhycGNfY29ubmVjdGlvbiAqY29ubjsKKwlpbnQgZXJyOworCisJX2VudGVyKCIlcCIsIHBlZXIpOworCisJLyogdGhlcmUgc2hvdWxkbid0IGJlIGFueSBhY3RpdmUgY29ubnMgcmVtYWluaW5nICovCisJaWYgKCFsaXN0X2VtcHR5KCZwZWVyLT5jb25uX2FjdGl2ZSkpCisJCUJVRygpOworCisJLyogbWFudWFsbHkgdGltZW91dCBhbGwgY29ubnMgaW4gdGhlIGdyYXZleWFyZCAqLworCXNwaW5fbG9jaygmcGVlci0+Y29ubl9neWxvY2spOworCXdoaWxlICghbGlzdF9lbXB0eSgmcGVlci0+Y29ubl9ncmF2ZXlhcmQpKSB7CisJCWNvbm4gPSBsaXN0X2VudHJ5KHBlZXItPmNvbm5fZ3JhdmV5YXJkLm5leHQsCisJCQkJICBzdHJ1Y3QgcnhycGNfY29ubmVjdGlvbiwgbGluayk7CisJCWVyciA9IHJ4cnBjX2tyeHRpbW9kX2RlbF90aW1lcigmY29ubi0+dGltZW91dCk7CisJCXNwaW5fdW5sb2NrKCZwZWVyLT5jb25uX2d5bG9jayk7CisKKwkJaWYgKGVyciA9PSAwKQorCQkJcnhycGNfY29ubl9kb190aW1lb3V0KGNvbm4pOworCisJCXNwaW5fbG9jaygmcGVlci0+Y29ubl9neWxvY2spOworCX0KKwlzcGluX3VubG9jaygmcGVlci0+Y29ubl9neWxvY2spOworCis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30gLyogZW5kIHJ4cnBjX2Nvbm5fbmV3bXNnKCkgKi8KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworLyoKKyAqIGZyZWUgYSBtZXNzYWdlCisgKi8KK3ZvaWQgX19yeHJwY19wdXRfbWVzc2FnZShzdHJ1Y3QgcnhycGNfbWVzc2FnZSAqbXNnKQoreworCWludCBsb29wOworCisJX2VudGVyKCIlcCAjJWQiLCBtc2csIGF0b21pY19yZWFkKCZyeHJwY19tZXNzYWdlX2NvdW50KSk7CisKKwlpZiAobXNnLT5wa3QpCisJCWtmcmVlX3NrYihtc2ctPnBrdCk7CisJcnhycGNfcHV0X2Nvbm5lY3Rpb24obXNnLT5jb25uKTsKKworCWZvciAobG9vcCA9IDA7IGxvb3AgPCA4OyBsb29wKyspCisJCWlmICh0ZXN0X2JpdChsb29wLCAmbXNnLT5kZnJlZSkpCisJCQlrZnJlZShtc2ctPmRhdGFbbG9vcF0uaW92X2Jhc2UpOworCisJX19SWEFDQ1QoYXRvbWljX2RlYygmcnhycGNfbWVzc2FnZV9jb3VudCkpOworCWtmcmVlKG1zZyk7CisKKwlfbGVhdmUoIiIpOworfSAvKiBlbmQgX19yeHJwY19wdXRfbWVzc2FnZSgpICovCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKy8qCisgKiBzZW5kIGEgbWVzc2FnZSBvdXQgdGhyb3VnaCB0aGUgdHJhbnNwb3J0IGVuZHBvaW50CisgKi8KK2ludCByeHJwY19jb25uX3NlbmRtc2coc3RydWN0IHJ4cnBjX2Nvbm5lY3Rpb24gKmNvbm4sCisJCSAgICAgICBzdHJ1Y3QgcnhycGNfbWVzc2FnZSAqbXNnKQoreworCXN0cnVjdCBtc2doZHIgbXNnaGRyOworCWludCByZXQ7CisKKwlfZW50ZXIoI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jbHVkZSA8bGludXgvc3BpbmxvY2suaD4KKyNpbmNsdWRlIDxsaW51eC9pbml0Lmg+CisjaW5jbHVkZSA8cnhycGMva3J4aW9kLmg+CisjaW5jbHVkZSA8cnhycGMvdHJhbnNwb3J0Lmg+CisjaW5jbHVkZSA8cnhycGMvcGVlci5oPgorI2luY2x1ZGUgPHJ4cnBjL2NhbGwuaD4KKyNpbmNsdWRlICJpbnRlcm5hbC5oIgorCitzdGF0aWMgREVDTEFSRV9XQUlUX1FVRVVFX0hFQUQocnhycGNfa3J4aW9kX3NsZWVwcSk7CitzdGF0aWMgREVDTEFSRV9DT01QTEVUSU9OKHJ4cnBjX2tyeGlvZF9kZWFkKTsKKworc3RhdGljIGF0b21pY190IHJ4cnBjX2tyeGlvZF9xY291bnQgPSBBVE9NSUNfSU5JVCgwKTsKKworc3RhdGljIExJU1RfSEVBRChyeHJwY19rcnhpb2RfdHJhbnNwb3J0cSk7CitzdGF0aWMgREVGSU5FX1NQSU5MT0NLKHJ4cnBjX2tyeGlvZF90cmFuc3BvcnRxX2xvY2spOworCitzdGF0aWMgTElTVF9IRUFEKHJ4cnBjX2tyeGlvZF9jYWxscSk7CitzdGF0aWMgREVGSU5FX1NQSU5MT0NLKHJ4cnBjX2tyeGlvZF9jYWxscV9sb2NrKTsKKworc3RhdGljIHZvbGF0aWxlIGludCByeHJwY19rcnhpb2RfZGllOworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisvKgorICogUnggSS9PIGRhZW1vbgorICovCitzdGF0aWMgaW50IHJ4cnBjX2tyeGlvZCh2b2lkICphcmcpCit7CisJREVDTEFSRV9XQUlUUVVFVUUoa3J4aW9kLGN1cnJlbnQpOworCisJcHJpbnRrKCJTdGFydGVkIGtyeGlvZCAlZFxuIixjdXJyZW50LT5waWQpOworCisJZGFlbW9uaXplKCJrcnhpb2QiKTsKKworCS8qIGxvb3AgYXJv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JfSB3aGlsZSAoIXJ4cnBjX2tyeGlvZF9kaWUpOworCisJLyogYW5kIHRoYXQncyBhbGwgKi8KKwljb21wbGV0ZV9hbmRfZXhpdCgmcnhycGNfa3J4aW9kX2RlYWQsIDApOworCit9IC8qIGVuZCByeHJwY19rcnhpb2QoKSAqLworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisvKgorICogc3RhcnQgdXAgYSBrcnhpb2QgZGFlbW9uCisgKi8KK2ludCBfX2luaXQgcnhycGNfa3J4aW9kX2luaXQodm9pZCkKK3sKKwlyZXR1cm4ga2VybmVsX3RocmVhZChyeHJwY19rcnhpb2QsIE5VTEwsIDApOworCit9IC8qIGVuZCByeHJwY19rcnhpb2RfaW5pdCgpICovCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKy8qCisgKiBraWxsIHRoZSBrcnhpb2QgZGFlbW9uIGFuZCB3YWl0IGZvciBpdCB0byBjb21wbGV0ZQorICovCit2b2lkIHJ4cnBjX2tyeGlvZF9raWxsKHZvaWQpCit7CisJcnhycGNfa3J4aW9kX2RpZSA9IDE7CisJd2FrZV91cF9hbGwoJnJ4cnBjX2tyeGlvZF9zbGVlcHEpOworCXdhaXRfZm9yX2NvbXBsZXRpb24oJnJ4cnBjX2tyeGlvZF9kZWFkKTsKKworfSAvKiBlbmQgcnhycGNfa3J4aW9kX2tpbGwoKSAqLworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisvKgorICogcXVldWUgYSB0cmFuc3BvcnQgZm9yIGF0dGVudGlvbiBieSBrcnhpb2QKKyAqLwordm9pZCByeHJwY19rcnhpb2RfcXVldWVfdHJhbnNwb3J0KHN0cnVjdCByeHJwY190cmFuc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KioqKioqKioqKioqKi8KKy8qCisgKiBzdGFydCB1cCBhIGtyeHNlY2QgZGFlbW9uCisgKi8KK2ludCBfX2luaXQgcnhycGNfa3J4c2VjZF9pbml0KHZvaWQpCit7CisJcmV0dXJuIGtlcm5lbF90aHJlYWQocnhycGNfa3J4c2VjZCwgTlVMTCwgMCk7CisKK30gLyogZW5kIHJ4cnBjX2tyeHNlY2RfaW5pdCgpICovCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKy8qCisgKiBraWxsIHRoZSBrcnhzZWNkIGRhZW1vbiBhbmQgd2FpdCBmb3IgaXQgdG8gY29tcGxldGUKKyAqLwordm9pZCByeHJwY19rcnhzZWNkX2tpbGwodm9pZCkKK3sKKwlyeHJwY19rcnhzZWNkX2RpZSA9IDE7CisJd2FrZV91cF9hbGwoJnJ4cnBjX2tyeHNlY2Rfc2xlZXBxKTsKKwl3YWl0X2Zvcl9jb21wbGV0aW9uKCZyeHJwY19rcnhzZWNkX2RlYWQpOworCit9IC8qIGVuZCByeHJwY19rcnhzZWNkX2tpbGwoKSAqLworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisvKgorICogY2xlYXIgYWxsIHBlbmRpbmcgaW5jb21pbmcgY2FsbHMgZm9yIHRoZSBzcGVjaWZpZWQgdHJhbnNwb3J0CisgKi8KK3ZvaWQgcnhycGNfa3J4c2VjZF9jbGVhcl90cmFuc3BvcnQoc3RydWN0IHJ4cnBjX3RyYW5zcG9ydCAqdHJhbnMpCit7CisJTElTVF9IRUFEKHRtcCk7CisKKwlzdHJ1Y3QgcnhycGNfbWVzc2FnZSAqbXNnOworCXN0cnVjdCBsaXN0X2hlYWQgKl9wLCAqX247CisKKwlfZW50ZXIoIiVwIix0cmFucyk7CisKKwkvKiBtb3ZlIGFsbCB0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J1Y3QgcnhycGNfbWVzc2FnZSAqbXNnKQoreworCV9lbnRlcigiJXAiLCBtc2cpOworCisJLyogcXVldWUgZm9yIHByb2Nlc3NpbmcgYnkga3J4c2VjZCAqLworCXNwaW5fbG9jaygmcnhycGNfa3J4c2VjZF9pbml0bXNncV9sb2NrKTsKKworCWlmICghcnhycGNfa3J4c2VjZF9kaWUpIHsKKwkJcnhycGNfZ2V0X21lc3NhZ2UobXNnKTsKKwkJbGlzdF9hZGRfdGFpbCgmbXNnLT5saW5rLCAmcnhycGNfa3J4c2VjZF9pbml0bXNncSk7CisJCWF0b21pY19pbmMoJnJ4cnBjX2tyeHNlY2RfcWNvdW50KTsKKwl9CisKKwlzcGluX3VubG9jaygmcnhycGNfa3J4c2VjZF9pbml0bXNncV9sb2NrKTsKKworCXdha2VfdXAoJnJ4cnBjX2tyeHNlY2Rfc2xlZXBxKTsKKworCV9sZWF2ZSgiIik7Cit9IC8qIGVuZCByeHJwY19rcnhzZWNkX3F1ZXVlX2luY29taW5nX2NhbGwoKSAqLworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisvKgorICogcHJvY2VzcyB0aGUgaW5pdGlhbCBtZXNzYWdlIG9mIGFuIGluY29taW5nIGNhbGwKKyAqLwordm9pZCByeHJwY19rcnhzZWNkX3Byb2Nlc3NfaW5jb21pbmdfY2FsbChzdHJ1Y3QgcnhycGNfbWVzc2FnZSAqbXNnKQoreworCXN0cnVjdCByeHJwY190cmFuc3BvcnQgKnRyYW5zID0gbXNnLT50cmFuczsKKwlzdHJ1Y3QgcnhycGNfc2VydmljZSAqc3J2OworCXN0cnVjdCByeHJwY19jYWxsICpjYWxsOworCXN0cnVjdCBsaXN0X2hlYWQgKl9wOworCXVuc2lnbmVkIHNob3J0IHNpZDsKKwlpbnQgcmV0OworCisJX2VudGVyKCIlcHt0cj0lcH0iLCBtc2csIHRyYW5zKTsKK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KioqKioqKioqKioqKioqKioqKioqKi8KKy8qCisgKiBzdGFydCB0aGUgdGltZW91dCBkYWVtb24KKyAqLworaW50IHJ4cnBjX2tyeHRpbW9kX3N0YXJ0KHZvaWQpCit7CisJaW50IHJldDsKKworCXJldCA9IGtlcm5lbF90aHJlYWQoa3J4dGltb2QsIE5VTEwsIDApOworCWlmIChyZXQgPCAwKQorCQlyZXR1cm4gcmV0OworCisJd2FpdF9mb3JfY29tcGxldGlvbigma3J4dGltb2RfYWxpdmUpOworCisJcmV0dXJuIHJldDsKK30gLyogZW5kIHJ4cnBjX2tyeHRpbW9kX3N0YXJ0KCkgKi8KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworLyoKKyAqIHN0b3AgdGhlIHRpbWVvdXQgZGFlbW9uCisgKi8KK3ZvaWQgcnhycGNfa3J4dGltb2Rfa2lsbCh2b2lkKQoreworCS8qIGdldCByaWQgb2YgbXkgZGFlbW9uICovCisJa3J4dGltb2RfZGllID0gMTsKKwl3YWtlX3VwKCZrcnh0aW1vZF9zbGVlcHEpOworCXdhaXRfZm9yX2NvbXBsZXRpb24oJmtyeHRpbW9kX2RlYWQpOworCit9IC8qIGVuZCByeHJwY19rcnh0aW1vZF9raWxsKCkgKi8KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworLyoKKyAqIHRpbWVvdXQgcHJvY2Vzc2luZyBkYWVtb24KKyAqLworc3RhdGljIGludCBrcnh0aW1vZCh2b2lkICphcmcpCit7CisJREVDTEFSRV9XQUlUUVVFVUUobXlzZWxmLCBjdXJyZW50KTsKKworCXJ4cnBjX3RpbWVyX3QgKnRpbWVyOworCisJcHJpbnRrKCJTdGFydGVkIGtyeHRpbW9kICVkXG4iLCBjdXJyZW50LT5waWQpOworCisJZGFlbW9uaXplKCJrcnh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KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKy8qCisgKiAocmUtKXF1ZXVlIGEgdGltZXIKKyAqLwordm9pZCByeHJwY19rcnh0aW1vZF9hZGRfdGltZXIocnhycGNfdGltZXJfdCAqdGltZXIsIHVuc2lnbmVkIGxvbmcgdGltZW91dCkKK3sKKwlzdHJ1Y3QgbGlzdF9oZWFkICpfcDsKKwlyeHJwY190aW1lcl90ICpwdGltZXI7CisKKwlfZW50ZXIoIiVwLCVsdSIsIHRpbWVyLCB0aW1lb3V0KTsKKworCXNwaW5fbG9jaygma3J4dGltb2RfbG9jayk7CisKKwlsaXN0X2RlbCgmdGltZXItPmxpbmspOworCisJLyogdGhlIHRpbWVyIHdhcyBkZWZlcnJlZCBvciByZXNldCAtIHB1dCBpdCBiYWNrIGluIHRoZSBxdWV1ZSBhdCB0aGUKKwkgKiByaWdodCBwbGFjZSAqLworCXRpbWVyLT50aW1vX2ppZiA9IGppZmZpZXMgKyB0aW1lb3V0OworCisJbGlzdF9mb3JfZWFjaChfcCwgJmtyeHRpbW9kX2xpc3QpIHsKKwkJcHRpbWVyID0gbGlzdF9lbnRyeShfcCwgcnhycGNfdGltZXJfdCwgbGluayk7CisJCWlmICh0aW1lX2JlZm9yZSh0aW1lci0+dGltb19qaWYsIHB0aW1lci0+dGltb19qaWYpKQorCQkJYnJlYWs7CisJfQorCisJbGlzdF9hZGRfdGFpbCgmdGltZXItPmxpbmssIF9wKTsgLyogaW5zZXJ0IGJlZm9yZSBzdG9wcGluZyBwb2ludCAqLworCisJc3Bpbl91bmxvY2soJmtyeHRpbW9kX2xvY2spOworCisJd2FrZV91cCgma3J4dGltb2Rfc2xlZXBxKTsKKworCV9sZWF2ZSgiIik7Cit9IC8qIGVuZCByeHJwY19rcnh0aW1vZF9hZGRfdGltZXIoKSAqLworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKio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KyNpZiAwCit2b2lkIF9fY3lnX3Byb2ZpbGVfZnVuY19lbnRlciAodm9pZCAqdGhpc19mbiwgdm9pZCAqY2FsbF9zaXRlKQorX19hdHRyaWJ1dGVfXygobm9faW5zdHJ1bWVudF9mdW5jdGlvbikpOworCit2b2lkIF9fY3lnX3Byb2ZpbGVfZnVuY19lbnRlciAodm9pZCAqdGhpc19mbiwgdm9pZCAqY2FsbF9zaXRlKQoreworICAgICAgIGFzbSB2b2xhdGlsZSgiICBtb3ZsICAgICUlZXNwLCUlZWRpICAgICBcbiIKKyAgICAgICAgICAgICAgICAgICAgIiAgYW5kbCAgICAlMCwlJWVkaSAgICAgICAgXG4iCisgICAgICAgICAgICAgICAgICAgICIgIGFkZGwgICAgJTEsJSVlZGkgICAgICAgIFxuIgorICAgICAgICAgICAgICAgICAgICAiICBtb3ZsICAgICUlZXNwLCUlZWN4ICAgICBcbiIKKyAgICAgICAgICAgICAgICAgICAgIiAgc3VibCAgICAlJWVkaSwlJWVjeCAgICAgXG4iCisgICAgICAgICAgICAgICAgICAgICIgIHNocmwgICAgJDIsJSVlY3ggICAgICAgIFxuIgorICAgICAgICAgICAgICAgICAgICAiICBtb3ZsICAgICQweGVkZWRlZGVkLCUlZWF4ICAgICBcbiIKKyAgICAgICAgICAgICAgICAgICAgIiAgcmVwIHN0b3NsICAgICAgICAgICAgICAgXG4iCisgICAgICAgICAgICAgICAgICAgIDoKKyAgICAgICAgICAgICAgICAgICAgOiAiaSIofihUSFJFQURfU0laRS0xKSksICJpIihzaXplb2Yoc3RydWN0IHRocmVhZF9pbmZvKSkKKyAgICAgICAgICAgICAgICAgICAgOiAiZWF4IiwgImVjeCIsICJlZGkiLCAibWVtb3J5IiwgImNjIgorICAgICAgICAgICAgICAgICAgICApOworfQorCit2b2lkIF9fY3lnX3Byb2ZpbGVfZnVuY19leGl0KHZvaWQgKnRoaXNfZm4sIHZvaWQgKmNhbGxfc2l0ZSkKK19fYXR0cmlidXRlX18oKG5vX2luc3RydW1lbnRfZnVuY3Rpb24pKTsKKwordm9pZCBfX2N5Z19wcm9maWxlX2Z1bmNfZXhpdCh2b2lkICp0aGlzX2ZuLCB2b2lkICpjYWxsX3NpdGUpCit7CisgICAgICAgYXNtIHZvbGF0aWxlKCIgIG1vdmwgICAgJSVlc3AsJSVlZGkgICAgIFxuIgorICAgICAgICAgICAgICAgICAgICAiICBhbmRsICAgICUwLCUlZWRpICAgICAgICBcbiIKKyAgICAgICAgICAgICAgICAgICAgIiAgYWRkbCAgICAlMSwlJWVkaSAgICAgICAgXG4iCisgICAgICAgICAgICAgICAgICAgICIgIG1vdmwgICAgJSVlc3AsJSVlY3ggICAgIFxuIgorICAgICAgICAgICAgICAgICAgICAiICBzdWJsICAgICUlZWRpLCUlZWN4ICAgICBcbiIKKyAgICAgICAgICAgICAgICAgICAgIiAgc2hybCAgICAkMiwlJWVjeCAgICAgICAgXG4iCisgICAgICAgICAgICAgICAgICAgICIgIG1vdmwgICAgJDB4ZGFkYWRhZGEsJSVlYXggICAgIFxuIgorICAgICAgICAgICAgICAgICAgICAiICByZXAgc3Rvc2wgICAgICAgICAgICAgICBcbiIKKyAgICAgICAgICAgICAgICAgICAgOgorICAgICAgICAgICAgICAgICAgICA6ICJpIih+KFRIUkVBRF9TSVpFLTEpKSwgImkiKHNpemVvZihzdHJ1Y3QgdGhyZWFkX2luZm8pKQorICAgICAgICAgICAgICAgICAgICA6ICJlYXgiLCAiZWN4IiwgImVkaSIsICJtZW1vcnkiLCAiY2MiCisgICAgICAgICAgICAgICAgICAgICk7Cit9CisjZW5kaWYKZGlmZiAtLWdpdCBhL25ldC9yeHJwYy9wZWVyLmMgYi9uZXQvcnhycGMvcGVlci5jCm5ldyBmaWxlIG1vZGUgMTAwNjQ0CmluZGV4IDAwMDAwMDAuLmVkMzhmNWIKLS0tIC9kZXYvbnVsbAorKysgYi9uZXQvcnhycGMvcGVlci5jCkBAIC0wLDAgKzEsMzk5IEBACisvKiBwZWVyLmM6IFJ4IFJQQ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woYXRvbWljX3QgcnhycGNfcGVlcl9jb3VudCk7CitMSVNUX0hFQUQocnhycGNfcGVlcnMpOworREVDTEFSRV9SV1NFTShyeHJwY19wZWVyc19zZW0pOwordW5zaWduZWQgbG9uZyByeHJwY19wZWVyX3RpbWVvdXQgPSAxMiAqIDYwICogNjA7CisKK3N0YXRpYyB2b2lkIHJ4cnBjX3BlZXJfZG9fdGltZW91dChzdHJ1Y3QgcnhycGNfcGVlciAqcGVlcik7CisKK3N0YXRpYyB2b2lkIF9fcnhycGNfcGVlcl90aW1lb3V0KHJ4cnBjX3RpbWVyX3QgKnRpbWVyKQoreworCXN0cnVjdCByeHJwY19wZWVyICpwZWVyID0KKwkJbGlzdF9lbnRyeSh0aW1lciwgc3RydWN0IHJ4cnBjX3BlZXIsIHRpbWVvdXQpOworCisJX2RlYnVnKCJSeCBQRUVSIFRJTUVPVVQgWyVwe3U9JWR9XSIsIHBlZXIsIGF0b21pY19yZWFkKCZwZWVyLT51c2FnZSkpOworCisJcnhycGNfcGVlcl9kb190aW1lb3V0KHBlZXIpOworfQorCitzdGF0aWMgY29uc3Qgc3RydWN0IHJ4cnBjX3RpbWVyX29wcyByeHJwY19wZWVyX3RpbWVyX29wcyA9IHsKKwkudGltZWRfb3V0CT0gX19yeHJwY19wZWVyX3RpbWVvdXQsCit9OworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisvKgorICogY3JlYXRlIGEgcGVlciByZWNvcmQKKyAqLworc3RhdGljIGludCBfX3J4cnBjX2NyZWF0ZV9wZWVyKHN0cnVjdCByeHJwY190cmFuc3BvcnQgKnRyYW5zLCBfX2JlMzIgYWRkciwKKwkJCSAgICAgICBzdHJ1Y3QgcnhycGNfcGVlciAqKl9wZWVyKQoreworCXN0cnVjdCByeHJwY19wZWVyICpwZWVyOworCisJX2VudGVyKCIlcCwlMDh4IiwgdHJhbnMsIG50b2hsKGFkZ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dWNjZXNzX3V3ZnJlZTsKKworfSAvKiBlbmQgcnhycGNfcGVlcl9sb29rdXAoKSAqLworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisvKgorICogZmluaXNoIHdpdGggYSBwZWVyIHJlY29yZAorICogLSBpdCBnZXRzIHNlbnQgdG8gdGhlIGdyYXZleWFyZCBmcm9tIHdoZXJlIGl0IGNhbiBiZSByZXN1cnJlY3RlZCBvciB0aW1lZAorICogICBvdXQKKyAqLwordm9pZCByeHJwY19wdXRfcGVlcihzdHJ1Y3QgcnhycGNfcGVlciAqcGVlcikKK3sKKwlzdHJ1Y3QgcnhycGNfdHJhbnNwb3J0ICp0cmFucyA9IHBlZXItPnRyYW5zOworCisJX2VudGVyKCIlcHtjYz0lZCBhPSUwOHh9IiwKKwkgICAgICAgcGVlciwKKwkgICAgICAgYXRvbWljX3JlYWQoJnBlZXItPmNvbm5fY291bnQpLAorCSAgICAgICBudG9obChwZWVyLT5hZGRyLnNfYWRkcikpOworCisJLyogc2FuaXR5IGNoZWNrICovCisJaWYgKGF0b21pY19yZWFkKCZwZWVyLT51c2FnZSkgPD0gMCkKKwkJQlVHKCk7CisKKwl3cml0ZV9sb2NrKCZ0cmFucy0+cGVlcl9sb2NrKTsKKwlzcGluX2xvY2soJnRyYW5zLT5wZWVyX2d5bG9jayk7CisJaWYgKGxpa2VseSghYXRvbWljX2RlY19hbmRfdGVzdCgmcGVlci0+dXNhZ2UpKSkgeworCQlzcGluX3VubG9jaygmdHJhbnMtPnBlZXJfZ3lsb2NrKTsKKwkJd3JpdGVfdW5sb2NrKCZ0cmFucy0+cGVlcl9sb2NrKTsKKwkJX2xlYXZlKCIiKTsKKwkJcmV0dXJuOworCX0KKworCS8qIG1vdmUgdG8gZ3JhdmV5YXJkIHF1ZXVlICovCisJbGlzdF9kZWwoJnBlZXItPmxpbmspOworCXdyaXRlX3VubG9jaygmdHJhbnMtPnBlZXJfbG9jayk7CisKKwlsaXN0X2FkZF90YWlsKCZwZWVyLT5saW5rLCAmdHJhbnMtPnBlZXJfZ3JhdmV5YXJkKTsKKworCUJVR19PTighbGlzdF9lbXB0eSgmcGVlci0+Y29ubl9hY3RpdmUpKTsKKworCXJ4cnBjX2tyeHRpbW9kX2FkZF90aW1lcigmcGVlci0+dGltZW91dCwgcnhycGNfcGVlcl90aW1lb3V0ICogSFopOworCisJc3Bpbl91bmxvY2soJnRyYW5zLT5wZWVyX2d5bG9jayk7CisKKwlyeHJwY19wdXRfdHJhbnNwb3J0KHRyYW5zKTsKKworCV9sZWF2ZSgiIFtraWxsZWRdIik7Cit9IC8qIGVuZCByeHJwY19wdXRfcGVlcigpICovCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKy8qCisgKiBoYW5kbGUgYSBwZWVyIHRpbWluZyBvdXQgaW4gdGhlIGdyYXZleWFyZAorICogLSBjYWxsZWQgZnJvbSBrcnh0aW1vZAorICovCitzdGF0aWMgdm9pZCByeHJwY19wZWVyX2RvX3RpbWVvdXQoc3RydWN0IHJ4cnBjX3BlZXIgKnBlZXIpCit7CisJc3RydWN0IHJ4cnBjX3RyYW5zcG9ydCAqdHJhbnMgPSBwZWVyLT50cmFuczsKKworCV9lbnRlcigiJXB7dT0lZCBjYz0lZCBhPSUwOHh9IiwKKwkgICAgICAgcGVlciwKKwkgICAgICAgYXRvbWljX3JlYWQoJnBlZXItPnVzYWdlKSwKKwkgICAgICAgYXRvbWljX3JlYWQoJnBlZXItPmNvbm5fY291bnQpLAorCSAgICAgICBudG9obChwZWVyLT5hZGRyLnNfYWRkcikpOworCisJQlVHX09OKGF0b21pY19yZWFkKCZwZWVyLT51c2FnZSkgPCAwKTsKKworCS8qIHJlbW92ZSBmcm9tIGdyYXZleWFyZCBpZiBzdGlsbCBkZWFkICovCisJc3Bpbl9sb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CSJsb2NfYWJ0IiwKKwkicm10X2FidCIsCisJImxvY19lcnIiLAorCSJybXRfZXJyIgorfTsKKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworLyoKKyAqIGluaXRpYWxpc2UgdGhlIC9wcm9jL25ldC9yeHJwYy8gZGlyZWN0b3J5CisgKi8KK2ludCByeHJwY19wcm9jX2luaXQodm9pZCkKK3sKKwlzdHJ1Y3QgcHJvY19kaXJfZW50cnkgKnA7CisKKwlwcm9jX3J4cnBjID0gcHJvY19ta2RpcigicnhycGMiLCBwcm9jX25ldCk7CisJaWYgKCFwcm9jX3J4cnBjKQorCQlnb3RvIGVycm9yOworCXByb2NfcnhycGMtPm93bmVyID0gVEhJU19NT0RVTEU7CisKKwlwID0gY3JlYXRlX3Byb2NfZW50cnkoImNhbGxzIiwgMCwgcHJvY19yeHJwYyk7CisJaWYgKCFwKQorCQlnb3RvIGVycm9yX3Byb2M7CisJcC0+cHJvY19mb3BzID0gJnJ4cnBjX3Byb2NfY2FsbHNfZm9wczsKKwlwLT5vd25lciA9IFRISVNfTU9EVUxFOworCisJcCA9IGNyZWF0ZV9wcm9jX2VudHJ5KCJjb25uZWN0aW9ucyIsIDAsIHByb2NfcnhycGMpOworCWlmICghcCkKKwkJZ290byBlcnJvcl9jYWxsczsKKwlwLT5wcm9jX2ZvcHMgPSAmcnhycGNfcHJvY19jb25uc19mb3BzOworCXAtPm93bmVyID0gVEhJU19NT0RVTEU7CisKKwlwID0gY3JlYXRlX3Byb2NfZW50cnkoInBlZXJzIiwgMCwgcHJvY19yeHJwYyk7CisJaWYgKCFwKQorCQlnb3RvIGVycm9yX2NhbGxzOworCXAtPnByb2NfZm9wcyA9ICZyeHJwY19wcm9jX3BlZXJzX2ZvcHM7CisJcC0+b3duZXIgPSBUSElTX01PRFVMRTsKKworCXAgPSBjcmVhdGVfcHJvY19lbnRyeSgidHJhbnNwb3J0cyIsIDAsIHByb2NfcnhycGMpOworCWlmICghcCkKKwkJZ290byBlcnJvcl9jb25uczsKKwlwLT5wcm9jX2ZvcHMgPSAmcnhycGNfcHJvY190cmFuc3BvcnRzX2ZvcHM7CisJcC0+b3duZXIgPSBUSElTX01PRFVMRTsKKworCXJldHVybiAwOworCisgZXJyb3JfY29ubnM6CisJcmVtb3ZlX3Byb2NfZW50cnkoImNvbm5lY3Rpb25zIiwgcHJvY19yeHJwYyk7CisgZXJyb3JfY2FsbHM6CisJcmVtb3ZlX3Byb2NfZW50cnkoImNhbGxzIiwgcHJvY19yeHJwYyk7CisgZXJyb3JfcHJvYzoKKwlyZW1vdmVfcHJvY19lbnRyeSgicnhycGMiLCBwcm9jX25ldCk7CisgZXJyb3I6CisJcmV0dXJuIC1FTk9NRU07Cit9IC8qIGVuZCByeHJwY19wcm9jX2luaXQoKSAqLworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisvKgorICogY2xlYW4gdXAgdGhlIC9wcm9jL25ldC9yeHJwYy8gZGlyZWN0b3J5CisgKi8KK3ZvaWQgcnhycGNfcHJvY19jbGVhbnVwKHZvaWQpCit7CisJcmVtb3ZlX3Byb2NfZW50cnkoInRyYW5zcG9ydHMiLCBwcm9jX3J4cnBjKTsKKwlyZW1vdmVfcHJvY19lbnRyeSgicGVlcnMiLCBwcm9jX3J4cnBjKTsKKwlyZW1vdmVfcHJvY19lbnRyeSgiY29ubmVjdGlvbnMiLCBwcm9jX3J4cnBjKTsKKwlyZW1vdmVfcHJvY19lbnRyeSgiY2FsbHMiLCBwcm9jX3J4cnBjKTsKKworCXJlbW92ZV9wcm9jX2VudHJ5KCJyeHJwYyIsIHByb2NfbmV0KTsKKworfSAvKiBlbmQgcnhycGNfcHJvY19jbGVhbnVwKCkgKi8KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq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worCisJLyogYWxsb3cgZm9yIHRoZSBoZWFkZXIgbGluZSAqLworCWlmICghcG9zKQorCQlyZXR1cm4gU0VRX1NUQVJUX1RPS0VOOworCXBvcy0tOworCisJLyogZmluZCB0aGUgbid0aCBlbGVtZW50IGluIHRoZSBsaXN0ICovCisJbGlzdF9mb3JfZWFjaChfcCwgJnJ4cnBjX3Byb2NfdHJhbnNwb3J0cykKKwkJaWYgKCFwb3MtLSkKKwkJCWJyZWFrOworCisJcmV0dXJuIF9wICE9ICZyeHJwY19wcm9jX3RyYW5zcG9ydHMgPyBfcCA6IE5VTEw7Cit9IC8qIGVuZCByeHJwY19wcm9jX3RyYW5zcG9ydHNfc3RhcnQoKSAqLworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisvKgorICogbW92ZSB0byBuZXh0IGNhbGwgaW4gdHJhbnNwb3J0cyBsaXN0CisgKi8KK3N0YXRpYyB2b2lkICpyeHJwY19wcm9jX3RyYW5zcG9ydHNfbmV4dChzdHJ1Y3Qgc2VxX2ZpbGUgKnAsIHZvaWQgKnYsIGxvZmZfdCAqcG9zKQoreworCXN0cnVjdCBsaXN0X2hlYWQgKl9wOworCisJKCpwb3MpKys7CisKKwlfcCA9IHY7CisJX3AgPSAodiA9PSBTRVFfU1RBUlRfVE9LRU4pID8gcnhycGNfcHJvY190cmFuc3BvcnRzLm5leHQgOiBfcC0+bmV4dDsKKworCXJldHVybiBfcCAhPSAmcnhycGNfcHJvY190cmFuc3BvcnRzID8gX3AgOiBOVUxMOworfSAvKiBlbmQgcnhycGNfcHJvY190cmFuc3BvcnRzX25leHQoKSAqLworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisvKgorICogY2xlYW4gdXAgYWZ0ZXIgcmVhZGluZyBmcm9tIHRoZSB0cmFuc3BvcnRzIGxpc3QKKyAqLworc3RhdGljIHZvaWQgcnhycGNfcHJvY190cmFuc3BvcnRzX3N0b3Aoc3RydWN0IHNlcV9maWxlICpwLCB2b2lkICp2KQoreworCXVwX3JlYWQoJnJ4cnBjX3Byb2NfdHJhbnNwb3J0c19zZW0pOworCit9IC8qIGVuZCByeHJwY19wcm9jX3RyYW5zcG9ydHNfc3RvcCgpICovCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKy8qCisgKiBkaXNwbGF5IGEgaGVhZGVyIGxpbmUgZm9sbG93ZWQgYnkgYSBsb2FkIG9mIGNhbGwgbGluZXMKKyAqLworc3RhdGljIGludCByeHJwY19wcm9jX3RyYW5zcG9ydHNfc2hvdyhzdHJ1Y3Qgc2VxX2ZpbGUgKm0sIHZvaWQgKnYpCit7CisJc3RydWN0IHJ4cnBjX3RyYW5zcG9ydCAqdHJhbnMgPQorCQlsaXN0X2VudHJ5KHYsIHN0cnVjdCByeHJwY190cmFuc3BvcnQsIHByb2NfbGluayk7CisKKwkvKiBkaXNwbGF5IGhlYWRlciBvbiBsaW5lIDEgKi8KKwlpZiAodiA9PSBTRVFfU1RBUlRfVE9LRU4pIHsKKwkJc2VxX3B1dHMobSwgIkxPQ0FMIFVTRVxuIik7CisJCXJldHVybiAwOworCX0KKworCS8qIGRpc3BsYXkgb25lIHRyYW5zcG9ydCBwZXIgbGluZSBvbiBzdWJzZXF1ZW50IGxpbmVzICovCisJc2VxX3ByaW50ZihtLCAiJTVodSAlM2RcbiIsCisJCSAgIHRyYW5zLT5wb3J0LAorCQkgICBhdG9taWNfcmVhZCgmdHJhbnMtPnVzYWdlKQorCQkgICApOworCisJcmV0dXJuIDA7Cit9IC8qIGVuZCByeHJwY19wcm9jX3RyYW5zcG9ydHNfc2hvdygpICovCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKy8qCisgKiBvcGVuICIvcHJvYy9uZXQvcnhycGMvcGVlcnMiIHdoaWNoIHByb3ZpZGVzIGEgc3VtbWFyeSBvZiBleHRhbnQgcGVlcnMKKyAqLworc3RhdGljIGludCByeHJwY19wcm9jX3BlZXJzX29wZW4oc3RydWN0IGlub2RlICppbm9kZSwgc3RydWN0IGZpbGUgKmZpbGUpCit7CisJc3RydWN0IHNlcV9maWxlICptOworCWludCByZXQ7CisKKwlyZXQgPSBzZXFfb3BlbihmaWxlLCAmcnhycGNfcHJvY19wZWVyc19vcHMpOworCWlmIChyZXQgPCAwKQorCQlyZXR1cm4gcmV0OworCisJbSA9IGZpbGUtPnByaXZhdGVfZGF0YTsKKwltLT5wcml2YXRlID0gUERFKGlub2RlKS0+ZGF0YTsKKworCXJldHVybiAwOworfSAvKiBlbmQgcnhycGNfcHJvY19wZWVyc19vcGVuKCkgKi8KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworLyoKKyAqIHNldCB1cCB0aGUgaXRlcmF0b3IgdG8gc3RhcnQgcmVhZGluZyBmcm9tIHRoZSBwZWVycyBsaXN0IGFuZCByZXR1cm4gdGhlCisgKiBmaXJzdCBpdGVtCisgKi8KK3N0YXRpYyB2b2lkICpyeHJwY19wcm9jX3BlZXJzX3N0YXJ0KHN0cnVjdCBzZXFfZmlsZSAqbSwgbG9mZl90ICpfcG9zKQoreworCXN0cnVjdCBsaXN0X2hlYWQgKl9wOworCWxvZmZfdCBwb3MgPSAqX3BvczsKKworCS8qIGxvY2sgdGhlIGxpc3QgYWdhaW5zdCBtb2RpZmljYXRpb24gKi8KKwlkb3duX3JlYWQoJnJ4cnBjX3BlZXJzX3NlbSk7CisKKwkvKiBhbGxvdyBmb3IgdGhlIGhlYWRlciBsaW5lICovCisJaWYgKCFwb3MpCisJCXJldHVybiBTRVFfU1RBUlRfVE9LRU47CisJcG9zLS07CisKKwkvKiBmaW5kIHRoZSBuJ3RoIGVsZW1lbnQgaW4gdGhlIGxpc3QgKi8KKwlsaXN0X2Zvcl9lYWNoKF9wLCAmcnhycGNfcGVlcnMpCisJCWlmICghcG9zLS0pCisJCQlicmVhazsKKworCXJldHVybiBfcCAhPSAmcnhycGNfcGVlcnMgPyBfcCA6IE5VTEw7Cit9IC8qIGVuZCByeHJwY19wcm9jX3BlZXJzX3N0YXJ0KCkgKi8KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworLyoKKyAqIG1vdmUgdG8gbmV4dCBjb25uIGluIHBlZXJzIGxpc3QKKyAqLworc3RhdGljIHZvaWQgKnJ4cnBjX3Byb2NfcGVlcnNfbmV4dChzdHJ1Y3Qgc2VxX2ZpbGUgKnAsIHZvaWQgKnYsIGxvZmZfdCAqcG9zKQoreworCXN0cnVjdCBsaXN0X2hlYWQgKl9wOworCisJKCpwb3MpKys7CisKKwlfcCA9IHY7CisJX3AgPSAodiA9PSBTRVFfU1RBUlRfVE9LRU4pID8gcnhycGNfcGVlcnMubmV4dCA6IF9wLT5uZXh0OworCisJcmV0dXJuIF9wICE9ICZyeHJwY19wZWVycyA/IF9wIDogTlVMTDsKK30gLyogZW5kIHJ4cnBjX3Byb2NfcGVlcnNfbmV4dCgpICovCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKy8qCisgKiBjbGVhbiB1cCBhZnRlciByZWFkaW5nIGZyb20gdGhlIHBlZXJzIGxpc3QKKyAqLworc3RhdGljIHZvaWQgcnhycGNfcHJvY19wZWVyc19zdG9wKHN0cnVjdCBzZXFfZmlsZSAqcCwgdm9pZCAqdikKK3sKKwl1cF9yZWFkKCZyeHJwY19wZWVyc19zZW0pOworCit9IC8qIGVuZCByeHJwY19wcm9jX3BlZXJzX3N0b3AoKSAqLworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisvKgorICogZGlzcGxheSBhIGhlYWRlciBsaW5lIGZvbGxvd2VkIGJ5IGEgbG9hZCBvZiBjb25uIGxpbmVzCisgKi8KK3N0YXRpYyBpbnQgcnhycGNfcHJvY19wZWVyc19zaG93KHN0cnVjdCBzZXFfZmlsZSAqbSwgdm9pZCAqdikKK3sKKwlzdHJ1Y3QgcnhycGNfcGVlciAqcGVlciA9IGxpc3RfZW50cnkodiwgc3RydWN0IHJ4cnBjX3BlZXIsIHByb2NfbGluayk7CisJc2lnbmVkIGxvbmcgdGltZW91dDsKKworCS8qIGRpc3BsYXkgaGVhZGVyIG9uIGxpbmUgMSAqLworCWlmICh2ID09IFNFUV9TVEFSVF9UT0tFTikgeworCQlzZXFfcHV0cyhtLCAiTE9DQUwgUkVNT1RFICAgVVNBR0UgQ09OTlMgIFRJTUVPVVQiCisJCQkgIiAgIE1UVSBSVFQodVMpXG4iKTsKKwkJcmV0dXJuIDA7CisJfQorCisJLyogZGlzcGxheSBvbmUgcGVlciBwZXIgbGluZSBvbiBzdWJzZXF1ZW50IGxpbmVzICovCisJdGltZW91dCA9IDA7CisJaWYgKCFsaXN0X2VtcHR5KCZwZWVyLT50aW1lb3V0LmxpbmspKQorCQl0aW1lb3V0ID0gKHNpZ25lZCBsb25nKSBwZWVyLT50aW1lb3V0LnRpbW9famlmIC0KKwkJCShzaWduZWQgbG9uZykgamlmZmllczsKKworCXNlcV9wcmludGYobSwgIiU1aHUgJTA4eCAlNWQgJTVkICU4bGQgJTVadSAlN2x1XG4iLAorCQkgICBwZWVyLT50cmFucy0+cG9ydCwKKwkJICAgbnRvaGwocGVlci0+YWRkci5zX2FkZHIpLAorCQkgICBhdG9taWNfcmVhZCgmcGVlci0+dXNhZ2UpLAorCQkgICBhdG9taWNfcmVhZCgmcGVlci0+Y29ubl9jb3VudCksCisJCSAgIHRpbWVvdXQsCisJCSAgIHBlZXItPmlmX210dSwKKwkJICAgKGxvbmcpIHBlZXItPnJ0dAorCQkgICApOworCisJcmV0dXJuIDA7Cit9IC8qIGVuZCByeHJwY19wcm9jX3BlZXJzX3Nob3coKSAqLworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisvKgorICogb3BlbiAiL3Byb2MvbmV0L3J4cnBjL2Nvbm5lY3Rpb25zIiB3aGljaCBwcm92aWRlcyBhIHN1bW1hcnkgb2YgZXh0YW50CisgKiBjb25uZWN0aW9ucworICovCitzdGF0aWMgaW50IHJ4cnBjX3Byb2NfY29ubnNfb3BlbihzdHJ1Y3QgaW5vZGUgKmlub2RlLCBzdHJ1Y3QgZmlsZSAqZmlsZSkKK3sKKwlzdHJ1Y3Qgc2VxX2ZpbGUgKm07CisJaW50IHJldDsKKworCXJldCA9IHNlcV9vcGVuKGZpbGUsICZyeHJwY19wcm9jX2Nvbm5zX29wcyk7CisJaWYgKHJldCA8IDApCisJCXJldHVybiByZXQ7CisKKwltID0gZmlsZS0+cHJpdmF0ZV9kYXRhOworCW0tPnByaXZhdGUgPSBQREUoaW5vZGUpLT5kYXRhOworCisJcmV0dXJuIDA7Cit9IC8qIGVuZCByeHJwY19wcm9jX2Nvbm5zX29wZW4oKSAqLworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisvKgorICogc2V0IHVwIHRoZSBpdGVyYXRvciB0byBzdGFydCByZWFkaW5nIGZyb20gdGhlIGNvbm5zIGxpc3QgYW5kIHJldHVybiB0aGUKKyAqIGZpcnN0IGl0ZW0KKyAqLworc3RhdGljIHZvaWQgKnJ4cnBjX3Byb2NfY29ubnNfc3RhcnQoc3RydWN0IHNlcV9maWxlICptLCBsb2ZmX3QgKl9wb3MpCit7CisJc3RydWN0IGxpc3RfaGVhZCAqX3A7CisJbG9mZl90IHBvcyA9ICpfcG9zOworCisJLyogbG9jayB0aGUgbGlzdCBhZ2FpbnN0IG1vZGlmaWNhdGlvbiAqLworCWRvd25fcmVhZCgmcnhycGNfY29ubnNfc2VtKTsKKworCS8qIGFsbG93IGZvciB0aGUgaGVhZGVyIGxpbmUgKi8KKwlpZiAoIXBvcykKKwkJcmV0dXJuIFNFUV9TVEFSVF9UT0tFTjsKKwlwb3MtLTsKKworCS8qIGZpbmQgdGhlIG4ndGggZWxlbWVudCBpbiB0aGUgbGlzdCAqLworCWxpc3RfZm9yX2VhY2goX3AsICZyeHJwY19jb25ucykKKwkJaWYgKCFwb3MtLSkKKwkJCWJyZWFrOworCisJcmV0dXJuIF9wICE9ICZyeHJwY19jb25ucyA/IF9wIDogTlVMTDsKK30gLyogZW5kIHJ4cnBjX3Byb2NfY29ubnNfc3RhcnQoKSAqLworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisvKgorICogbW92ZSB0byBuZXh0IGNvbm4gaW4gY29ubnMgbGlzdAorICovCitzdGF0aWMgdm9pZCAqcnhycGNfcHJvY19jb25uc19uZXh0KHN0cnVjdCBzZXFfZmlsZSAqcCwgdm9pZCAqdiwgbG9mZl90ICpwb3MpCit7CisJc3RydWN0IGxpc3RfaGVhZCAqX3A7CisKKwkoKnBvcykrKzsKKworCV9wID0gdjsKKwlfcCA9ICh2ID09IFNFUV9TVEFSVF9UT0tFTikgPyByeHJwY19jb25ucy5uZXh0IDogX3AtPm5leHQ7CisKKwlyZXR1cm4gX3AgIT0gJnJ4cnBjX2Nvbm5zID8gX3AgOiBOVUxMOworfSAvKiBlbmQgcnhycGNfcHJvY19jb25uc19uZXh0KCkgKi8KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworLyoKKyAqIGNsZWFuIHVwIGFmdGVyIHJlYWRpbmcgZnJvbSB0aGUgY29ubnMgbGlzdAorICovCitzdGF0aWMgdm9pZCByeHJwY19wcm9jX2Nvbm5zX3N0b3Aoc3RydWN0IHNlcV9maWxlICpwLCB2b2lkICp2KQoreworCXVwX3JlYWQoJnJ4cnBjX2Nvbm5zX3NlbSk7CisKK30gLyogZW5kIHJ4cnBjX3Byb2NfY29ubnNfc3RvcCgpICovCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKy8qCisgKiBkaXNwbGF5IGEgaGVhZGVyIGxpbmUgZm9sbG93ZWQgYnkgYSBsb2FkIG9mIGNvbm4gbGluZXMKKyAqLworc3RhdGljIGludCByeHJwY19wcm9jX2Nvbm5zX3Nob3coc3RydWN0IHNlcV9maWxlICptLCB2b2lkICp2KQoreworCXN0cnVjdCByeHJwY19jb25uZWN0aW9uICpjb25uOworCXNpZ25lZCBsb25nIHRpbWVvdXQ7CisKKwljb25uID0gbGlzdF9lbnRyeSh2LCBzdHJ1Y3QgcnhycGNfY29ubmVjdGlvbiwgcHJvY19saW5rKTsKKworCS8qIGRpc3BsYXkgaGVhZGVyIG9uIGxpbmUgMSAqLworCWlmICh2ID09IFNFUV9TVEFSVF9UT0tFTikgeworCQlzZXFfcHV0cyhtLAorCQkJICJMT0NBTCBSRU1PVEUgICBSUE9SVCBTUlZDIENPTk4gICAgIEVORCBTRVJJQUxOTyAiCisJCQkgIkNBTExOTyAgICAgTVRVICBUSU1FT1VUIgorCQkJICJcbiIpOworCQlyZXR1cm4gMDsKKwl9CisKKwkvKiBkaXNwbGF5IG9uZSBjb25uIHBlciBsaW5lIG9uIHN1YnNlcXVlbnQgbGluZXMgKi8KKwl0aW1lb3V0ID0gMDsKKwlpZiAoIWxpc3RfZW1wdHkoJmNvbm4tPnRpbWVvdXQubGluaykpCisJCXRpbWVvdXQgPSAoc2lnbmVkIGxvbmcpIGNvbm4tPnRpbWVvdXQudGltb19qaWYgLQorCQkJKHNpZ25lZCBsb25nKSBqaWZmaWVzOworCisJc2VxX3ByaW50ZihtLAorCQkgICAiJTVodSAlMDh4ICU1aHUgJTA0aHggJTA4eCAlLTMuM3MgJTA4eCAlMDh4ICU1WnUgJThsZFxuIiwKKwkJICAgY29ubi0+dHJhbnMtPnBvcnQsCisJCSAgIG50b2hsKGNvbm4tPmFkZHIuc2luX2FkZHIuc19hZGRyKSwKKwkJICAgbnRvaHMoY29ubi0+YWRkci5zaW5fcG9ydCksCisJCSAgIG50b2hzKGNvbm4tPnNlcnZpY2VfaWQpLAorCQkgICBudG9obChjb25uLT5jb25uX2lkKSwKKwkJICAgY29ubi0+b3V0X2NsaWVudGZsYWcgPyAiQ0xUIiA6ICJTUlYiLAorCQkgICBjb25uLT5zZXJpYWxfY291bnRlciwKKwkJICAgY29ubi0+Y2FsbF9jb3VudGVyLAorCQkgICBjb25uLT5tdHVfc2l6ZSwKKwkJICAgdGltZW91dAorCQkgICApOworCisJcmV0dXJuIDA7Cit9IC8qIGVuZCByeHJwY19wcm9jX2Nvbm5zX3Nob3coKSAqLworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisvKgorICogb3BlbiAiL3Byb2MvbmV0L3J4cnBjL2NhbGxzIiB3aGljaCBwcm92aWRlcyBhIHN1bW1hcnkgb2YgZXh0YW50IGNhbGxzCisgKi8KK3N0YXRpYyBpbnQgcnhycGNfcHJvY19jYWxsc19vcGVuKHN0cnVjdCBpbm9kZSAqaW5vZGUsIHN0cnVjdCBmaWxlICpmaWxlKQoreworCXN0cnVjdCBzZXFfZmlsZSAqbTsKKwlpbnQgcmV0OworCisJcmV0ID0gc2VxX29wZW4oZmlsZSwgJnJ4cnBjX3Byb2NfY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ioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKy8qCisgKiBtb3ZlIHRvIG5leHQgY2FsbCBpbiBjYWxscyBsaXN0CisgKi8KK3N0YXRpYyB2b2lkICpyeHJwY19wcm9jX2NhbGxzX25leHQoc3RydWN0IHNlcV9maWxlICpwLCB2b2lkICp2LCBsb2ZmX3QgKnBvcykKK3sKKwlzdHJ1Y3QgbGlzdF9oZWFkICpfcDsKKworCSgqcG9zKSsrOworCisJX3AgPSB2OworCV9wID0gKHYgPT0gU0VRX1NUQVJUX1RPS0VOKSA/IHJ4cnBjX2NhbGxzLm5leHQgOiBfcC0+bmV4dDsKKworCXJldHVybiBfcCAhPSAmcnhycGNfY2FsbHMgPyBfcCA6IE5VTEw7Cit9IC8qIGVuZCByeHJwY19wcm9jX2NhbGxzX25leHQoKSAqLworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisvKgorICogY2xlYW4gdXAgYWZ0ZXIgcmVhZGluZyBmcm9tIHRoZSBjYWxscyBsaXN0CisgKi8KK3N0YXRpYyB2b2lkIHJ4cnBjX3Byb2NfY2FsbHNfc3RvcChzdHJ1Y3Qgc2VxX2ZpbGUgKnAsIHZvaWQgKnYpCit7CisJdXBfcmVhZCgmcnhycGNfY2FsbHNfc2VtKTsKKworfSAvKiBlbmQgcnhycGNfcHJvY19jYWxsc19zdG9wKCkgKi8KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworLyoKKyAqIGRpc3BsYXkgYSBoZWFkZXIgbGluZSBmb2xsb3dlZCBieSBhIGxvYWQgb2YgY2FsbCBsaW5lcworICovCitzdGF0aWMgaW50IHJ4cnBjX3Byb2NfY2FsbHNfc2hvdyhzdHJ1Y3Qgc2VxX2ZpbGUgKm0sIHZvaWQgKnYpCit7CisJc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Cit9IC8qIGVuZCByeHJwY19jcmVhdGVfdHJhbnNwb3J0KCkgKi8KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworLyoKKyAqIGRlc3Ryb3kgYSB0cmFuc3BvcnQgZW5kcG9pbnQKKyAqLwordm9pZCByeHJwY19wdXRfdHJhbnNwb3J0KHN0cnVjdCByeHJwY190cmFuc3BvcnQgKnRyYW5zKQoreworCV9lbnRlcigiJXB7dT0lZCBwPSVodX0iLAorCSAgICAgICB0cmFucywgYXRvbWljX3JlYWQoJnRyYW5zLT51c2FnZSksIHRyYW5zLT5wb3J0KTsKKworCUJVR19PTihhdG9taWNfcmVhZCgmdHJhbnMtPnVzYWdlKSA8PSAwKTsKKworCS8qIHRvIHByZXZlbnQgYSByYWNlLCB0aGUgZGVjcmVtZW50IGFuZCB0aGUgZGVxdWV1ZSBtdXN0IGJlCisJICogZWZmZWN0aXZlbHkgYXRvbWljICovCisJc3Bpbl9sb2NrKCZyeHJwY190cmFuc3BvcnRzX2xvY2spOworCWlmIChsaWtlbHkoIWF0b21pY19kZWNfYW5kX3Rlc3QoJnRyYW5zLT51c2FnZSkpKSB7CisJCXNwaW5fdW5sb2NrKCZyeHJwY190cmFuc3BvcnRzX2xvY2spOworCQlfbGVhdmUoIiIpOworCQlyZXR1cm47CisJfQorCisJbGlzdF9kZWwoJnRyYW5zLT5saW5rKTsKKwlzcGluX3VubG9jaygmcnhycGNfdHJhbnNwb3J0c19sb2NrKTsKKworCS8qIGZpbmlzaCBjbGVhbmluZyB1cCB0aGUgdHJhbnNwb3J0ICovCisJaWYgKHRyYW5zLT5zb2NrZXQpCisJCXRyYW5zLT5zb2NrZXQtPm9wcy0+c2h1dGRvd24odHJhbnMtPnNvY2tldCwgMik7CisKKwlyeHJwY19rcnhzZWNkX2NsZWFyX3RyYW5zcG9ydCh0cmFucyk7CisJcnhycGNfa3J4aW9kX2RlcXVldWVfdHJhbnNwb3J0KHRyYW5zKTsKKworCS8qIGRpc2NhcmQgYWxsIHBlZXIgaW5mb3JtYXRpb24gKi8KKwlyeHJwY19wZWVyX2NsZWFyYWxsKHRyYW5zKTsKKworCWRvd25fd3JpdGUoJnJ4cnBjX3Byb2NfdHJhbnNwb3J0c19zZW0pOworCWxpc3RfZGVsKCZ0cmFucy0+cHJvY19saW5rKTsKKwl1cF93cml0ZSgmcnhycGNfcHJvY190cmFuc3BvcnRzX3NlbSk7CisJX19SWEFDQ1QoYXRvbWljX2RlYygmcnhycGNfdHJhbnNwb3J0X2NvdW50KSk7CisKKwkvKiBjbG9zZSB0aGUgc29ja2V0ICovCisJaWYgKHRyYW5zLT5zb2NrZXQpIHsKKwkJdHJhbnMtPnNvY2tldC0+c2stPnNrX3VzZXJfZGF0YSA9IE5VTEw7CisJCXNvY2tfcmVsZWFzZSh0cmFucy0+c29ja2V0KTsKKwkJdHJhbnMtPnNvY2tldCA9IE5VTEw7CisJfQorCisJa2ZyZWUodHJhbnMpOworCisJX2xlYXZlKCIiKTsKK30gLyogZW5kIHJ4cnBjX3B1dF90cmFuc3BvcnQoKSAqLworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisvKgorICogYWRkIGEgc2VydmljZSB0byBhIHRyYW5zcG9ydCB0byBiZSBsaXN0ZW5lZCB1cG9uCisgKi8KK2ludCByeHJwY19hZGRfc2VydmljZShzdHJ1Y3QgcnhycGNfdHJhbnNwb3J0ICp0cmFucywKKwkJICAgICAgc3RydWN0IHJ4cnBjX3NlcnZpY2UgKm5ld3NydikKK3sKKwlzdHJ1Y3QgcnhycGNfc2VydmljZSAqc3J2OworCXN0cnVjdCBsaXN0X2hlYWQgKl9wOworCWludCByZXQgPSAtRUVYSVNUOworCisJX2VudGVyKCIlcHslaHV9LCVweyVodX0iLAorCSAgICAgICB0cmFucywgdHJhbnMtPnBvc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xvY2spOworCWxpc3RfZGVsKCZzcnYtPmxpbmspOworCXNwaW5fdW5sb2NrKCZ0cmFucy0+bG9jayk7CisKKwlyeHJwY19wdXRfdHJhbnNwb3J0KHRyYW5zKTsKKworCV9sZWF2ZSgiIik7Cit9IC8qIGVuZCByeHJwY19kZWxfc2VydmljZSgpICovCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKy8qCisgKiBJTkVUIGNhbGxiYWNrIHdoZW4gZGF0YSBoYXMgYmVlbiByZWNlaXZlZCBvbiB0aGUgc29ja2V0LgorICovCitzdGF0aWMgdm9pZCByeHJwY19kYXRhX3JlYWR5KHN0cnVjdCBzb2NrICpzaywgaW50IGNvdW50KQoreworCXN0cnVjdCByeHJwY190cmFuc3BvcnQgKnRyYW5zOworCisJX2VudGVyKCIlcHt0PSVwfSwlZCIsIHNrLCBzay0+c2tfdXNlcl9kYXRhLCBjb3VudCk7CisKKwkvKiBxdWV1ZSB0aGUgdHJhbnNwb3J0IGZvciBhdHRlbnRpb24gYnkga3J4aW9kICovCisJdHJhbnMgPSAoc3RydWN0IHJ4cnBjX3RyYW5zcG9ydCAqKSBzay0+c2tfdXNlcl9kYXRhOworCWlmICh0cmFucykKKwkJcnhycGNfa3J4aW9kX3F1ZXVlX3RyYW5zcG9ydCh0cmFucyk7CisKKwkvKiB3YWtlIHVwIGFueW9uZSB3YWl0aW5nIG9uIHRoZSBzb2NrZXQgKi8KKwlpZiAoc2stPnNrX3NsZWVwICYmIHdhaXRxdWV1ZV9hY3RpdmUoc2stPnNrX3NsZWVwKSkKKwkJd2FrZV91cF9pbnRlcnJ1cHRpYmxlKHNrLT5za19zbGVlcCk7CisKKwlfbGVhdmUoIiIpOworfSAvKiBlbmQgcnhycGNfZGF0YV9yZWFkeSgpICovCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqK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za2JfdHJpbShza2IsIGIgLSBza2ItPmRhdGEpOworCXJldHVybiAtZXJyOworfQorCitzdHJ1Y3QgdGNfYWN0aW9uICp0Y2ZfYWN0aW9uX2luaXRfMShzdHJ1Y3QgcnRhdHRyICpydGEsIHN0cnVjdCBydGF0dHIgKmVzdCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNoYXIgKm5hbWUsIGludCBvdnIsIGludCBiaW5kLCBpbnQgKmVycikKK3sKKwlzdHJ1Y3QgdGNfYWN0aW9uICphOworCXN0cnVjdCB0Y19hY3Rpb25fb3BzICphX287CisJY2hhciBhY3RfbmFtZVtJRk5BTVNJWl07CisJc3RydWN0IHJ0YXR0ciAqdGJbVENBX0FDVF9NQVgrMV07CisJc3RydWN0IHJ0YXR0ciAqa2luZDsKKworCSplcnIgPSAtRUlOVkFMOworCisJaWYgKG5hbWUgPT0gTlVMTCkgeworCQlpZiAocnRhdHRyX3BhcnNlX25lc3RlZCh0YiwgVENBX0FDVF9NQVgsIHJ0YSkgPCAwKQorCQkJZ290byBlcnJfb3V0OworCQlraW5kID0gdGJbVENBX0FDVF9LSU5ELTFdOworCQlpZiAoa2luZCA9PSBOVUxMKQorCQkJZ290byBlcnJfb3V0OworCQlpZiAocnRhdHRyX3N0cmxjcHkoYWN0X25hbWUsIGtpbmQsIElGTkFNU0laKSA+PSBJRk5BTVNJWikKKwkJCWdvdG8gZXJyX291dDsKKwl9IGVsc2UgeworCQlpZiAoc3RybGNweShhY3RfbmFtZSwgbmFtZSwgSUZOQU1TSVopID49IElGTkFNU0laKQorCQkJZ290byBlcnJfb3V0OworCX0KKworCWFfbyA9IHRjX2xvb2t1cF9hY3Rpb25fbihhY3RfbmFtZSk7CisJaWYgKGFfbyA9PSBOVUxMKSB7CisjaWZkZWYgQ09ORklHX0tNT0QKKwkJcnRubF91bmxvY2soKTsKKwkJcmVxdWVzdF9tb2R1bGUoYWN0X25hbWUpOworCQlydG5sX2xvY2soKTsKKworCQlhX28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zIG9mIGEgY2VydGFpbiB0eXBlIHdoaWNoIG11c3QgYmUKKyAqIAllcXVhbCB0byB0aGUgb2JqZWN0IGl0IGlzIGJlaW5nIGNvbXBhcmVkIHRvLgorICoKKyAqIAlUaGUgZGVmaW5pdGlvbiBvZiBhIG9iamVjdHMgY29uaXN0cyBvZiB0aGUgdHlwZSAobWV0YSB0eXBlKSwgYQorICogCWlkZW50aWZpZXIgKG1ldGEgaWQpIGFuZCBhZGRpdGlvbmFsIHR5cGUgc3BlY2lmaWMgaW5mb3JtYXRpb24uCisgKiAJVGhlIG1ldGEgaWQgaXMgZWl0aGVyIFRDRl9NRVRBX1RZUEVfVkFMVUUgZm9yIHZhbHVlcyBwcm92aWRlZCBieQorICogCXVzZXJzcGFjZSBvciBhIGluZGV4IHRvIHRoZSBtZXRhIG9wZXJhdGlvbnMgdGFibGUgY29uc2lzdGluZyBvZgorICogCWZ1bmN0aW9uIHBvaW50ZXJzIHRvIHR5cGUgc3BlY2lmaWMgbWV0YSBkYXRhIGNvbGxlY3RvcnMgcmV0dXJuaW5nCisgKiAJdGhlIHZhbHVlIG9mIHRoZSByZXF1ZXN0ZWQgbWV0YSB2YWx1ZS4KKyAqCisgKiAJICAgICAgICAgbHZhbHVlICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBydmFsdWUKKyAqIAkgICAgICArLS0tLS0tLS0tLS0rICAgICAgICAgICAgICAgICAgICAgICAgICAgKy0tLS0tLS0tLS0tKworICogCSAgICAgIHwgdHlwZTogSU5UIHwgICAgICAgICAgICAgICAgICAgICAgICAgICB8IHR5cGU6IElOVCB8CisgKiAJIGRlZiAgfCBpZDogSU5ERVYgfCAgICAgICAgICAgICAgICAgICAgICAgICAgIHwgaWQ6IFZBTFVFIHwKKyAqIAkgICAgICB8IGRhdGE6ICAgICB8ICAgICAgICAgICAgICAgICAgICAgICAgICAgfCBkYXRhOiAzICAgfAorICogCSAgICAgICstLS0tLS0tLS0tLSsgICAgICAgICAgICAgICAgICAgICAgICAgICArLS0tLS0tLS0tLS0rCisgKiAJICAgICAgICAgICAgfCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwKKyAqIAkgICAgICAgICAgICAtLS0+IG1ldGFfb3BzW0lOVF1bSU5ERVZdKC4uLikgICAgICAgICAgfAorICogICAgICAgICAgICAgICAgICAgICAgICAgICAgfCAgICAgICAgICAgICAgICAgICAgICAgICAgICB8CisgKiAJICAgICAgICAgICAgLS0tLS0tLS0tLS0gICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwKKyAqIAkgICAgICAgICAgICBWICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgVgorICogCSAgICAgICstLS0tLS0tLS0tLSsgICAgICAgICAgICAgICAgICAgICAgICAgICArLS0tLS0tLS0tLS0rCisgKiAJICAgICAgfCB0eXBlOiBJTlQgfCAgICAgICAgICAgICAgICAgICAgICAgICAgIHwgdHlwZTogSU5UIHwKKyAqIAkgb2JqICB8IGlkOiBJTkRFViB8ICAgICAgICAgICAgICAgICAgICAgICAgICAgfCBpZDogVkFMVUUgfAorICogCSAgICAgIHwgZGF0YTogMiAgIHw8LS1kYXRhIGdvdCBmaWxsZWQgb3V0ICAgICB8IGRhdGE6IDMgICB8CisgKiAJICAgICAgKy0tLS0tLS0tLS0tKyAgICAgICAgICAgICAgICAgICAgICAgICAgICstLS0tLS0tLS0tLSsKKyAqIAkgICAgICAgICAgICB8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB8CisgKiAJICAgICAgICAgICAgLS0tLS0tLS0tLS0tLS0+IDIgIGVxdWFscyAzIDwtLS0tLS0tLS0tLS0tLQorICoKKyAqIAlUaGlzIGlzIGEgc2ltcGxpZmllZCBzY2hlbWEsIHRoZSBjb21wbGV4aXR5IHZhcmllcyBkZXBlbmRpbmcKKyAqIAlvbiB0aGUgbWV0YSB0eXBlLiBPYnZpb3VzbHksIHRoZSBsZW5ndGggb2YgdGhlIGRhdGEgb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ioqKioqKioqKioqKioqKioqKioqKioqKiovCisKK01FVEFfQ09MTEVDVE9SKGludF9yYW5kb20pCit7CisJZ2V0X3JhbmRvbV9ieXRlcygmZHN0LT52YWx1ZSwgc2l6ZW9mKGRzdC0+dmFsdWUpKTsKK30KKworc3RhdGljIGlubGluZSB1bnNpZ25lZCBsb25nIGZpeGVkX2xvYWRhdmcoaW50IGxvYWQpCit7CisJaW50IHJuZF9sb2FkID0gbG9hZCArIChGSVhFRF8xLzIwMCk7CisJaW50IHJuZF9mcmFjID0gKChybmRfbG9hZCAmIChGSVhFRF8xLTEpKSAqIDEwMCkgPj4gRlNISUZUOworCisJcmV0dXJuICgocm5kX2xvYWQgPj4gRlNISUZUKSAqIDEwMCkgKyBybmRfZnJhYzsKK30KKworTUVUQV9DT0xMRUNUT1IoaW50X2xvYWRhdmdfMCkKK3sKKwlkc3QtPnZhbHVlID0gZml4ZWRfbG9hZGF2ZyhhdmVucnVuWzBdKTsKK30KKworTUVUQV9DT0xMRUNUT1IoaW50X2xvYWRhdmdfMSkKK3sKKwlkc3QtPnZhbHVlID0gZml4ZWRfbG9hZGF2ZyhhdmVucnVuWzFdKTsKK30KKworTUVUQV9DT0xMRUNUT1IoaW50X2xvYWRhdmdfMikKK3sKKwlkc3QtPnZhbHVlID0gZml4ZWRfbG9hZGF2ZyhhdmVucnVuWzJdKTsKK30KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgKiBEZXZpY2UgbmFtZXMgJiBpbmRpY2VzCisgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisKK3N0YXRpYyBpbmxpbmUgaW50IGludF9kZXYoc3RydWN0IG5ldF9kZXZpY2UgKmRldiwgc3RydWN0IG1ldGFfb2JqICpkc3QpCit7CisJaWYgKHVubGlrZWx5KGRldiA9PSBOVUxMKSkKKwkJcmV0dXJuIC0xOworCisJZHN0LT52YWx1ZSA9IGRldi0+aWZpbmRleDsKKwlyZXR1cm4gMDsKK30KKworc3RhdGljIGlubGluZSBpbnQgdmFyX2RldihzdHJ1Y3QgbmV0X2RldmljZSAqZGV2LCBzdHJ1Y3QgbWV0YV9vYmogKmRzdCkKK3sKKwlpZiAodW5saWtlbHkoZGV2ID09IE5VTEwpKQorCQlyZXR1cm4gLTE7CisKKwlkc3QtPnZhbHVlID0gKHVuc2lnbmVkIGxvbmcpIGRldi0+bmFtZTsKKwlkc3QtPmxlbiA9IHN0cmxlbihkZXYtPm5hbWUpOworCXJldHVybiAwOworfQorCitNRVRBX0NPTExFQ1RPUihpbnRfZGV2KQoreworCSplcnIgPSBpbnRfZGV2KHNrYi0+ZGV2LCBkc3QpOworfQorCitNRVRBX0NPTExFQ1RPUih2YXJfZGV2KQoreworCSplcnIgPSB2YXJfZGV2KHNrYi0+ZGV2LCBkc3QpOworfQorCitNRVRBX0NPTExFQ1RPUihpbnRfaW5kZXYpCit7CisJKmVyciA9IGludF9kZXYoc2tiLT5pbnB1dF9kZXYsIGRzdCk7Cit9CisKK01FVEFfQ09MTEVDVE9SKHZhcl9pbmRldikKK3sKKwkqZXJyID0gdmFyX2Rldihza2ItPmlucHV0X2RldiwgZHN0KTsKK30KKworTUVUQV9DT0xMRUNUT1IoaW50X3JlYWxkZXYpCit7CisJKmVyciA9IGludF9kZXYoc2tiLT5yZWFsX2RldiwgZHN0KTsKK30KKworTUVUQV9DT0xMRUNUT1IodmFyX3JlYWxkZXYpCit7CisJKmVyciA9IHZhcl9kZXYoc2tiLT5yZWFsX2RldiwgZHN0KTsKK30KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgKiBza2IgYXR0cmlidXRlcworICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworCitNRVRBX0NPTExFQ1RPUihpbnRfcHJpb3JpdHkpCit7CisJZHN0LT52YWx1ZSA9IHNrYi0+cHJpb3JpdHk7Cit9CisKK01FVEFfQ09MTEVDVE9SKGludF9wcm90b2NvbCkKK3sKKwkvKiBMZXQgdXNlcnNwYWNlIHRha2UgY2FyZSBvZiB0aGUgYnl0ZSBvcmRlcmluZyAqLworCWRzdC0+dmFsdWUgPSBza2ItPnByb3RvY29sOworfQorCitNRVRBX0NPTExFQ1RPUihpbnRfc2VjdXJpdHkpCit7CisJZHN0LT52YWx1ZSA9IHNrYi0+c2VjdXJpdHk7Cit9CisKK01FVEFfQ09MTEVDVE9SKGludF9wa3R0eXBlKQoreworCWRzdC0+dmFsdWUgPSBza2ItPnBrdF90eXBlOworfQorCitNRVRBX0NPTExFQ1RPUihpbnRfcGt0bGVuKQoreworCWRzdC0+dmFsdWUgPSBza2ItPmxlbjsKK30KKworTUVUQV9DT0xMRUNUT1IoaW50X2RhdGFsZW4pCit7CisJZHN0LT52YWx1ZSA9IHNrYi0+ZGF0YV9sZW47Cit9CisKK01FVEFfQ09MTEVDVE9SKGludF9tYWNsZW4pCit7CisJZHN0LT52YWx1ZSA9IHNrYi0+bWFjX2xlbjsKK30KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgKiBOZXRmaWx0ZXIKKyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKworI2lmZGVmIENPTkZJR19ORVRGSUxURVIKK01FVEFfQ09MTEVDVE9SKGludF9uZm1hcmspCit7CisJZHN0LT52YWx1ZSA9IHNrYi0+bmZtYXJrOworfQorI2VuZGlmCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorICogVHJhZmZpYyBDb250cm9sCisgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisKK01FVEFfQ09MTEVDVE9SKGludF90Y2luZGV4KQoreworCWRzdC0+dmFsdWUgPSBza2ItPnRjX2luZGV4OworfQorCisjaWZkZWYgQ09ORklHX05FVF9DTFNfQUNUCitNRVRBX0NPTExFQ1RPUihpbnRfdGN2ZXJkKQoreworCWRzdC0+dmFsdWUgPSBza2ItPnRjX3ZlcmQ7Cit9CisKK01FVEFfQ09MTEVDVE9SKGludF90Y2NsYXNzaWQpCit7CisJZHN0LT52YWx1ZSA9IHNrYi0+dGNfY2xhc3NpZDsKK30KKyNlbmRpZgorCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyAqIFJvdXRpbmcKKyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKworI2lmZGVmIENPTkZJR19ORVRfQ0xTX1JPVVRFCitNRVRBX0NPTExFQ1RPUihpbnRfcnRjbGFzc2lkKQoreworCWlmICh1bmxpa2VseShza2ItPmRzdCA9PSBOVUxMKSkKKwkJKmVyciA9IC0xOworCWVsc2UKKwkJZHN0LT52YWx1ZSA9IHNrYi0+ZHN0LT50Y2xhc3NpZDsKK30KKyNlbmRpZgorCitNRVRBX0NPTExFQ1RPUihpbnRfcnRpaWYpCit7CisJaWYgKHVubGlrZWx5KHNrYi0+ZHN0ID09IE5VTEwpKQorCQkqZXJyID0gLTE7CisJZWxzZQorCQlkc3QtPnZhbHVlID0gKChzdHJ1Y3QgcnRhYmxlKikgc2tiLT5kc3QpLT5mbC5paWY7Cit9CisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKio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lkIG1ldGFfaW50X2FwcGx5X2V4dHJhcyhzdHJ1Y3QgbWV0YV92YWx1ZSAqdiwKKwkJCQkgIHN0cnVjdCBtZXRhX29iaiAqZHN0KQoreworCWlmICh2LT5oZHIuc2hpZnQpCisJCWRzdC0+dmFsdWUgPj49IHYtPmhkci5zaGlmdDsKKworCWlmICh2LT52YWwpCisJCWRzdC0+dmFsdWUgJj0gdi0+dmFsOworfQorCitzdGF0aWMgaW50IG1ldGFfaW50X2R1bXAoc3RydWN0IHNrX2J1ZmYgKnNrYiwgc3RydWN0IG1ldGFfdmFsdWUgKnYsIGludCB0bHYpCit7CisJaWYgKHYtPmxlbiA9PSBzaXplb2YodW5zaWduZWQgbG9uZykpCisJCVJUQV9QVVQoc2tiLCB0bHYsIHNpemVvZih1bnNpZ25lZCBsb25nKSwgJnYtPnZhbCk7CisJZWxzZSBpZiAodi0+bGVuID09IHNpemVvZih1MzIpKSB7CisJCXUzMiBkID0gdi0+dmFsOworCQlSVEFfUFVUKHNrYiwgdGx2LCBzaXplb2YoZCksICZkKTsKKwl9CisKKwlyZXR1cm4gMDsKKworcnRhdHRyX2ZhaWx1cmU6CisJcmV0dXJuIC0xOworfQorCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyAqIFR5cGUgc3BlY2lmaWMgb3BlcmF0aW9ucyB0YWJsZQorICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworCitzdHJ1Y3QgbWV0YV90eXBlX29wcworeworCXZvaWQJKCpkZXN0cm95KShzdHJ1Y3QgbWV0YV92YWx1ZSAqKTsKKwlpbnQJKCpjb21wYXJlKShzdHJ1Y3QgbWV0YV9vYmogKiwgc3RydWN0IG1ldGFfb2JqICopOworCWludAkoKmNoYW5nZSkoc3RydWN0IG1ldGFfdmFsdWUgKiwgc3RydWN0IHJ0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gICBcCisgKiArLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0tKworICogfCBBIEFORCB8IEIgQU5EIHwgQyBBTkQgfCBEIEVORCB8IEIxIE9SIHwgQjIgRU5EIHwKKyAqICstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLS0rCisgKiAgICAgICAgICAgICAgICAgICAgXCAgICAgICAgICAgICAgICAgICAgICAvCisgKiAgICAgICAgICAgICAgICAgICAgIC0tLS0tLS0tPC1QT1AtLS0tLS0tLS0KKyAqCisgKiB3aGVyZSBCIGlzIGEgdmlydHVhbCBlbWF0Y2ggcmVmZXJlbmNpbmcgdG8gc2VxdWVuY2Ugc3RhcnRpbmcgd2l0aCBCMS4KKyAqIAorICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqCisgKiBIb3cgdG8gd3JpdGUgYW4gZW1hdGNoIGluIDYwIHNlY29uZHMKKyAqIC0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLQorICogCisgKiAgIDEpIFByb3ZpZGUgYSBtYXRjaGVyIGZ1bmN0aW9uOgorICogICAgICBzdGF0aWMgaW50IG15X21hdGNoKHN0cnVjdCBza19idWZmICpza2IsIHN0cnVjdCB0Y2ZfZW1hdGNoICptLAorICogICAgICAgICAgICAgICAgICAgICAgICAgIHN0cnVjdCB0Y2ZfcGt0X2luZm8gKmluZm8pCisgKiAgICAgIHsKKyAqICAgICAgCXN0cnVjdCBteWRhdGEgKmQgPSAoc3RydWN0IG15ZGF0YSAqKSBtLT5kYXRhOworICoKKyAqICAgICAgCWlmICguLi5tYXRjaGluZyBnb2VzIGhlcmUuLi4pCisgKiAgICAgIAkJcmV0dXJuIDE7CisgKiAgICAgIAllbHNlCisgKiAgICAgIAkJcmV0dXJuIDA7CisgKiAgICAgIH0KKyAqCisgKiAgIDIpIEZpbGwgb3V0IGEgc3RydWN0IHRjZl9lbWF0Y2hfb3BzOgorICogICAgICBzdGF0aWMgc3RydWN0IHRjZl9lbWF0Y2hfb3BzIG15X29wcyA9IHsKKyAqICAgICAgCS5raW5kID0gdW5pcXVlIGlkLAorICogICAgICAJLmRhdGFsZW4gPSBzaXplb2Yoc3RydWN0IG15ZGF0YSksCisgKiAgICAgIAkubWF0Y2ggPSBteV9tYXRjaCwKKyAqICAgICAgCS5vd25lciA9IFRISVNfTU9EVUxFLAorICogICAgICB9OworICoKKyAqICAgMykgUmVnaXN0ZXIvVW5yZWdpc3RlciB5b3VyIGVtYXRjaDoKKyAqICAgICAgc3RhdGljIGludCBfX2luaXQgaW5pdF9teV9lbWF0Y2godm9pZCkKKyAqICAgICAgeworICogICAgICAJcmV0dXJuIHRjZl9lbV9yZWdpc3RlcigmbXlfb3BzKTsKKyAqICAgICAgfQorICoKKyAqICAgICAgc3RhdGljIHZvaWQgX19leGl0IGV4aXRfbXlfZW1hdGNoKHZvaWQpCisgKiAgICAgIHsKKyAqICAgICAgCXJldHVybiB0Y2ZfZW1fdW5yZWdpc3RlcigmbXlfb3BzKTsKKyAqICAgICAgfQorICoKKyAqICAgICAgbW9kdWxlX2luaXQoaW5pdF9teV9lbWF0Y2gpOworICogICAgICBtb2R1bGVfZXhpdChleGl0X215X2VtYXRjaCk7CisgKgorICogICA0KSBCeSBub3cgeW91IHNob3VsZCBoYXZlIHR3byBtb3JlIHNlY29uZHMgbGVmdCwgYmFyZWx5IGVub3VnaCB0bworICogICAgICBvcGVuIHVwIGEgYmVlciB0byB3YXRjaCB0aGUgY29tcGlsYXRpb24gZ29pbmcuCisgKi8KKworI2luY2x1ZGUgPGxpbnV4L2NvbmZpZy5oPgorI2luY2x1ZGUgPGxpbnV4L21vZHVsZS5oPgorI2luY2x1ZGUgPGxpbnV4L3R5cGVzLmg+CisjaW5jbHVkZSA8bGludXgva2VybmVsLmg+Cisj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VvZigqcCksIEdGUF9LRVJORUwpOworCWlmIChwID09IE5VTEwpCisJCXJldHVybiBOVUxMOworCisJbWVtc2V0KHAsIDAsIHNpemVvZigqcCkpOworCXAtPnJlZmNudCA9IDE7CisJc3Bpbl9sb2NrX2luaXQoJnAtPmxvY2spOworCXAtPnN0YXRzX2xvY2sgPSAmcC0+bG9jazsKKwlpZiAocGFybS0+cmF0ZS5yYXRlKSB7CisJCXAtPlJfdGFiID0gcWRpc2NfZ2V0X3J0YWIoJnBhcm0tPnJhdGUsIHRiW1RDQV9QT0xJQ0VfUkFURS0xXSk7CisJCWlmIChwLT5SX3RhYiA9PSBOVUxMKQorCQkJZ290byBmYWlsdXJlOworCQlpZiAocGFybS0+cGVha3JhdGUucmF0ZSkgeworCQkJcC0+UF90YWIgPSBxZGlzY19nZXRfcnRhYigmcGFybS0+cGVha3JhdGUsCisJCQkgICAgICAgICAgICAgICAgICAgICAgICAgIHRiW1RDQV9QT0xJQ0VfUEVBS1JBVEUtMV0pOworCQkJaWYgKHAtPlBfdGFiID09IE5VTEwpCisJCQkJZ290byBmYWlsdXJlOworCQl9CisJfQorCWlmICh0YltUQ0FfUE9MSUNFX1JFU1VMVC0xXSkgeworCQlpZiAoUlRBX1BBWUxPQUQodGJbVENBX1BPTElDRV9SRVNVTFQtMV0pICE9IHNpemVvZih1MzIpKQorCQkJZ290byBmYWlsdXJlOworCQlwLT5yZXN1bHQgPSAqKHUzMiopUlRBX0RBVEEodGJbVENBX1BPTElDRV9SRVNVTFQtMV0pOworCX0KKyNpZmRlZiBDT05GSUdfTkVUX0VTVElNQVRPUgorCWlmICh0YltUQ0FfUE9MSUNFX0FWUkFURS0xXSkgeworCQlpZiAoUlRBX1BBWUxPQUQodGJbVENBX1BPTElDRV9BVlJBVEUtMV0pICE9IHNpemVvZih1MzIpKQorCQkJZ290byBmYWlsdXJlOworCQlwLT5ld21hX3JhdGUgPSAqKHUzMiopUlRBX0RBVEEodGJbVENBX1BPTElDRV9BVlJBVEU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0wOyBkZXY7IGRldiA9IGRldi0+bmV4dCwgaWR4KyspIHsKKwkJaWYgKGlkeCA8IHNfaWR4KQorCQkJY29udGludWU7CisJCWlmIChpZHggPiBzX2lkeCkKKwkJCXNfcV9pZHggPSAwOworCQlyZWFkX2xvY2tfYmgoJnFkaXNjX3RyZWVfbG9jayk7CisJCXFfaWR4ID0gMDsKKwkJbGlzdF9mb3JfZWFjaF9lbnRyeShxLCAmZGV2LT5xZGlzY19saXN0LCBsaXN0KSB7CisJCQlpZiAocV9pZHggPCBzX3FfaWR4KSB7CisJCQkJcV9pZHgrKzsKKwkJCQljb250aW51ZTsKKwkJCX0KKwkJCWlmICh0Y19maWxsX3FkaXNjKHNrYiwgcSwgcS0+cGFyZW50LCBORVRMSU5LX0NCKGNiLT5za2IpLnBpZCwKKwkJCQkJICBjYi0+bmxoLT5ubG1zZ19zZXEsIE5MTV9GX01VTFRJLCBSVE1fTkVXUURJU0MpIDw9IDApIHsKKwkJCQlyZWFkX3VubG9ja19iaCgmcWRpc2NfdHJlZV9sb2NrKTsKKwkJCQlnb3RvIGRvbmU7CisJCQl9CisJCQlxX2lkeCsrOworCQl9CisJCXJlYWRfdW5sb2NrX2JoKCZxZGlzY190cmVlX2xvY2spOworCX0KKworZG9uZToKKwlyZWFkX3VubG9jaygmZGV2X2Jhc2VfbG9jayk7CisKKwljYi0+YXJnc1swXSA9IGlkeDsKKwljYi0+YXJnc1sxXSA9IHFfaWR4OworCisJcmV0dXJuIHNrYi0+bGVuOworfQorCisKKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorICoJVHJhZmZpYyBjbGFzc2VzIG1hbmlwdWxhdGlvbi4JCSoKKyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisKKworCitzdGF0aWMgaW50IHRjX2N0bF90Y2xhc3Moc3RydWN0IHNrX2J1ZmYgKnNrYiwgc3RydWN0IG5sbXNnaGRyICpuLCB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GNoZWFwZXIuCisgKi8KKworc3RhdGljIGludAorbm9vcF9lbnF1ZXVlKHN0cnVjdCBza19idWZmICpza2IsIHN0cnVjdCBRZGlzYyAqIHFkaXNjKQoreworCWtmcmVlX3NrYihza2IpOworCXJldHVybiBORVRfWE1JVF9DTjsKK30KKworc3RhdGljIHN0cnVjdCBza19idWZmICoKK25vb3BfZGVxdWV1ZShzdHJ1Y3QgUWRpc2MgKiBxZGlzYykKK3sKKwlyZXR1cm4gTlVMTDsKK30KKworc3RhdGljIGludAorbm9vcF9yZXF1ZXVlKHN0cnVjdCBza19idWZmICpza2IsIHN0cnVjdCBRZGlzYyogcWRpc2MpCit7CisJaWYgKG5ldF9yYXRlbGltaXQoKSkKKwkJcHJpbnRrKEtFUk5fREVCVUcgIiVzIGRlZmVycmVkIG91dHB1dC4gSXQgaXMgYnVnZ3kuXG4iLCBza2ItPmRldi0+bmFtZSk7CisJa2ZyZWVfc2tiKHNrYik7CisJcmV0dXJuIE5FVF9YTUlUX0NOOworfQorCitzdHJ1Y3QgUWRpc2Nfb3BzIG5vb3BfcWRpc2Nfb3BzID0geworCS5uZXh0CQk9CU5VTEwsCisJLmNsX29wcwkJPQlOVUxMLAorCS5pZAkJPQkibm9vcCIsCisJLnByaXZfc2l6ZQk9CTAsCisJLmVucXVldWUJPQlub29wX2VucXVldWUsCisJLmRlcXVldWUJPQlub29wX2RlcXVldWUsCisJLnJlcXVldWUJPQlub29wX3JlcXVldWUsCisJLm93bmVyCQk9CVRISVNfTU9EVUxFLAorfTsKKworc3RydWN0IFFkaXNjIG5vb3BfcWRpc2MgPSB7CisJLmVucXVldWUJPQlub29wX2VucXVldWUsCisJLmRlcXVldWUJPQlub29wX2RlcXVldWUsCisJLmZsYWdzCQk9CVRDUV9GX0JVSUxUSU4sCisJLm9wcwkJPQkmbm9vcF9xZGlzY19vcHMsCQorCS5saXN0CQk9CUxJU1RfSEVBRF9JTklUKG5vb3BfcWRpc2MubGlzdCksCit9OworCitzdGF0aWMg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AoKCh4ICYgU01fTUFTSykgKiBzbSkgPj4gU01fU0hJRlQpOworCXJldHVybiB5OworfQorCitzdGF0aWMgaW5saW5lIHU2NAorc2VnX3kyeCh1NjQgeSwgdTY0IGlzbSkKK3sKKwl1NjQgeDsKKworCWlmICh5ID09IDApCisJCXggPSAwOworCWVsc2UgaWYgKGlzbSA9PSBIVF9JTkZJTklUWSkKKwkJeCA9IEhUX0lORklOSVRZOworCWVsc2UgeworCQl4ID0gKHkgPj4gSVNNX1NISUZUKSAqIGlzbQorCQkgICAgKyAoKCh5ICYgSVNNX01BU0spICogaXNtKSA+PiBJU01fU0hJRlQpOworCX0KKwlyZXR1cm4geDsKK30KKworLyogQ29udmVydCBtIChicHMpIGludG8gc20gKGJ5dGVzL3BzY2hlZCB1cykgKi8KK3N0YXRpYyB1NjQKK20yc20odTMyIG0pCit7CisJdTY0IHNtOworCisJc20gPSAoKHU2NCltIDw8IFNNX1NISUZUKTsKKwlzbSArPSBQU0NIRURfSklGRklFMlVTKEhaKSAtIDE7CisJZG9fZGl2KHNtLCBQU0NIRURfSklGRklFMlVTKEhaKSk7CisJcmV0dXJuIHNtOworfQorCisvKiBjb252ZXJ0IG0gKGJwcykgaW50byBpc20gKHBzY2hlZCB1cy9ieXRlKSAqLworc3RhdGljIHU2NAorbTJpc20odTMyIG0pCit7CisJdTY0IGlzbTsKKworCWlmIChtID09IDApCisJCWlzbSA9IEhUX0lORklOSVRZOworCWVsc2UgeworCQlpc20gPSAoKHU2NClQU0NIRURfSklGRklFMlVTKEhaKSA8PCBJU01fU0hJRlQpOworCQlpc20gKz0gbSAtIDE7CisJCWRvX2Rpdihpc20sIG0pOworCX0KKwlyZXR1cm4gaXNtOworfQorCisvKiBjb252ZXJ0IGQgKHVzKSBpbnRvIGR4IChwc2NoZWQgdXMpICovCitzdGF0aWMgdTY0CitkMmR4KHUzMiBkKQoreworCXU2NCBkeDsKKworCWR4ID0gKCh1NjQpZCAqIFBTQ0hFRF9KSUZGSUUyVVMo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PmVucXVldWUoc2tiLCBxKTsKKwkJc3Bpbl91bmxvY2soJmRldi0+cXVldWVfbG9jayk7CisgICAgICAgIH0KKwkJCQorCXJldHVybiBmd3JlczsKK30KKworLyogYWZ0ZXIgaXB0X2ZpbHRlciAqLworc3RhdGljIHN0cnVjdCBuZl9ob29rX29wcyBpbmdfb3BzID0geworCS5ob29rICAgICAgICAgICA9IGluZ19ob29rLAorCS5vd25lcgkJPSBUSElTX01PRFVMRSwKKwkucGYgICAgICAgICAgICAgPSBQRl9JTkVULAorCS5ob29rbnVtICAgICAgICA9IE5GX0lQX1BSRV9ST1VUSU5HLAorCS5wcmlvcml0eSAgICAgICA9IE5GX0lQX1BSSV9GSUxURVIgKyAxLAorfTsKKworc3RhdGljIHN0cnVjdCBuZl9ob29rX29wcyBpbmc2X29wcyA9IHsKKwkuaG9vayAgICAgICAgICAgPSBpbmdfaG9vaywKKwkub3duZXIJCT0gVEhJU19NT0RVTEUsCisJLnBmICAgICAgICAgICAgID0gUEZfSU5FVDYsCisJLmhvb2tudW0gICAgICAgID0gTkZfSVA2X1BSRV9ST1VUSU5HLAorCS5wcmlvcml0eSAgICAgICA9IE5GX0lQNl9QUklfRklMVEVSICsgMSwKK307CisKKyNlbmRpZgorI2VuZGlmCisKK3N0YXRpYyBpbnQgaW5ncmVzc19pbml0KHN0cnVjdCBRZGlzYyAqc2NoLHN0cnVjdCBydGF0dHIgKm9wdCkKK3sKKwlzdHJ1Y3QgaW5ncmVzc19xZGlzY19kYXRhICpwID0gUFJJVihzY2gpOworCisvKiBNYWtlIHN1cmUgZWl0aGVyIG5ldGZpbHRlciBvciBwcmVmZXJhYmx5IENMU19BQ1QgaXMKKyogY29tcGlsZWQgaW4gKi8KKyNpZm5kZWYgQ09ORklHX05FVF9DTFNfQUNUCisjaWZuZGVmIENPTkZJR19ORVRGSUxURVIKKwlwcmludGsoIllvdSBNVVNUIGNvbXBpbGUgY2xhc3NpZmllciBhY3Rpb25zIGludG8gdGhlIGtlcm5lbFxuIik7CisJcmV0dXJuIC1FSU5WQUw7CisjZWxzZQorCXByaW50aygiSW5ncmVzcyBzY2hlZHVsZXI6IENsYXNzaWZpZXIgYWN0aW9ucyBwcmVmZXJlZCBvdmVyIG5ldGZpbHRlclxuIik7CisjZW5kaWYKKyNlbmRpZgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKKyNpZm5kZWYgQ09ORklHX05FVF9DTFNfQUNUCisjaWZkZWYgQ09ORklHX05FVEZJTFRFUgorCWlmICghbmZfcmVnaXN0ZXJlZCkgeworCQlpZiAobmZfcmVnaXN0ZXJfaG9vaygmaW5nX29wcykgPCAwKSB7CisJCQlwcmludGsoImluZ3Jlc3MgcWRpc2MgcmVnaXN0cmF0aW9uIGVycm9yIFxuIik7CisJCQlyZXR1cm4gLUVJTlZBTDsKKwkJfQorCQluZl9yZWdpc3RlcmVkKys7CisKKwkJaWYgKG5mX3JlZ2lzdGVyX2hvb2soJmluZzZfb3BzKSA8IDApIHsKKwkJCXByaW50aygiSVB2NiBpbmdyZXNzIHFkaXNjIHJlZ2lzdHJhdGlvbiBlcnJvciwgIiBcCisJCQkgICAgImRpc2FibGluZyBJUHY2IHN1cHBvcnQuXG4iKTsKKwkJfSBlbHNlCisJCQluZl9yZWdpc3RlcmVkKys7CisJfQorI2VuZGlmCisjZW5kaWYKKworCURQUklOVEsoImluZ3Jlc3NfaW5pdChzY2ggJXAsW3FkaXNjICVwXSxvcHQgJXApXG4iLHNjaCxwLG9wdCk7CisJcC0+cSA9ICZub29wX3FkaXNjOworCXJldHVybiAwOworfQorCisKK3N0YXRpYyB2b2lkIGluZ3Jlc3NfcmVzZXQoc3RydWN0IFFkaXNjICpzY2gpCit7CisJc3RydWN0IGluZ3Jlc3NfcWRpc2NfZGF0YSAqcCA9IFBSSVYoc2NoKTsKKworCURQUklOVEsoImluZ3Jlc3NfcmVzZXQoc2NoICVwLFt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zY3RwX3Njb3BlX3QgYWRkcl9zY29wZSA9IHNjdHBfc2NvcGUoYWRkcik7CisKKwkvKiBUaGUgdW51c2FibGUgU0NUUCBhZGRyZXNzZXMgd2lsbCBub3QgYmUgY29uc2lkZXJlZCB3aXRoCisJICogYW55IGRlZmluZWQgc2NvcGVzLgorCSAqLworCWlmIChTQ1RQX1NDT1BFX1VOVVNBQkxFID09IGFkZHJfc2NvcGUpCisJCXJldHVybiAwOworCS8qCisJICogRm9yIElOSVQgYW5kIElOSVQtQUNLIGFkZHJlc3MgbGlzdCwgbGV0IEwgYmUgdGhlIGxldmVsIG9mCisJICogb2YgcmVxdWVzdGVkIGRlc3RpbmF0aW9uIGFkZHJlc3MsIHNlbmRlciBhbmQgcmVjZWl2ZXIKKwkgKiBTSE9VTEQgaW5jbHVkZSBhbGwgb2YgaXRzIGFkZHJlc3NlcyB3aXRoIGxldmVsIGdyZWF0ZXIKKwkgKiB0aGFuIG9yIGVxdWFsIHRvIEwuCisJICovCisJaWYgKGFkZHJfc2NvcGUgPD0gc2NvcGUpCisJCXJldHVybiAxOworCisJcmV0dXJuIDA7Cit9CisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorICogM3JkIExldmVsIEFic3RyYWN0aW9ucworICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworCisvKiBXaGF0IGlzIHRoZSBzY29wZSBvZiAnYWRkcic/ICAqLworc2N0cF9zY29wZV90IHNjdHBfc2NvcGUoY29uc3QgdW5pb24gc2N0cF9hZGRyICphZGRyKQoreworCXN0cnVjdCBzY3RwX2FmICphZjsKKworCWFmID0gc2N0cF9nZXRfYWZfc3BlY2lmaWMoYWRkci0+c2Euc2FfZmFtaWx5KTsKKwlpZiAoIWFmKQorCQlyZXR1cm4gU0NUUF9TQ09QRV9VTlVTQUJMRTsKKworCXJldHVyb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cnkgdG8gZml4Li4uIGFueSBmaXhlcyBzaGFyZWQgd2lsbAorICogYmUgaW5jb3Jwb3JhdGVkIGludG8gdGhlIG5leHQgU0NUUCByZWxlYXNlLgorICovCisKKy8qIFRoZSBmb2xsb3dpbmcgY29kZSBoYXMgYmVlbiB0YWtlbiBkaXJlY3RseSBmcm9tCisgKiBkcmFmdC1pZXRmLXRzdndnLXNjdHBjc3VtLTAzLnR4dAorICoKKyAqIFRoZSBjb2RlIGhhcyBub3cgYmVlbiBtb2RpZmllZCBzcGVjaWZpY2FsbHkgZm9yIFNDVFAga25vd2xlZGdlLgorICovCisKKyNpbmNsdWRlIDxsaW51eC90eXBlcy5oPgorI2luY2x1ZGUgPG5ldC9zY3RwL3NjdHAuaD4KKworI2RlZmluZSBDUkMzMkNfUE9MWSAweDFFREM2RjQxCisjZGVmaW5lIENSQzMyQyhjLGQpIChjPShjPj44KV5jcmNfY1soY14oZCkpJjB4RkZdKQorLyogKiAqICogKiAqICogKiAqICogKiAqICogKiAqICogKiAqICogKiAqICogKiAqICogKiAqICogKiAqICogKiAqLworLyogQ29weXJpZ2h0IDIwMDEsIEQuIE90aXMuICBVc2UgdGhpcyBwcm9ncmFtLCBjb2RlIG9yIHRhYmxlcyAgICAqLworLyogZXh0cmFjdGVkIGZyb20gaXQsIGFzIGRlc2lyZWQgd2l0aG91dCByZXN0cmljdGlvbi4gICAgICAgICAgICAqLworLyogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqLworLyogMzIgQml0IFJlZmxlY3RlZCBDUkMgdGFibGUgZ2VuZXJhdGlvbiBmb3IgU0NUUC4gICAgICAgICAgICAgICAqLworLyogVG8gYWNjb21tb2RhdGUgc2VyaWFsIGJ5dGUgZGF0YSBiZWluZyBzaGlmdGVkIG91dCBsZWFzdCAgICAgICAqLworLyogc2lnbmlmaWNhbnQgYml0IGZpcnN0LCB0aGUgdGFibGUncyAzMiBiaXQgd29yZHMgYXJlIHJlZmxlY3RlZCAqLworLyogd2hpY2ggZmxpcHMgYm90aCBieXRlIGFuZCBiaXQgTVMgYW5kIExTIHBvc2l0aW9ucy4gIFRoZSBDUkMgICAqLworLyogaXMgY2FsY3VsYXRlZCBNUyBiaXRzIGZpcnN0IGZyb20gdGhlIHBlcnNwZWN0aXZlIG9mIHRoZSBzZXJpYWwqLworLyogc3RyZWFtLiAgVGhlIHheMzIgdGVybSBpcyBpbXBsaWVkIGFuZCB0aGUgeF4wIHRlcm0gbWF5IGFsc28gICAqLworLyogYmUgc2hvd24gYXMgKzEuICBUaGUgcG9seW5vbWlhbCBjb2RlIHVzZWQgaXMgMHgxRURDNkY0MS4gICAgICAqLworLyogQ2FzdGFnbm9saTkzICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqLworLyogeF4zMit4XjI4K3heMjcreF4yNit4XjI1K3heMjMreF4yMit4XjIwK3heMTkreF4xOCt4XjE0K3heMTMrICAqLworLyogeF4xMSt4XjEwK3heOSt4XjgreF42K3heMCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqLworLyogR3V5IENhc3RhZ25vbGkgU3RlZmFuIEJyYWV1ZXIgYW5kIE1hcnRpbiBIZXJybWFuICAgICAgICAgICAgICAqLworLyogIk9wdGltaXphdGlvbiBvZiBDeWNsaWMgUmVkdW5kYW5jeS1DaGVjayBDb2RlcyAgICAgICAgICAgICAgICAqLworLyogd2l0aCAyNCBhbmQgMzIgUGFyaXR5IEJpdHMiLCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqLworLyogSUVFRSBUcmFuc2FjdGlvbnMgb24gQ29tbXVuaWNhdGlvbnMsIFZvbC40MSwgTm8uNiwgSnVuZSAxOTkzICAqLworLyogKiAqICogKiAqICogKiAqICogKiAqICogKiAqICogKiAqICogKiAqICogKiAqICogKiAqICogKiAqICogKiAqLworc3RhdGljIGNvbnN0IF9fdTMyIGNyY19jWzI1Nl0gP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6CisJLyogQ29udHJvbCBjaHVua3MgYXJlIHVucmVsaWFibGUgc28ganVzdCBkcm9wIHRoZW0uICBEQVRBIGNodW5rcworCSAqIHdpbGwgZ2V0IHJlc2VudCBvciBkcm9wcGVkIGxhdGVyLgorCSAqLworCisJd2hpbGUgKChjaHVuayA9IChzdHJ1Y3Qgc2N0cF9jaHVuayAqKV9fc2tiX2RlcXVldWUoJnBhY2tldC0+Y2h1bmtzKSkgIT0gTlVMTCkgeworCQlpZiAoIXNjdHBfY2h1bmtfaXNfZGF0YShjaHVuaykpCisgICAgCQkJc2N0cF9jaHVua19mcmVlKGNodW5rKTsKKwl9CisJZ290byBvdXQ7Citub21lbToKKwllcnIgPSAtRU5PTUVNOworCWdvdG8gZXJyOworfQorCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyAqIDJuZCBMZXZlbCBBYnN0cmFjdGlvbnMKKyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKworLyogVGhpcyBwcml2YXRlIGZ1bmN0aW9uIGhhbmRsZXMgdGhlIHNwZWNpZmljcyBvZiBhcHBlbmRpbmcgREFUQSBjaHVua3MuICAqLworc3RhdGljIHNjdHBfeG1pdF90IHNjdHBfcGFja2V0X2FwcGVuZF9kYXRhKHN0cnVjdCBzY3RwX3BhY2tldCAqcGFja2V0LAorCQkJCQkgICBzdHJ1Y3Qgc2N0cF9jaHVuayAqY2h1bmspCit7CisJc2N0cF94bWl0X3QgcmV0dmFsID0gU0NUUF9YTUlUX09LOworCXNpemVfdCBkYXRhc2l6ZSwgcnduZCwgaW5mbGlnaHQ7CisJc3RydWN0IHNjdHBfdHJhbnNwb3J0ICp0cmFuc3BvcnQgPSBwYWNrZXQtPnRyYW5zcG9ydDsKKwlfX3UzMiBtYXhfYnVyc3RfYnl0ZXM7CisJc3RydWN0IHNjdHBfYX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BhZnRlciBBZHYuQWNrLlBvaW50CisJICogICBub3JtYWwgU0FDSyBwcm9jZXNzaW5nICAgICAgICAgICBsb2NhbCBhZHZhbmNlbWVudAorCSAqICAgICAgICAgICAgICAgIC4uLiAgICAgICAgICAgICAgICAgICAgICAgICAgIC4uLgorCSAqICAgQWR2LkFjay5QdC0+IDEwMiBhY2tlZCAgICAgICAgICAgICAgICAgICAgIDEwMiBhY2tlZAorCSAqICAgICAgICAgICAgICAgIDEwMyBhYmFuZG9uZWQgICAgICAgICAgICAgICAgIDEwMyBhYmFuZG9uZWQKKwkgKiAgICAgICAgICAgICAgICAxMDQgYWJhbmRvbmVkICAgICBBZHYuQWNrLlAtPiAxMDQgYWJhbmRvbmVkCisJICogICAgICAgICAgICAgICAgMTA1ICAgICAgICAgICAgICAgICAgICAgICAgICAgMTA1CisJICogICAgICAgICAgICAgICAgMTA2IGFja2VkICAgICAgICAgICAgICAgICAgICAgMTA2IGFja2VkCisJICogICAgICAgICAgICAgICAgLi4uICAgICAgICAgICAgICAgICAgICAgICAgICAgLi4uCisJICoKKwkgKiBJbiB0aGlzIGV4YW1wbGUsIHRoZSBkYXRhIHNlbmRlciBzdWNjZXNzZnVsbHkgYWR2YW5jZWQgdGhlCisJICogIkFkdmFuY2VkLlBlZXIuQWNrLlBvaW50IiBmcm9tIDEwMiB0byAxMDQgbG9jYWxseS4KKwkgKi8KKwlsaXN0X2Zvcl9lYWNoX3NhZmUobGNodW5rLCB0ZW1wLCAmcS0+YWJhbmRvbmVkKSB7CisJCWNodW5rID0gbGlzdF9lbnRyeShsY2h1bmssIHN0cnVjdCBzY3RwX2NodW5rLAorCQkJCQl0cmFuc21pdHRlZF9saXN0KTsKKwkJdHNuID0gbnRvaGwoY2h1bmstPnN1YmguZGF0YV9oZHItPnRzbik7CisKKwkJLyogUmVtb3ZlIGFueSBjaHVua3MgaW4gdGhlIGFiYW5kb25lZCBxdWV1ZSB0aGF0IGFyZSBhY2tlZCBieQorCQkgKiB0aGUgY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UgY29uc3RhbnRzIGFyZSBub3cgZGVmaW5lZCBpbiBuZXR3b3JrIG9yZGVyLiAgKi8KKwllcnIuY2F1c2UgPSBjYXVzZV9jb2RlOworCWxlbiA9IHNpemVvZihzY3RwX2Vycmhkcl90KSArIHBheWxlbjsKKwlwYWRsZW4gPSBsZW4gJSA0OworCWVyci5sZW5ndGggID0gaHRvbnMobGVuKTsKKwlsZW4gKz0gcGFkbGVuOworCXNjdHBfYWRkdG9fY2h1bmsoY2h1bmssIHNpemVvZihzY3RwX2Vycmhkcl90KSwgJmVycik7CisJY2h1bmstPnN1YmguZXJyX2hkciA9IHNjdHBfYWRkdG9fY2h1bmsoY2h1bmssIHBheWxlbiwgcGF5bG9hZCk7Cit9CisKKy8qIDMuMy4yIEluaXRpYXRpb24gKElOSVQpICgxKQorICoKKyAqIFRoaXMgY2h1bmsgaXMgdXNlZCB0byBpbml0aWF0ZSBhIFNDVFAgYXNzb2NpYXRpb24gYmV0d2VlbiB0d28KKyAqIGVuZHBvaW50cy4gVGhlIGZvcm1hdCBvZiB0aGUgSU5JVCBjaHVuayBpcyBzaG93biBiZWxvdzoKKyAqCisgKiAgICAgMCAgICAgICAgICAgICAgICAgICAxICAgICAgICAgICAgICAgICAgIDIgICAgICAgICAgICAgICAgICAgMworICogICAgIDAgMSAyIDMgNCA1IDYgNyA4IDkgMCAxIDIgMyA0IDUgNiA3IDggOSAwIDEgMiAzIDQgNSA2IDcgOCA5IDAgMQorICogICAgKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSsKKyAqICAgIHwgICBUeXBlID0gMSAgICB8ICBDaHVuayBGbGFncyAgfCAgICAgIENodW5rIExlbmd0aCAgICAgICAgICAgICB8CisgKiAgICArLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKworICogICAgfCAgICAgICAgICAgICAgICAgICAgICAgICBJbml0aWF0ZSBUYWcgICAgICAgICAgICAgICAgICAgICAgICAgIHwKKyAqICAgICstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rCisgKiAgICB8ICAgICAgICAgICBBZHZlcnRpc2VkIFJlY2VpdmVyIFdpbmRvdyBDcmVkaXQgKGFfcnduZCkgICAgICAgICAgfAorICogICAgKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSsKKyAqICAgIHwgIE51bWJlciBvZiBPdXRib3VuZCBTdHJlYW1zICAgfCAgTnVtYmVyIG9mIEluYm91bmQgU3RyZWFtcyAgICB8CisgKiAgICArLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKworICogICAgfCAgICAgICAgICAgICAgICAgICAgICAgICAgSW5pdGlhbCBUU04gICAgICAgICAgICAgICAgICAgICAgICAgIHwKKyAqICAgICstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rCisgKiAgICBcICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXAorICogICAgLyAgICAgICAgICAgICAgT3B0aW9uYWwvVmFyaWFibGUtTGVuZ3RoIFBhcmFtZXRlcnMgICAgICAgICAgICAgIC8KKyAqICAgIFwgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCisgKiAgICArLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKworICoKKyAqCisgKiBUaGUgSU5JVCBjaHVuayBjb250YWlucyB0aGUgZm9sbG93aW5nIHBhcmFt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AgICAgICAgICAgICAgICAgICAzCisgKiAgICAgIDAgMSAyIDMgNCA1IDYgNyA4IDkgMCAxIDIgMyA0IDUgNiA3IDggOSAwIDEgMiAzIDQgNSA2IDcgOCA5IDAgMQorICogICAgICstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rCisgKiAgICAgfCAgIFR5cGUgPSAxMCAgIHxDaHVuayAgRmxhZ3MgICB8ICAgICAgICAgTGVuZ3RoICAgICAgICAgICAgICAgIHwKKyAqICAgICArLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKworICogICAgIC8gICAgICAgICAgICAgICAgICAgICBDb29raWUgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvCisgKiAgICAgXCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKKyAqICAgICArLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKworICoKKyAqIENodW5rIEZsYWdzOiA4IGJpdAorICoKKyAqICAgU2V0IHRvIHplcm8gb24gdHJhbnNtaXQgYW5kIGlnbm9yZWQgb24gcmVjZWlwdC4KKyAqCisgKiBMZW5ndGg6IDE2IGJpdHMgKHVuc2lnbmVkIGludGVnZXIpCisgKgorICogICBTZXQgdG8gdGhlIHNpemUgb2YgdGhlIGNodW5rIGluIGJ5dGVzLCBpbmNsdWRpbmcgdGhlIDQgYnl0ZXMgb2YKKyAqICAgdGhlIGNodW5rIGhlYWRlciBhbmQgdGhlIHNpemUgb2YgdGhlIENvb2tpZS4KKyAqCisgKiBDb29raWU6IHZhcmlhYmxlIHNpemUKKyAqCisgKiAgIFRoaXMgZmllbGQgbXVzdCBjb250YWluIHRoZSBleGFjdCBjb29raWUgcmVjZWl2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LSsKKyAqICAgIHwgQ2h1bmsgVHlwZT0xMyB8IEZsYWdzPTAwMDAwMDAwfCAgICBDaHVuayBMZW5ndGggPSA4ICAgICAgICAgICB8CisgKiAgICArLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKworICogICAgfCAgICAgICAgICAgICAgICAgICAgICBMb3dlc3QgVFNOIE51bWJlciAgICAgICAgICAgICAgICAgICAgICAgIHwKKyAqICAgICstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rCisgKgorICogICAgIE5vdGU6IFRoZSBDV1IgaXMgY29uc2lkZXJlZCBhIENvbnRyb2wgY2h1bmsuCisgKi8KK3N0cnVjdCBzY3RwX2NodW5rICpzY3RwX21ha2VfY3dyKGNvbnN0IHN0cnVjdCBzY3RwX2Fzc29jaWF0aW9uICphc29jLAorCQkJICAgIGNvbnN0IF9fdTMyIGxvd2VzdF90c24sCisJCQkgICAgY29uc3Qgc3RydWN0IHNjdHBfY2h1bmsgKmNodW5rKQoreworCXN0cnVjdCBzY3RwX2NodW5rICpyZXR2YWw7CisJc2N0cF9jd3JoZHJfdCBjd3I7CisKKwljd3IubG93ZXN0X3RzbiA9IGh0b25sKGxvd2VzdF90c24pOworCXJldHZhbCA9IHNjdHBfbWFrZV9jaHVuayhhc29jLCBTQ1RQX0NJRF9FQ05fQ1dSLCAwLAorCQkJCSBzaXplb2Yoc2N0cF9jd3JoZHJfdCkpOworCisJaWYgKCFyZXR2YWwpCisJCWdvdG8gbm9kYXRhOworCisJcmV0dmFsLT5zdWJoLmVjbl9jd3JfaGRyID0KKwkJc2N0cF9hZGR0b19jaHVuayhyZXR2YWwsIHNpemVvZihjd3IpLCAmY3dyKTsKKworCS8qIFJGQyAyOTYwIDYuNCBNdWx0aS1ob21lZCBTQ1RQIEVuZHBvaW50cworCSAqCisJICogQW4gZW5k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BheWxlbik7CisKK25vZGF0YToKKwlyZXR1cm4gcmV0dmFsOworfQorCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyAqIDJuZCBMZXZlbCBBYnN0cmFjdGlvbnMKKyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKworLyogVHVybiBhbiBza2IgaW50byBhIGNodW5rLgorICogRklYTUU6IEV2ZW50dWFsbHkgbW92ZSB0aGUgc3RydWN0dXJlIGRpcmVjdGx5IGluc2lkZSB0aGUgc2tiLT5jYltdLgorICovCitzdHJ1Y3Qgc2N0cF9jaHVuayAqc2N0cF9jaHVua2lmeShzdHJ1Y3Qgc2tfYnVmZiAqc2tiLAorCQkJICAgIGNvbnN0IHN0cnVjdCBzY3RwX2Fzc29jaWF0aW9uICphc29jLAorCQkJICAgIHN0cnVjdCBzb2NrICpzaykKK3sKKwlzdHJ1Y3Qgc2N0cF9jaHVuayAqcmV0dmFsOworCisJcmV0dmFsID0ga21lbV9jYWNoZV9hbGxvYyhzY3RwX2NodW5rX2NhY2hlcCwgU0xBQl9BVE9NSUMpOworCisJaWYgKCFyZXR2YWwpCisJCWdvdG8gbm9kYXRhOworCW1lbXNldChyZXR2YWwsIDAsIHNpemVvZihzdHJ1Y3Qgc2N0cF9jaHVuaykpOworCisJaWYgKCFzaykgeworCQlTQ1RQX0RFQlVHX1BSSU5USygiY2h1bmtpZnlpbmcgc2tiICVwIHcvbyBhbiBza1xuIiwgc2tiKTsKKwl9CisKKwlyZXR2YWwtPnNrYgkJPSBza2I7CisJcmV0dmFsLT5hc29jCQk9IChzdHJ1Y3Qgc2N0cF9hc3NvY2lhdGlvbiAqKWFzb2M7CisJcmV0dmFsLT5yZXNlbnQgIAk9IDA7CisJcmV0dmFsLT5oYXNfdHNuCQk9IDA7CisJcmV0dmFsLT5oYXNfc3NuICAgICAgIC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ZGRyc19sZW47CisKKwkvKiBSZW1lbWJlciBQUi1TQ1RQIGNhcGFiaWxpdHkuICovCisJY29va2llLT5jLnByc2N0cF9jYXBhYmxlID0gYXNvYy0+cGVlci5wcnNjdHBfY2FwYWJsZTsKKworCS8qIFNhdmUgYWRhcHRpb24gaW5kaWNhdGlvbiBpbiB0aGUgY29va2llLiAqLworCWNvb2tpZS0+Yy5hZGFwdGlvbl9pbmQgPSBhc29jLT5wZWVyLmFkYXB0aW9uX2luZDsKKworCS8qIFNldCBhbiBleHBpcmF0aW9uIHRpbWUgZm9yIHRoZSBjb29raWUuICAqLworCWRvX2dldHRpbWVvZmRheSgmY29va2llLT5jLmV4cGlyYXRpb24pOworCVRJTUVWQUxfQUREKGFzb2MtPmNvb2tpZV9saWZlLCBjb29raWUtPmMuZXhwaXJhdGlvbik7CisKKwkvKiBDb3B5IHRoZSBwZWVyJ3MgaW5pdCBwYWNrZXQuICAqLworCW1lbWNweSgmY29va2llLT5jLnBlZXJfaW5pdFswXSwgaW5pdF9jaHVuay0+Y2h1bmtfaGRyLAorCSAgICAgICBudG9ocyhpbml0X2NodW5rLT5jaHVua19oZHItPmxlbmd0aCkpOworCisJLyogQ29weSB0aGUgcmF3IGxvY2FsIGFkZHJlc3MgbGlzdCBvZiB0aGUgYXNzb2NpYXRpb24uICovCisJbWVtY3B5KChfX3U4ICopJmNvb2tpZS0+Yy5wZWVyX2luaXRbMF0gKworCSAgICAgICBudG9ocyhpbml0X2NodW5rLT5jaHVua19oZHItPmxlbmd0aCksIHJhd19hZGRycywgYWRkcnNfbGVuKTsKKworICAJaWYgKHNjdHBfc2soZXAtPmJhc2Uuc2spLT5obWFjKSB7CisJCS8qIFNpZ24gdGhlIG1lc3NhZ2UuICAqLworCQlzZy5wYWdlID0gdmlydF90b19wYWdlKCZjb29raWUtPmMpOworCQlzZy5vZmZzZXQgPSAodW5zaWduZWQgbG9uZykoJmNvb2tpZS0+YykgJSBQQUdFX1NJWkU7CisJCXNnLmxlbm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WwtPnBlZXIuYWRhcHRpb25faW5kID0gcmV0dmFsLT5jLmFkYXB0aW9uX2luZDsKKworCS8qIFRoZSBJTklUIHN0dWZmIHdpbGwgYmUgZG9uZSBieSB0aGUgc2lkZSBlZmZlY3RzLiAgKi8KKwlyZXR1cm4gcmV0dmFsOworCitmYWlsOgorCWlmIChyZXR2YWwpCisJCXNjdHBfYXNzb2NpYXRpb25fZnJlZShyZXR2YWwpOworCisJcmV0dXJuIE5VTEw7CisKK21hbGZvcm1lZDoKKwkvKiBZaWtlcyEgIFRoZSBwYWNrZXQgaXMgZWl0aGVyIGNvcnJ1cHQgb3IgZGVsaWJlcmF0ZWx5CisJICogbWFsZm9ybWVkLgorCSAqLworCSplcnJvciA9IC1TQ1RQX0lFUlJPUl9NQUxGT1JNRUQ7CisJZ290byBmYWlsOworfQorCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyAqIDNyZCBMZXZlbCBBYnN0cmFjdGlvbnMKKyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKworc3RydWN0IF9fc2N0cF9taXNzaW5nIHsKKwlfX3UzMiBudW1fbWlzc2luZzsKKwlfX3UxNiB0eXBlOworfSAgX19hdHRyaWJ1dGVfXygocGFja2VkKSk7CisKKy8qCisgKiBSZXBvcnQgYSBtaXNzaW5nIG1hbmRhdG9yeSBwYXJhbWV0ZXIuCisgKi8KK3N0YXRpYyBpbnQgc2N0cF9wcm9jZXNzX21pc3NpbmdfcGFyYW0oY29uc3Qgc3RydWN0IHNjdHBfYXNzb2NpYXRpb24gKmFzb2MsCisJCQkJICAgICAgc2N0cF9wYXJhbV90IHBhcmFtdHlwZSwKKwkJCQkgICAgICBzdHJ1Y3Qgc2N0cF9jaHVuayAqY2h1bmssCisJCQkJICAgICAgc3RydWN0IHNjdHBfY2h1bmsgKiplcnJwKQore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worCQlnZXRfcmFuZG9tX2J5dGVzKCZ4LCBzaXplb2YoX191MzIpKTsKKwl9IHdoaWxlICh4ID09IDApOworCisJcmV0dXJuIHg7Cit9CisKKy8qIFNlbGVjdCBhbiBpbml0aWFsIFRTTiB0byBzZW5kIGR1cmluZyBzdGFydHVwLiAgKi8KK19fdTMyIHNjdHBfZ2VuZXJhdGVfdHNuKGNvbnN0IHN0cnVjdCBzY3RwX2VuZHBvaW50ICplcCkKK3sKKwlfX3UzMiByZXR2YWw7CisKKwlnZXRfcmFuZG9tX2J5dGVzKCZyZXR2YWwsIHNpemVvZihfX3UzMikpOworCXJldHVybiByZXR2YWw7Cit9CisKKy8qCisgKiBBRERJUCAzLjEuMSBBZGRyZXNzIENvbmZpZ3VyYXRpb24gQ2hhbmdlIENodW5rIChBU0NPTkYpCisgKiAgICAgIDAgICAgICAgICAgICAgICAgICAgMSAgICAgICAgICAgICAgICAgICAyICAgICAgICAgICAgICAgICAgIDMKKyAqICAgICAgMCAxIDIgMyA0IDUgNiA3IDggOSAwIDEgMiAzIDQgNSA2IDcgOCA5IDAgMSAyIDMgNCA1IDYgNyA4IDkgMCAxCisgKiAgICAgKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSsKKyAqICAgICB8IFR5cGUgPSAweEMxICAgfCAgQ2h1bmsgRmxhZ3MgIHwgICAgICBDaHVuayBMZW5ndGggICAgICAgICAgICAgfAorICogICAgICstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rCisgKiAgICAgfCAgICAgICAgICAgICAgICAgICAgICAgU2VyaWFsIE51bWJlciAgICAgICAgICAgICAgICAgICAgICAgICAgIHwKKyAqICAgICArLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKworICogICAgIHwgICAgICAgICAgICAgICAgICAgIEFkZHJlc3MgUGFyYW1ldGVyICAgICAgICAgICAgICAgICAgICAgICAgICB8CisgKiAgICAgKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSsKKyAqICAgICB8ICAgICAgICAgICAgICAgICAgICAgQVNDT05GIFBhcmFtZXRlciAjMSAgICAgICAgICAgICAgICAgICAgICAgfAorICogICAgICstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rCisgKiAgICAgXCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKKyAqICAgICAvICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuLi4uICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLworICogICAgIFwgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCisgKiAgICAgKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSsKKyAqICAgICB8ICAgICAgICAgICAgICAgICAgICAgQVNDT05GIFBhcmFtZXRlciAjTiAgICAgICAgICAgICAgICAgICAgICAgfAorICogICAgICArLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKworICoKKyAqIEFkZHJlc3MgUGFyYW1ldGVyIGFuZCBvdGhlciBwYXJhbWV0ZXIgd2lsbCBub3QgYmUgd3JhcHBlZCBpbiB0aGlzIGZ1bmN0aW9uIAorICovCitzdGF0aWMgc3RydWN0IHNjdHBfY2h1bmsgKnNjdHBfbWFrZV9hc2NvbmYoc3RydWN0IHNjdHBfYXNzb2NpYXRpb24gKmFzb2MsCisJCQkJCSAgIHVuaW9u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zIDQgNSA2IDcgOCA5IDAgMSAyIDMgNCA1IDYgNyA4IDkgMCAxIDIgMyA0IDUgNiA3IDggOSAwIDEKKyAqICAgICArLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKworICogICAgIHwgICAgICAgIFR5cGUgPSAweEMwMDEgICAgICAgICAgfCAgICBMZW5ndGggPSBWYXJpYWJsZSAgICAgICAgICB8CisgKiAgICAgKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSsKKyAqICAgICB8ICAgICAgICAgICAgICAgQVNDT05GLVJlcXVlc3QgQ29ycmVsYXRpb24gSUQgICAgICAgICAgICAgICAgICAgfAorICogICAgICstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rCisgKiAgICAgfCAgICAgICAgICAgICAgICAgICAgICAgQWRkcmVzcyBQYXJhbWV0ZXIgICAgICAgICAgICAgICAgICAgICAgIHwKKyAqICAgICArLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKworICoKKyAqIDMuMi4yIERlbGV0ZSBJUCBBZGRyZXNzCisgKiAJMCAgICAgICAgICAgICAgICAgICAxICAgICAgICAgICAgICAgICAgIDIgICAgICAgICAgICAgICAgICAgMworICogCTAgMSAyIDMgNCA1IDYgNyA4IDkgMCAxIDIgMyA0IDUgNiA3IDggOSAwIDEgMiAzIDQgNSA2IDcgOCA5IDAgMQorICogICAgICstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rCisgKiAgICAgfCAgICAgICAgVHlwZSA9IDB4QzAwMiAgICAgICAgICB8ICAgIExlbmd0aCA9IFZhcmlhYmxlICAgICAgICAgIHwKKyAqICAgICArLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKworICogICAgIHwgICAgICAgICAgICAgICBBU0NPTkYtUmVxdWVzdCBDb3JyZWxhdGlvbiBJRCAgICAgICAgICAgICAgICAgICB8CisgKiAgICAgKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSsKKyAqICAgICB8ICAgICAgICAgICAgICAgICAgICAgICBBZGRyZXNzIFBhcmFtZXRlciAgICAgICAgICAgICAgICAgICAgICAgfAorICogICAgICstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rCisgKgorICovCitzdHJ1Y3Qgc2N0cF9jaHVuayAqc2N0cF9tYWtlX2FzY29uZl91cGRhdGVfaXAoc3RydWN0IHNjdHBfYXNzb2NpYXRpb24gKmFzb2MsCisJCQkJCSAgICAgIHVuaW9uIHNjdHBfYWRkcgkgICAgICAqbGFkZHIsCisJCQkJCSAgICAgIHN0cnVjdCBzb2NrYWRkcgkgICAgICAqYWRkcnMsCisJCQkJCSAgICAgIGludAkJICAgICAgYWRkcmNudCwKKwkJCQkJICAgICAgX191MTYJCSAgICAgIGZsYWdzKQoreworCXNjdHBfYWRkaXBfcGFyYW1fdAlwYXJhbTsKKwlzdHJ1Y3Qgc2N0cF9jaHVuawkqcmV0dmFsOworCXVuaW9uIHNjdHBfYWRkcl9wYXJhbQlhZGRyX3BhcmFtOworCXVuaW9uIHNjdHBfYWRkcgkJKmFkZHI7CisJdm9pZAkJCSphZGRyX2J1ZjsKKwlzdHJ1Y3Qgc2N0cF9hZgkJKmFmOworCWludAkJCXBhcmFtbGVuID0gc2l6ZW9mKHBhcmFtKTsKKwlpbnQJCQlhZGRyX3BhcmFtX2xlbiA9IDA7CisJaW50IAkJCXRvdG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FyYW0ucGFyYW1faGRyLmxlbmd0aCA9IGh0b25zKHBhcmFtbGVuICsgYWRkcl9wYXJhbV9sZW4pOworCQlwYXJhbS5jcnJfaWQgPSBpOworCisJCXNjdHBfYWRkdG9fY2h1bmsocmV0dmFsLCBwYXJhbWxlbiwgJnBhcmFtKTsKKwkJc2N0cF9hZGR0b19jaHVuayhyZXR2YWwsIGFkZHJfcGFyYW1fbGVuLCAmYWRkcl9wYXJhbSk7CisKKwkJYWRkcl9idWYgKz0gYWYtPnNvY2thZGRyX2xlbjsKKwl9CisJcmV0dXJuIHJldHZhbDsKK30KKworLyogQURESVAKKyAqIDMuMi40IFNldCBQcmltYXJ5IElQIEFkZHJlc3MKKyAqCTAgICAgICAgICAgICAgICAgICAgMSAgICAgICAgICAgICAgICAgICAyICAgICAgICAgICAgICAgICAgIDMKKyAqCTAgMSAyIDMgNCA1IDYgNyA4IDkgMCAxIDIgMyA0IDUgNiA3IDggOSAwIDEgMiAzIDQgNSA2IDcgOCA5IDAgMQorICogICAgICstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rCisgKiAgICAgfCAgICAgICAgVHlwZSA9MHhDMDA0ICAgICAgICAgICB8ICAgIExlbmd0aCA9IFZhcmlhYmxlICAgICAgICAgIHwKKyAqICAgICArLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKworICogICAgIHwgICAgICAgICAgICAgICBBU0NPTkYtUmVxdWVzdCBDb3JyZWxhdGlvbiBJRCAgICAgICAgICAgICAgICAgICB8CisgKiAgICAgKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSsKKyAqICAgICB8ICAgICAgICAgICAgICAgICAgICAgICBBZGRyZXNzIFBhcmFtZXRlciAgICAgICAgICAgICAgICAgICAgICAg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ayhyZXR2YWwsIHNpemVvZihwYXJhbSksICZwYXJhbSk7CisJc2N0cF9hZGR0b19jaHVuayhyZXR2YWwsIGFkZHJsZW4sICZhZGRycGFyYW0pOworCisJcmV0dXJuIHJldHZhbDsKK30KKworLyogQURESVAgMy4xLjIgQWRkcmVzcyBDb25maWd1cmF0aW9uIEFja25vd2xlZGdlbWVudCBDaHVuayAoQVNDT05GLUFDSykKKyAqICAgICAgMCAgICAgICAgICAgICAgICAgICAxICAgICAgICAgICAgICAgICAgIDIgICAgICAgICAgICAgICAgICAgMworICogICAgICAwIDEgMiAzIDQgNSA2IDcgOCA5IDAgMSAyIDMgNCA1IDYgNyA4IDkgMCAxIDIgMyA0IDUgNiA3IDggOSAwIDEKKyAqICAgICArLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKworICogICAgIHwgVHlwZSA9IDB4ODAgICB8ICBDaHVuayBGbGFncyAgfCAgICAgIENodW5rIExlbmd0aCAgICAgICAgICAgICB8CisgKiAgICAgKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSsKKyAqICAgICB8ICAgICAgICAgICAgICAgICAgICAgICBTZXJpYWwgTnVtYmVyICAgICAgICAgICAgICAgICAgICAgICAgICAgfAorICogICAgICstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rCisgKiAgICAgfCAgICAgICAgICAgICAgICAgQVNDT05GIFBhcmFtZXRlciBSZXNwb25zZSMxICAgICAgICAgICAgICAgICAgIHwKKyAqICAgICArLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKworICogICAgIFwgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCisgKiAgICAgLyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLi4uLiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8KKyAqICAgICBcICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXAorICogICAgICstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rCisgKiAgICAgfCAgICAgICAgICAgICAgICAgQVNDT05GIFBhcmFtZXRlciBSZXNwb25zZSNOICAgICAgICAgICAgICAgICAgIHwKKyAqICAgICArLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKworICoKKyAqIENyZWF0ZSBhbiBBU0NPTkZfQUNLIGNodW5rIHdpdGggZW5vdWdoIHNwYWNlIGZvciB0aGUgcGFyYW1ldGVyIHJlc3BvbnNlcy4gCisgKi8KK3N0YXRpYyBzdHJ1Y3Qgc2N0cF9jaHVuayAqc2N0cF9tYWtlX2FzY29uZl9hY2soY29uc3Qgc3RydWN0IHNjdHBfYXNzb2NpYXRpb24gKmFzb2MsCisJCQkJCSAgICAgICBfX3UzMiBzZXJpYWwsIGludCB2cGFyYW1fbGVuKQoreworCXNjdHBfYWRkaXBoZHJfdAkJYXNjb25mOworCXN0cnVjdCBzY3RwX2NodW5rCSpyZXR2YWw7CisJaW50CQkJbGVuZ3RoID0gc2l6ZW9mKGFzY29uZikgKyB2cGFyYW1fbGVuOworCisJLyogQ3JlYXRlIHRoZSBjaHVuay4gICovCisJcmV0dmFsID0gc2N0cF9tYWtlX2NodW5rKGFzb2MsIFNDVFBfQ0lEX0FTQ09ORl9BQ0ssIDAsIGxlbmd0aCk7CisJaWYgKCFyZXR2YWwpCisJCXJldHVybiBOVUxMOworCisJYXNjb25mLnNlcmlhbCA9IGh0b25sKHNlcmlhbCk7CisKKwlyZ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VRJT05fVklPTEFUSU9OOgorCQlwcmludGsoS0VSTl9FUlIgInNjdHAgcHJvdG9jb2wgdmlvbGF0aW9uIHN0YXRlICVkICIKKwkJICAgICAgICJjaHVua2lkICVkXG4iLCBzdGF0ZSwgc3VidHlwZS5jaHVuayk7CisJCWJyZWFrOworCisJY2FzZSBTQ1RQX0RJU1BPU0lUSU9OX05PVF9JTVBMOgorCQlwcmludGsoS0VSTl9XQVJOSU5HICJzY3RwIHVuaW1wbGVtZW50ZWQgZmVhdHVyZSBpbiBzdGF0ZSAlZCwgIgorCQkgICAgICAgImV2ZW50X3R5cGUgJWQsIGV2ZW50X2lkICVkXG4iLAorCQkgICAgICAgc3RhdGUsIGV2ZW50X3R5cGUsIHN1YnR5cGUuY2h1bmspOworCQlicmVhazsKKworCWNhc2UgU0NUUF9ESVNQT1NJVElPTl9CVUc6CisJCXByaW50ayhLRVJOX0VSUiAic2N0cCBidWcgaW4gc3RhdGUgJWQsICIKKwkJICAgICAgICJldmVudF90eXBlICVkLCBldmVudF9pZCAlZFxuIiwKKwkJICAgICAgIHN0YXRlLCBldmVudF90eXBlLCBzdWJ0eXBlLmNodW5rKTsKKwkJQlVHKCk7CisJCWJyZWFrOworCisJZGVmYXVsdDoKKwkJcHJpbnRrKEtFUk5fRVJSICJzY3RwIGltcG9zc2libGUgZGlzcG9zaXRpb24gJWQgIgorCQkgICAgICAgImluIHN0YXRlICVkLCBldmVudF90eXBlICVkLCBldmVudF9pZCAlZFxuIiwKKwkJICAgICAgIHN0YXR1cywgc3RhdGUsIGV2ZW50X3R5cGUsIHN1YnR5cGUuY2h1bmspOworCQlCVUcoKTsKKwkJYnJlYWs7CisJfTsKKworYmFpbDoKKwlyZXR1cm4gZXJyb3I7Cit9CisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorICogMm5kIExldmVsIEFic3RyYWN0aW9ucworICoqKioqKioqKioqKioqKioqKioqKio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SBsZW5ndGguICBUaGUgJ3JlcXVpcmVkX2xlbmd0aCcgYXJndW1lbnQKKyAqIGlzIHNldCB0byBiZSB0aGUgc2l6ZSBvZiBhIHNwZWNpZmljIGNodW5rIHdlIGFyZSB0ZXN0aW5nLgorICogUmV0dXJuIFZhbHVlczogIDEgPSBWYWxpZCBsZW5ndGgKKyAqIAkJICAgMCA9IEludmFsaWQgbGVuZ3RoCisgKgorICovCitzdGF0aWMgaW5saW5lIGludAorc2N0cF9jaHVua19sZW5ndGhfdmFsaWQoc3RydWN0IHNjdHBfY2h1bmsgKmNodW5rLAorCQkJICAgX191MTYgcmVxdWlyZWRfbGVuZ3RoKQoreworCV9fdTE2IGNodW5rX2xlbmd0aCA9IG50b2hzKGNodW5rLT5jaHVua19oZHItPmxlbmd0aCk7CisKKwlpZiAodW5saWtlbHkoY2h1bmtfbGVuZ3RoIDwgcmVxdWlyZWRfbGVuZ3RoKSkKKwkJcmV0dXJuIDA7CisKKwlyZXR1cm4gMTsKK30KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyAqIFRoZXNlIGFyZSB0aGUgc3RhdGUgZnVuY3Rpb25zIGZvciBoYW5kbGluZyBjaHVuayBldmVudHMuCisgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKworLyoKKyAqIFByb2Nlc3MgdGhlIGZpbmFsIFNIVVRET1dOIENPTVBMRVRFLgorICoKKyAqIFNlY3Rpb246IDQgKEMpIChkaWFncmFtKSwgOS4yCisgKiBVcG9uIHJlY2VwdGlvbiBvZiB0aGUgU0hVVERPV04gQ09NUExFVEUgY2h1bmsgdGhlIGVuZHBvaW50IHdpbGwgdmVyaWZ5CisgKiB0aGF0IGl0IGlzIGluIFNIVVRET1dOLUFDSy1TRU5UIHN0YXRlLCBpZiBpdCBpcyBub3QgdGhlIGNodW5rIHNob3VsZCBiZQorICogZGlzY2Fy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tbWFuZHMsIFNDVFBfQ01EX0RJU0NBUkRfUEFDS0VULCBTQ1RQX05VTEwoKSk7CisKKwlTQ1RQX0lOQ19TVEFUUyhTQ1RQX01JQl9BQk9SVEVEUyk7CisJCisJcmV0dXJuIFNDVFBfRElTUE9TSVRJT05fQUJPUlQ7CisKK25vbWVtOgorCXJldHVybiBTQ1RQX0RJU1BPU0lUSU9OX05PTUVNOworfQorCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgKiBUaGVzZSBhcmUgdGhlIHN0YXRlIGZ1bmN0aW9ucyBmb3IgaGFuZGxpbmcgcHJpbWl0aXZlIChTZWN0aW9uIDEwKSBldmVudHMuCisgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworLyoKKyAqIHNjdHBfc2ZfZG9fcHJtX2Fzb2MKKyAqCisgKiBTZWN0aW9uOiAxMC4xIFVMUC10by1TQ1RQCisgKiBCKSBBc3NvY2lhdGUKKyAqCisgKiBGb3JtYXQ6IEFTU09DSUFURShsb2NhbCBTQ1RQIGluc3RhbmNlIG5hbWUsIGRlc3RpbmF0aW9uIHRyYW5zcG9ydCBhZGRyLAorICogb3V0Ym91bmQgc3RyZWFtIGNvdW50KQorICogLT4gYXNzb2NpYXRpb24gaWQgWyxkZXN0aW5hdGlvbiB0cmFuc3BvcnQgYWRkciBsaXN0XSBbLG91dGJvdW5kIHN0cmVhbQorICogY291bnRdCisgKgorICogVGhpcyBwcmltaXRpdmUgYWxsb3dzIHRoZSB1cHBlciBsYXllciB0byBpbml0aWF0ZSBhbiBhc3NvY2lhdGlvbiB0byBhCisgKiBzcGVjaWZpYyBwZWVyIGVuZHBvaW50LgorICoKKyAqIFRoZSBwZWVyIGVuZHBvaW50IHNoYWxsIGJlIHNwZWNpZmllZCBieSBvbmUgb2YgdGhlIHRyYW5z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wX2VuZHBvaW50ICplcCwKKwljb25zdCBzdHJ1Y3Qgc2N0cF9hc3NvY2lhdGlvbiAqYXNvYywKKwljb25zdCBzY3RwX3N1YnR5cGVfdCB0eXBlLAorCXZvaWQgKmFyZywKKwlzY3RwX2NtZF9zZXFfdCAqY29tbWFuZHMpCit7CisJU0NUUF9ERUJVR19QUklOVEsoIlByaW1pdGl2ZSB0eXBlICVkIGlzIGlnbm9yZWQuXG4iLCB0eXBlLnByaW1pdGl2ZSk7CisJcmV0dXJuIFNDVFBfRElTUE9TSVRJT05fRElTQ0FSRDsKK30KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorICogVGhlc2UgYXJlIHRoZSBzdGF0ZSBmdW5jdGlvbnMgZm9yIHRoZSBPVEhFUiBldmVudHMuCisgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworCisvKgorICogU3RhcnQgdGhlIHNodXRkb3duIG5lZ290aWF0aW9uLgorICoKKyAqIEZyb20gU2VjdGlvbiA5LjI6CisgKiBPbmNlIGFsbCBpdHMgb3V0c3RhbmRpbmcgZGF0YSBoYXMgYmVlbiBhY2tub3dsZWRnZWQsIHRoZSBlbmRwb2ludAorICogc2hhbGwgc2VuZCBhIFNIVVRET1dOIGNodW5rIHRvIGl0cyBwZWVyIGluY2x1ZGluZyBpbiB0aGUgQ3VtdWxhdGl2ZQorICogVFNOIEFjayBmaWVsZCB0aGUgbGFzdCBzZXF1ZW50aWFsIFRTTiBpdCBoYXMgcmVjZWl2ZWQgZnJvbSB0aGUgcGVlci4KKyAqIEl0IHNoYWxsIHRoZW4gc3RhcnQgdGhlIFQyLXNodXRkb3duIHRpbWVyIGFuZCBlbnRlciB0aGUgU0hVVERPV04tU0VOVAorICogc3RhdGUuIElmIHRoZSB0aW1lciBleHBpcmVzLCB0aGUgZ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zdCBzdHJ1Y3Qgc2N0cF9lbmRwb2ludCAqZXAsCisJCQkJCWNvbnN0IHN0cnVjdCBzY3RwX2Fzc29jaWF0aW9uICphc29jLAorCQkJCQljb25zdCBzY3RwX3N1YnR5cGVfdCB0eXBlLAorCQkJCQl2b2lkICphcmcsCisJCQkJCXNjdHBfY21kX3NlcV90ICpjb21tYW5kcykKK3sKKwlTQ1RQX0RFQlVHX1BSSU5USygiVGltZXIgJWQgaWdub3JlZC5cbiIsIHR5cGUuY2h1bmspOworCXJldHVybiBTQ1RQX0RJU1BPU0lUSU9OX0NPTlNVTUU7Cit9CisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorICogMm5kIExldmVsIEFic3RyYWN0aW9ucworICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworCisvKiBQdWxsIHRoZSBTQUNLIGNodW5rIGJhc2VkIG9uIHRoZSBTQUNLIGhlYWRlci4gKi8KK3N0YXRpYyBzdHJ1Y3Qgc2N0cF9zYWNraGRyICpzY3RwX3NtX3B1bGxfc2FjayhzdHJ1Y3Qgc2N0cF9jaHVuayAqY2h1bmspCit7CisJc3RydWN0IHNjdHBfc2Fja2hkciAqc2FjazsKKwl1bnNpZ25lZCBpbnQgbGVuOworCV9fdTE2IG51bV9ibG9ja3M7CisJX191MTYgbnVtX2R1cF90c25zOworCisJLyogUHJvdGVjdCBvdXJzZWx2ZXMgZnJvbSByZWFkaW5nIHRvbyBmYXIgaW50bworCSAqIHRoZSBza2IgZnJvbSBhIGJvZ3VzIHNlbmRlci4KKwkgKi8KKwlzYWNrID0gKHN0cnVjdCBzY3RwX3NhY2toZHIgKikgY2h1bmstPnNrYi0+ZGF0YTsKKworCW51bV9ibG9ja3MgPSBudG9ocyhzYWNrLT5udW1fZ2FwX2Fja19ibG9ja3MpOworCW51bV9kdXBfdHNucy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GUF9LRVJORUwpOworCWlmICghZXApCisJCXJldHVybiAtRU5PTUVNOworCisJc3AtPmVwID0gZXA7CisJc3AtPmhtYWMgPSBOVUxMOworCisJU0NUUF9EQkdfT0JKQ05UX0lOQyhzb2NrKTsKKwlyZXR1cm4gMDsKK30KKworLyogQ2xlYW51cCBhbnkgU0NUUCBwZXIgc29ja2V0IHJlc291cmNlcy4gICovCitTQ1RQX1NUQVRJQyBpbnQgc2N0cF9kZXN0cm95X3NvY2soc3RydWN0IHNvY2sgKnNrKQoreworCXN0cnVjdCBzY3RwX2VuZHBvaW50ICplcDsKKworCVNDVFBfREVCVUdfUFJJTlRLKCJzY3RwX2Rlc3Ryb3lfc29jayhzazogJXApXG4iLCBzayk7CisKKwkvKiBSZWxlYXNlIG91ciBob2xkIG9uIHRoZSBlbmRwb2ludC4gKi8KKwllcCA9IHNjdHBfc2soc2spLT5lcDsKKwlzY3RwX2VuZHBvaW50X2ZyZWUoZXApOworCisJcmV0dXJuIDA7Cit9CisKKy8qIEFQSSA0LjEuNyBzaHV0ZG93bigpIC0gVENQIFN0eWxlIFN5bnRheAorICogICAgIGludCBzaHV0ZG93bihpbnQgc29ja2V0LCBpbnQgaG93KTsKKyAqCisgKiAgICAgc2QgICAgICAtIHRoZSBzb2NrZXQgZGVzY3JpcHRvciBvZiB0aGUgYXNzb2NpYXRpb24gdG8gYmUgY2xvc2VkLgorICogICAgIGhvdyAgICAgLSBTcGVjaWZpZXMgdGhlIHR5cGUgb2Ygc2h1dGRvd24uICBUaGUgIHZhbHVlcyAgYXJlCisgKiAgICAgICAgICAgICAgIGFzIGZvbGxvd3M6CisgKiAgICAgICAgICAgICAgIFNIVVRfUkQKKyAqICAgICAgICAgICAgICAgICAgICAgRGlzYWJsZXMgZnVydGhlciByZWNlaXZlIG9wZXJhdGlvbnMuIE5vIFNDVFAKKyAqICAgICAgICAgICAgICAgICAgICAgcHJvdG9jb2wgYWN0aW9uIGlzIHRha2VuLgorICogICAgICAgICAgICAgICBT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aGljaCBhZGRyZXNzIGlzIG9mIGludGVyZXN0LgorICogICBzcHBfaGJpbnRlcnZhbCAgLSBUaGlzIGNvbnRhaW5zIHRoZSB2YWx1ZSBvZiB0aGUgaGVhcnRiZWF0IGludGVydmFsLAorICogICAgICAgICAgICAgICAgICAgICBpbiBtaWxsaXNlY29uZHMuICBBIHZhbHVlIG9mIDAsIHdoZW4gbW9kaWZ5aW5nIHRoZQorICogICAgICAgICAgICAgICAgICAgICBwYXJhbWV0ZXIsIHNwZWNpZmllcyB0aGF0IHRoZSBoZWFydGJlYXQgb24gdGhpcworICogICAgICAgICAgICAgICAgICAgICBhZGRyZXNzIHNob3VsZCBiZSBkaXNhYmxlZC4gQSB2YWx1ZSBvZiBVSU5UMzJfTUFYCisgKiAgICAgICAgICAgICAgICAgICAgICg0Mjk0OTY3Mjk1KSwgd2hlbiBtb2RpZnlpbmcgdGhlIHBhcmFtZXRlciwKKyAqICAgICAgICAgICAgICAgICAgICAgc3BlY2lmaWVzIHRoYXQgYSBoZWFydGJlYXQgc2hvdWxkIGJlIHNlbnQKKyAqICAgICAgICAgICAgICAgICAgICAgaW1tZWRpYXRlbHkgdG8gdGhlIHBlZXIgYWRkcmVzcywgYW5kIHRoZSBjdXJyZW50CisgKiAgICAgICAgICAgICAgICAgICAgIGludGVydmFsIHNob3VsZCByZW1haW4gdW5jaGFuZ2VkLgorICogICBzcHBfcGF0aG1heHJ4dCAgLSBUaGlzIGNvbnRhaW5zIHRoZSBtYXhpbXVtIG51bWJlciBvZgorICogICAgICAgICAgICAgICAgICAgICByZXRyYW5zbWlzc2lvbnMgYmVmb3JlIHRoaXMgYWRkcmVzcyBzaGFsbCBiZQorICogICAgICAgICAgICAgICAgICAgICBjb25zaWRlcmVkIHVucmVhY2hhYmxlLgorICovCitzdGF0aWMgaW50IHNjdHBfZ2V0c29ja29wdF9wZWVyX2FkZHJfcGFyYW1zKHN0cnVjdCBzb2NrICpzaywgaW50IGxlbiwKKwkJCQkJCWNoYXIgX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c2ssIENMT1NFRCkpCisJCXJldHVybiBtYXNrOworCisJLyogSXMgaXQgd3JpdGFibGU/ICAqLworCWlmIChzY3RwX3dyaXRlYWJsZShzaykpIHsKKwkJbWFzayB8PSBQT0xMT1VUIHwgUE9MTFdSTk9STTsKKwl9IGVsc2UgeworCQlzZXRfYml0KFNPQ0tfQVNZTkNfTk9TUEFDRSwgJnNrLT5za19zb2NrZXQtPmZsYWdzKTsKKwkJLyoKKwkJICogU2luY2UgdGhlIHNvY2tldCBpcyBub3QgbG9ja2VkLCB0aGUgYnVmZmVyCisJCSAqIG1pZ2h0IGJlIG1hZGUgYXZhaWxhYmxlIGFmdGVyIHRoZSB3cml0ZWFibGUgY2hlY2sgYW5kCisJCSAqIGJlZm9yZSB0aGUgYml0IGlzIHNldC4gIFRoaXMgY291bGQgY2F1c2UgYSBsb3N0IEkvTworCQkgKiBzaWduYWwuICB0Y3BfcG9sbCgpIGhhcyBhIHJhY2UgYnJlYWtlciBmb3IgdGhpcyByYWNlCisJCSAqIGNvbmRpdGlvbi4gIEJhc2VkIG9uIHRoZWlyIGltcGxlbWVudGF0aW9uLCB3ZSBwdXQKKwkJICogaW4gdGhlIGZvbGxvd2luZyBjb2RlIHRvIGNvdmVyIGl0IGFzIHdlbGwuCisJCSAqLworCQlpZiAoc2N0cF93cml0ZWFibGUoc2spKQorCQkJbWFzayB8PSBQT0xMT1VUIHwgUE9MTFdSTk9STTsKKwl9CisJcmV0dXJuIG1hc2s7Cit9CisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorICogMm5kIExldmVsIEFic3RyYWN0aW9ucworICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworCitzdGF0aWMgc3RydWN0IHNjdHBfYmluZF9idWNrZXQgKnNjdHBfYnVja2V0X2NyZWF0ZSgKKwlzdHJ1Y3Qgc2N0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BtdWx0aXBsZSBvYmplY3RzIHRvIGJlCisgKiBwYXNzZWQgaW4gYSBzaW5nbGUgY2FsbCB0byBzZW5kbXNnKCkgb3IgcmVjdm1zZygpLiBUaGUgZm9sbG93aW5nIGV4YW1wbGUKKyAqIHNob3dzIHR3byBhbmNpbGxhcnkgZGF0YSBvYmplY3RzIGluIGEgY29udHJvbCBidWZmZXIuCisgKgorICogICB8PC0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSBtc2dfY29udHJvbGxlbiAtLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLT58CisgKiAgIHwgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwKKyAqCisgKiAgIHw8LS0tLS0gYW5jaWxsYXJ5IGRhdGEgb2JqZWN0IC0tLS0tPnw8LS0tLS0gYW5jaWxsYXJ5IGRhdGEgb2JqZWN0IC0tLS0tPnwKKyAqCisgKiAgIHw8LS0tLS0tLS0tLSBDTVNHX1NQQUNFKCkgLS0tLS0tLS0tPnw8LS0tLS0tLS0tLSBDTVNHX1NQQUNFKCkgLS0tLS0tLS0tPnwKKyAqICAgfCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfAorICoKKyAqICAgfDwtLS0tLS0tLS0tIGNtc2dfbGVuIC0tLS0tLS0tLS0+fCAgfDwtLS0tLS0tLS0gY21zZ19sZW4gLS0tLS0tLS0tLS0+fCAgfAorICoKKyAqICAgfDwtLS0tLS0tLS0gQ01TR19MRU4oKSAtLS0tLS0tLS0+fCAgfDwtLS0tLS0tLSBDTVNHX0xFTigpIC0tLS0tLS0tLS0+fCAgfAorICogICB8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB8ICB8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB8ICB8CisgKgorICogICArLS0tLS0rLS0tLS0rLS0tLS0r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ZpeHVwIGFueSBpbnRlcm5hbCBUU04gbWFwcGluZyB2YXJpYWJsZXMgaW5jbHVkaW5nCisJICogY3VtdWxhdGl2ZV90c25fYWNrX3BvaW50LgorCSAqLworCXNjdHBfdHNubWFwX3VwZGF0ZShtYXApOworfQorCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyAqIDJuZCBMZXZlbCBBYnN0cmFjdGlvbnMKKyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKworLyogVGhpcyBwcml2YXRlIGhlbHBlciBmdW5jdGlvbiB1cGRhdGVzIHRoZSB0c25tYXAgYnVmZmVycyBhbmQKKyAqIHRoZSBDdW11bGF0aXZlIFRTTiBBY2sgUG9pbnQuCisgKi8KK3N0YXRpYyB2b2lkIHNjdHBfdHNubWFwX3VwZGF0ZShzdHJ1Y3Qgc2N0cF90c25tYXAgKm1hcCkKK3sKKwlfX3UzMiBjdHNuOworCisJY3RzbiA9IG1hcC0+Y3VtdWxhdGl2ZV90c25fYWNrX3BvaW50OworCWRvIHsKKwkJY3RzbisrOworCQlpZiAoY3RzbiA9PSBtYXAtPm92ZXJmbG93X3RzbikgeworCQkJLyogTm93IHRzbl9tYXAgbXVzdCBoYXZlIGJlZW4gYWxsICcxJ3MsCisJCQkgKiBzbyB3ZSBzd2FwIHRoZSBtYXAgYW5kIGNoZWNrIHRoZSBvdmVyZmxvdyB0YWJsZQorCQkJICovCisgICAgICAgIAkJX191OCAqdG1wID0gbWFwLT50c25fbWFwOworCQkJbWVtc2V0KHRtcCwgMCwgbWFwLT5sZW4pOworCQkJbWFwLT50c25fbWFwID0gbWFwLT5vdmVyZmxvd19tYXA7CisJCQltYXAtPm92ZXJmbG93X21hcCA9IHRtcDsKKworCQkJLyogVXBkYXRlIHRoZSB0c25fbWFwIGJvdW5kYXJpZXMuICAqLworCQkJbW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gICAgICAgICAgICAgIHRvdF9sZW4gKz0gdmVjdG9yW2ldLmlvdl9sZW47CisJcmV0dXJuIHNvY2tfcmVhZHZfd3JpdGV2KFZFUklGWV9XUklURSwgZmlsZS0+Zl9kZW50cnktPmRfaW5vZGUsCisJCQkJIGZpbGUsIHZlY3RvciwgY291bnQsIHRvdF9sZW4pOworfQorCQorc3RhdGljIHNzaXplX3Qgc29ja193cml0ZXYoc3RydWN0IGZpbGUgKmZpbGUsIGNvbnN0IHN0cnVjdCBpb3ZlYyAqdmVjdG9yLAorCQkJICAgdW5zaWduZWQgbG9uZyBjb3VudCwgbG9mZl90ICpwcG9zKQoreworCXNpemVfdCB0b3RfbGVuID0gMDsKKwlpbnQgaTsKKyAgICAgICAgZm9yIChpID0gMCA7IGkgPCBjb3VudCA7IGkrKykKKyAgICAgICAgICAgICAgICB0b3RfbGVuICs9IHZlY3RvcltpXS5pb3ZfbGVuOworCXJldHVybiBzb2NrX3JlYWR2X3dyaXRldihWRVJJRllfUkVBRCwgZmlsZS0+Zl9kZW50cnktPmRfaW5vZGUsCisJCQkJIGZpbGUsIHZlY3RvciwgY291bnQsIHRvdF9sZW4pOworfQorCisKKy8qCisgKiBBdG9taWMgc2V0dGluZyBvZiBpb2N0bCBob29rcyB0byBhdm9pZCByYWNlCisgKiB3aXRoIG1vZHVsZSB1bmxvYWQuCisgKi8KKworc3RhdGljIERFQ0xBUkVfTVVURVgoYnJfaW9jdGxfbXV0ZXgpOworc3RhdGljIGludCAoKmJyX2lvY3RsX2hvb2spKHVuc2lnbmVkIGludCBjbWQsIHZvaWQgX191c2VyICphcmcpID0gTlVMTDsKKwordm9pZCBicmlvY3RsX3NldChpbnQgKCpob29rKSh1bnNpZ25lZCBpbnQsIHZvaWQgX191c2VyICopKQoreworCWRvd24oJmJyX2lvY3RsX211dGV4KTsKKwlicl9pb2N0bF9ob29rID0gaG9vazsKKwl1cCgmYnJfaW9jdGxfbXV0ZXgpOworfQorRVhQT1JUX1NZTUJPTChic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jX2NsbnQgKmNsaWVudDsKKwlzdHJ1Y3QgZGVudHJ5ICpkZW50cnk7CisJY2hhciBwYXRoWzQ4XTsKKwlzcGlubG9ja190IGxvY2s7Cit9OworCitzdGF0aWMgdm9pZCBnc3NfZGVzdHJveV9jdHgoc3RydWN0IGdzc19jbF9jdHggKik7CitzdGF0aWMgc3RydWN0IHJwY19waXBlX29wcyBnc3NfdXBjYWxsX29wczsKKwordm9pZAorcHJpbnRfaGV4bCh1MzIgKnAsIHVfaW50IGxlbmd0aCwgdV9pbnQgb2Zmc2V0KQoreworCXVfaW50IGksIGosIGptOworCXU4IGMsICpjcDsKKwkKKwlkcHJpbnRrKCJSUEM6IHByaW50X2hleGw6IGxlbmd0aCAlZFxuIixsZW5ndGgpOworCWRwcmludGsoIlxuIik7CisJY3AgPSAodTggKikgcDsKKwkKKwlmb3IgKGkgPSAwOyBpIDwgbGVuZ3RoOyBpICs9IDB4MTApIHsKKwkJZHByaW50aygiICAlMDR4OiAiLCAodV9pbnQpKGkgKyBvZmZzZXQpKTsKKwkJam0gPSBsZW5ndGggLSBpOworCQlqbSA9IGptID4gMTYgPyAxNiA6IGptOworCQkKKwkJZm9yIChqID0gMDsgaiA8IGptOyBqKyspIHsKKwkJCWlmICgoaiAlIDIpID09IDEpCisJCQkJZHByaW50aygiJTAyeCAiLCAodV9pbnQpY3BbaStqXSk7CisJCQllbHNlCisJCQkJZHByaW50aygiJTAyeCIsICh1X2ludCljcFtpK2pdKTsKKwkJfQorCQlmb3IgKDsgaiA8IDE2OyBqKyspIHsKKwkJCWlmICgoaiAlIDIpID09IDEpCisJCQkJZHByaW50aygiICAgIik7CisJCQllbHNlCisJCQkJZHByaW50aygiICAiKTsKKwkJfQorCQlkcHJpbnRrKCIgIik7CisJCQorCQlmb3IgKGogPSAwOyBqIDwgam07IGorKykgeworCQkJYyA9IGNwW2kral07CisJCQljID0gaXNwcmludChjKSA/IGMgOiAnLic7CisJCQlkcHJpbnRrKCIlYyIsIGMpOworCQl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sKKwkqKHU4ICopaHB0cisrID0gZWxlbiArIDE7IC8qIGFkZCAxIHRvIGluY2x1ZGUgemJpdCAqLworCSoodTggKilocHRyKysgPSB6Yml0OworCW1lbWNweShocHRyLCBjdHhkYXRhLCBlbGVuKTsKKwlocHRyICs9IGVsZW47CisJKmhkcmxlbiA9IGhwdHIgLSB0b3A7IAorfQorCQkKKy8qIAorICogc3BrbTNfbWljX2lubmVyY29udGV4dF90b2tlbigpCisgKgorICogKnRva3AgcG9pbnRzIHRvIHRoZSBiZWdpbm5pbmcgb2YgdGhlIFNQS01fTUlDIHRva2VuICBkZXNjcmliZWQgCisgKiBpbiByZmMgMjAyNSwgc2VjdGlvbiAzLjIuMTogCisgKgorICovCit2b2lkCitzcGttM19tYWtlX21pY190b2tlbih1bnNpZ25lZCBjaGFyICoqdG9rcCwgaW50IHRva2xlbiwgc3RydWN0IHhkcl9uZXRvYmogKm1pY19oZHIsIHN0cnVjdCB4ZHJfbmV0b2JqICptZDVja3N1bSwgaW50IG1kNWVsZW4sIGludCBtZDV6Yml0KQoreworCXVuc2lnbmVkIGNoYXIgKmljdCA9ICp0b2twOworCisJKih1OCAqKWljdCsrID0gMHhhNDsKKwkqKHU4ICopaWN0KysgPSB0b2tsZW4gLSAyOyAKKwltZW1jcHkoaWN0LCBtaWNfaGRyLT5kYXRhLCBtaWNfaGRyLT5sZW4pOworCWljdCArPSBtaWNfaGRyLT5sZW47CisKKwkqKHU4ICopaWN0KysgPSAweDAzOworCSoodTggKilpY3QrKyA9IG1kNWVsZW4gKyAxOyAvKiBhZGQgMSB0byBpbmNsdWRlIHpiaXQgKi8KKwkqKHU4ICopaWN0KysgPSBtZDV6Yml0OworCW1lbWNweShpY3QsIG1kNWNrc3VtLT5kYXRhLCBtZDVlbGVuKTsKK30KKwordTMyCitzcGttM192ZXJpZnlfbWljX3Rva2VuKHVuc2lnbmVkIGNoYXIgKip0b2twLCBpbnQgKm1pY19oZHJsZW4sIHVuc2lnbmVkIGNoYXIgKip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fYXV0aCAqCitudWxfY3JlYXRlKHN0cnVjdCBycGNfY2xudCAqY2xudCwgcnBjX2F1dGhmbGF2b3JfdCBmbGF2b3IpCit7CisJYXRvbWljX2luYygmbnVsbF9hdXRoLmF1X2NvdW50KTsKKwlyZXR1cm4gJm51bGxfYXV0aDsKK30KKworc3RhdGljIHZvaWQKK251bF9kZXN0cm95KHN0cnVjdCBycGNfYXV0aCAqYXV0aCkKK3sKK30KKworLyoKKyAqIExvb2t1cCBOVUxMIGNyZWRzIGZvciBjdXJyZW50IHByb2Nlc3MKKyAqLworc3RhdGljIHN0cnVjdCBycGNfY3JlZCAqCitudWxfbG9va3VwX2NyZWQoc3RydWN0IHJwY19hdXRoICphdXRoLCBzdHJ1Y3QgYXV0aF9jcmVkICphY3JlZCwgaW50IGZsYWdzKQoreworCXJldHVybiBnZXRfcnBjY3JlZCgmbnVsbF9jcmVkKTsKK30KKworLyoKKyAqIERlc3Ryb3kgY3JlZCBoYW5kbGUuCisgKi8KK3N0YXRpYyB2b2lkCitudWxfZGVzdHJveV9jcmVkKHN0cnVjdCBycGNfY3JlZCAqY3JlZCkKK3sKK30KKworLyoKKyAqIE1hdGNoIGNyZWQgaGFuZGxlIGFnYWluc3QgY3VycmVudCBwcm9jZXNzCisgKi8KK3N0YXRpYyBpbnQKK251bF9tYXRjaChzdHJ1Y3QgYXV0aF9jcmVkICphY3JlZCwgc3RydWN0IHJwY19jcmVkICpjcmVkLCBpbnQgdGFza2ZsYWdzKQoreworCXJldHVybiAxOworfQorCisvKgorICogTWFyc2hhbCBjcmVkZW50aWFsLgorICovCitzdGF0aWMgdTMyICoKK251bF9tYXJzaGFsKHN0cnVjdCBycGNfdGFzayAqdGFzaywgdTMyICpwKQoreworCSpwKysgPSBodG9ubChSUENfQVVUSF9OVUxMKTsKKwkqcCsrID0gMDsKKwkqcCsrID0gaHRvbmwoUlBDX0FVVEhfTlVMTCk7CisJKnArKyA9IDA7CisKKwlyZXR1cm4gcDsKK30KKworLyoKKy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CisKKwl3aGlsZSAoKGM9KnN0cisrKSAmJiBsZW4pCisJCXN3aXRjaChjKSB7CisJCWNhc2UgJyAnOgorCQljYXNlICdcdCc6CisJCWNhc2UgJ1xuJzoKKwkJY2FzZSAnXFwnOgorCQkJaWYgKGxlbiA+PSA0KSB7CisJCQkJKmJwKysgPSAnXFwnOworCQkJCSpicCsrID0gJzAnICsgKChjICYgMDMwMCk+PjYpOworCQkJCSpicCsrID0gJzAnICsgKChjICYgMDA3MCk+PjMpOworCQkJCSpicCsrID0gJzAnICsgKChjICYgMDAwNyk+PjApOworCQkJfQorCQkJbGVuIC09IDQ7CisJCQlicmVhazsKKwkJZGVmYXVsdDoKKwkJCSpicCsrID0gYzsKKwkJCWxlbi0tOworCQl9CisJaWYgKGMgfHwgbGVuIDwxKSBsZW4gPSAtMTsKKwllbHNlIHsKKwkJKmJwKysgPSAnICc7CisJCWxlbi0tOworCX0KKwkqYnBwID0gYnA7CisJKmxwID0gbGVuOworfQorCit2b2lkIHF3b3JkX2FkZGhleChjaGFyICoqYnBwLCBpbnQgKmxwLCBjaGFyICpidWYsIGludCBibGVuKQoreworCWNoYXIgKmJwID0gKmJwcDsKKwlpbnQgbGVuID0gKmxwOworCisJaWYgKGxlbiA8IDApIHJldHVybjsKKworCWlmIChsZW4gPiAyKSB7CisJCSpicCsrID0gJ1xcJzsKKwkJKmJwKysgPSAneCc7CisJCWxlbiAtPSAyOworCQl3aGlsZSAoYmxlbiAmJiBsZW4gPj0gMikgeworCQkJdW5zaWduZWQgY2hhciBjID0gKmJ1ZisrOworCQkJKmJwKysgPSAnMCcgKyAoKGMmMHhmMCk+PjQpICsgKGM+PTB4YTApKignYSctJzknLTEpOworCQkJKmJwKysgPSAnMCcgKyAoYyYweDBmKSArICgoYyYweDBmKT49MHgwYSkqKCdhJy0nOSctMSk7CisJCQlsZW4gLT0gMjsKKwkJCWJsZW4tLTsKKwkJfQorCX0KKwlpZiAoYmxlbiB8fCBsZW48MSkgbGVuID0gLTE7C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GFzaykKKwkJZ290byBjbGVhbnVwOworCisJcnBjX2luaXRfdGFzayh0YXNrLCBjbG50LCBjYWxsYmFjaywgZmxhZ3MpOworCisJLyogUmVwbGFjZSB0a19yZWxlYXNlICovCisJdGFzay0+dGtfcmVsZWFzZSA9IHJwY19kZWZhdWx0X2ZyZWVfdGFzazsKKworCWRwcmludGsoIlJQQzogJTRkIGFsbG9jYXRlZCB0YXNrXG4iLCB0YXNrLT50a19waWQpOworCXRhc2stPnRrX2ZsYWdzIHw9IFJQQ19UQVNLX0RZTkFNSUM7CitvdXQ6CisJcmV0dXJuIHRhc2s7CisKK2NsZWFudXA6CisJLyogQ2hlY2sgd2hldGhlciB0byByZWxlYXNlIHRoZSBjbGllbnQgKi8KKwlpZiAoY2xudCkgeworCQlwcmludGsoInJwY19uZXdfdGFzazogZmFpbGVkLCB1c2Vycz0lZCwgb25lc2hvdD0lZFxuIiwKKwkJCWF0b21pY19yZWFkKCZjbG50LT5jbF91c2VycyksIGNsbnQtPmNsX29uZXNob3QpOworCQlhdG9taWNfaW5jKCZjbG50LT5jbF91c2Vycyk7IC8qIHByZXRlbmQgd2Ugd2VyZSB1c2VkIC4uLiAqLworCQlycGNfcmVsZWFzZV9jbGllbnQoY2xudCk7CisJfQorCWdvdG8gb3V0OworfQorCit2b2lkIHJwY19yZWxlYXNlX3Rhc2soc3RydWN0IHJwY190YXNrICp0YXNrKQoreworCWRwcmludGsoIlJQQzogJTRkIHJlbGVhc2UgdGFza1xuIiwgdGFzay0+dGtfcGlkKTsKKworI2lmZGVmIFJQQ19ERUJVRworCUJVR19PTih0YXNrLT50a19tYWdpYyAhPSBSUENfVEFTS19NQUdJQ19JRCk7CisjZW5kaWYKKworCS8qIFJlbW92ZSBmcm9tIGdsb2JhbCB0YXNrIGxpc3QgKi8KKwlzcGluX2xvY2soJnJwY19zY2hlZF9sb2NrKTsKKwlsaXN0X2RlbCgmdGFzay0+dGtfdGFzayk7CisJc3Bpbl91bmxvY2soJnJwY19zY2h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9oZWFkICpsaXN0LCBzdHJ1Y3Qgc29jayAqc2spCit7CisJQlVHX1RSQVAoc2tfdW5oYXNoZWQoc2spKTsKKwlza19hZGRfbm9kZShzaywgbGlzdCk7Cit9CisKK3N0YXRpYyBpbmxpbmUgdm9pZCB1bml4X3JlbW92ZV9zb2NrZXQoc3RydWN0IHNvY2sgKnNrKQoreworCXdyaXRlX2xvY2soJnVuaXhfdGFibGVfbG9jayk7CisJX191bml4X3JlbW92ZV9zb2NrZXQoc2spOworCXdyaXRlX3VubG9jaygmdW5peF90YWJsZV9sb2NrKTsKK30KKworc3RhdGljIGlubGluZSB2b2lkIHVuaXhfaW5zZXJ0X3NvY2tldChzdHJ1Y3QgaGxpc3RfaGVhZCAqbGlzdCwgc3RydWN0IHNvY2sgKnNrKQoreworCXdyaXRlX2xvY2soJnVuaXhfdGFibGVfbG9jayk7CisJX191bml4X2luc2VydF9zb2NrZXQobGlzdCwgc2spOworCXdyaXRlX3VubG9jaygmdW5peF90YWJsZV9sb2NrKTsKK30KKworc3RhdGljIHN0cnVjdCBzb2NrICpfX3VuaXhfZmluZF9zb2NrZXRfYnluYW1lKHN0cnVjdCBzb2NrYWRkcl91biAqc3VubmFtZSwKKwkJCQkJICAgICAgaW50IGxlbiwgaW50IHR5cGUsIHVuc2lnbmVkIGhhc2gpCit7CisJc3RydWN0IHNvY2sgKnM7CisJc3RydWN0IGhsaXN0X25vZGUgKm5vZGU7CisKKwlza19mb3JfZWFjaChzLCBub2RlLCAmdW5peF9zb2NrZXRfdGFibGVbaGFzaCBeIHR5cGVdKSB7CisJCXN0cnVjdCB1bml4X3NvY2sgKnUgPSB1bml4X3NrKHMpOworCisJCWlmICh1LT5hZGRyLT5sZW4gPT0gbGVuICYmCisJCSAgICAhbWVtY21wKHUtPmFkZHItPm5hbWUsIHN1bm5hbWUsIGxlbikpCisJCQlnb3RvIGZvdW5kOworCX0KKwlzID0gTlVMTDsKK2ZvdW5kOgorCXJldHVybiBzOworfQorCitzdGF0aW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IGFyZSBzdGlsbCBhbGl2ZS5cbiIsIHNrLCBhdG9taWNfcmVhZCgmdW5peF9ucl9zb2NrcykpOworI2VuZGlmCit9CisKK3N0YXRpYyBpbnQgdW5peF9yZWxlYXNlX3NvY2sgKHN0cnVjdCBzb2NrICpzaywgaW50IGVtYnJpb24pCit7CisJc3RydWN0IHVuaXhfc29jayAqdSA9IHVuaXhfc2soc2spOworCXN0cnVjdCBkZW50cnkgKmRlbnRyeTsKKwlzdHJ1Y3QgdmZzbW91bnQgKm1udDsKKwlzdHJ1Y3Qgc29jayAqc2twYWlyOworCXN0cnVjdCBza19idWZmICpza2I7CisJaW50IHN0YXRlOworCisJdW5peF9yZW1vdmVfc29ja2V0KHNrKTsKKworCS8qIENsZWFyIHN0YXRlICovCisJdW5peF9zdGF0ZV93bG9jayhzayk7CisJc29ja19vcnBoYW4oc2spOworCXNrLT5za19zaHV0ZG93biA9IFNIVVRET1dOX01BU0s7CisJZGVudHJ5CSAgICAgPSB1LT5kZW50cnk7CisJdS0+ZGVudHJ5ICAgID0gTlVMTDsKKwltbnQJICAgICA9IHUtPm1udDsKKwl1LT5tbnQJICAgICA9IE5VTEw7CisJc3RhdGUgPSBzay0+c2tfc3RhdGU7CisJc2stPnNrX3N0YXRlID0gVENQX0NMT1NFOworCXVuaXhfc3RhdGVfd3VubG9jayhzayk7CisKKwl3YWtlX3VwX2ludGVycnVwdGlibGVfYWxsKCZ1LT5wZWVyX3dhaXQpOworCisJc2twYWlyPXVuaXhfcGVlcihzayk7CisKKwlpZiAoc2twYWlyIT1OVUxMKSB7CisJCWlmIChzay0+c2tfdHlwZSA9PSBTT0NLX1NUUkVBTSB8fCBzay0+c2tfdHlwZSA9PSBTT0NLX1NFUVBBQ0tFVCkgeworCQkJdW5peF9zdGF0ZV93bG9jayhza3BhaXIpOworCQkJLyogTm8gbW9yZSB3cml0ZXMgKi8KKwkJCXNrcGFpci0+c2tfc2h1dGRvd24gPSBTSFVURE9XTl9NQVNLOworCQkJaWY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ICh1bml4X3BlZXIoc2spID09IG90aGVyKSB7CisJCQl1bml4X3BlZXIoc2spPU5VTEw7CisJCQl1bml4X3N0YXRlX3d1bmxvY2soc2spOworCisJCQl1bml4X2RncmFtX2Rpc2Nvbm5lY3RlZChzaywgb3RoZXIpOworCQkJc29ja19wdXQob3RoZXIpOworCQkJZXJyID0gLUVDT05OUkVGVVNFRDsKKwkJfSBlbHNlIHsKKwkJCXVuaXhfc3RhdGVfd3VubG9jayhzayk7CisJCX0KKworCQlvdGhlciA9IE5VTEw7CisJCWlmIChlcnIpCisJCQlnb3RvIG91dF9mcmVlOworCQlnb3RvIHJlc3RhcnQ7CisJfQorCisJZXJyID0gLUVQSVBFOworCWlmIChvdGhlci0+c2tfc2h1dGRvd24gJiBSQ1ZfU0hVVERPV04pCisJCWdvdG8gb3V0X3VubG9jazsKKworCWlmIChzay0+c2tfdHlwZSAhPSBTT0NLX1NFUVBBQ0tFVCkgeworCQllcnIgPSBzZWN1cml0eV91bml4X21heV9zZW5kKHNrLT5za19zb2NrZXQsIG90aGVyLT5za19zb2NrZXQpOworCQlpZiAoZXJyKQorCQkJZ290byBvdXRfdW5sb2NrOworCX0KKworCWlmICh1bml4X3BlZXIob3RoZXIpICE9IHNrICYmCisJICAgIChza2JfcXVldWVfbGVuKCZvdGhlci0+c2tfcmVjZWl2ZV9xdWV1ZSkgPgorCSAgICAgb3RoZXItPnNrX21heF9hY2tfYmFja2xvZykpIHsKKwkJaWYgKCF0aW1lbykgeworCQkJZXJyID0gLUVBR0FJTjsKKwkJCWdvdG8gb3V0X3VubG9jazsKKwkJfQorCisJCXRpbWVvID0gdW5peF93YWl0X2Zvcl9wZWVyKG90aGVyLCB0aW1lbyk7CisKKwkJZXJyID0gc29ja19pbnRyX2Vycm5vKHRpbWVvKTsKKwkJaWYgKHNpZ25hbF9wZW5kaW5nKGN1cnJlbnQpKQorCQkJZ290byBvdXRfZnJlZTsKKworCQlnb3RvIHJlc3RhcnQ7CisJfQorCisJc2tiX3F1ZXVlX3RhaWwoJm90aGVyLT5za19yZWNlaXZlX3F1ZXVlLCBza2IpOworCXVuaXhfc3RhdGVfcnVubG9jayhvdGhlcik7CisJb3RoZXItPnNrX2RhdGFfcmVhZHkob3RoZXIsIGxlbik7CisJc29ja19wdXQob3RoZXIpOworCXNjbV9kZXN0cm95KHNpb2NiLT5zY20pOworCXJldHVybiBsZW47CisKK291dF91bmxvY2s6CisJdW5peF9zdGF0ZV9ydW5sb2NrKG90aGVyKTsKK291dF9mcmVlOgorCWtmcmVlX3NrYihza2IpOworb3V0OgorCWlmIChvdGhlcikKKwkJc29ja19wdXQob3RoZXIpOworCXNjbV9kZXN0cm95KHNpb2NiLT5zY20pOworCXJldHVybiBlcnI7Cit9CisKKwkJCitzdGF0aWMgaW50IHVuaXhfc3RyZWFtX3NlbmRtc2coc3RydWN0IGtpb2NiICpraW9jYiwgc3RydWN0IHNvY2tldCAqc29jaywKKwkJCSAgICAgICBzdHJ1Y3QgbXNnaGRyICptc2csIHNpemVfdCBsZW4pCit7CisJc3RydWN0IHNvY2tfaW9jYiAqc2lvY2IgPSBraW9jYl90b19zaW9jYihraW9jYik7CisJc3RydWN0IHNvY2sgKnNrID0gc29jay0+c2s7CisJc3RydWN0IHNvY2sgKm90aGVyID0gTlVMTDsKKwlzdHJ1Y3Qgc29ja2FkZHJfdW4gKnN1bmFkZHI9bXNnLT5tc2dfbmFtZTsKKwlpbnQgZXJyLHNpemU7CisJc3RydWN0IHNrX2J1ZmYgKnNrYjsKKwlpbnQgc2VudD0wOworCXN0cnVjdCBzY21fY29va2llIHRtcF9zY207CisKKwlpZiAoTlVMTCA9PSBzaW9jYi0+c2NtKQorCQlzaW9jYi0+c2NtID0gJnRtcF9zY207CisJZXJyID0gc2NtX3NlbmQoc29jaywgbXNnLCBzaW9jYi0+c2NtKTsKKwlpZiAoZXJyIDwgMCkKKwkJcmV0dXJuIGVycjsKKworCWVyciA9IC1FT1BOT1RTVVBQOworCWlmIChtc2ctPm1zZ19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lzZW50Kz1zaXplOworCX0KKwlzb2NrX3B1dChvdGhlcik7CisKKwlzY21fZGVzdHJveShzaW9jYi0+c2NtKTsKKwlzaW9jYi0+c2NtID0gTlVMTDsKKworCXJldHVybiBzZW50OworCitwaXBlX2Vycl9mcmVlOgorCXVuaXhfc3RhdGVfcnVubG9jayhvdGhlcik7CisJa2ZyZWVfc2tiKHNrYik7CitwaXBlX2VycjoKKwlpZiAoc2VudD09MCAmJiAhKG1zZy0+bXNnX2ZsYWdzJk1TR19OT1NJR05BTCkpCisJCXNlbmRfc2lnKFNJR1BJUEUsY3VycmVudCwwKTsKKwllcnIgPSAtRVBJUEU7CitvdXRfZXJyOgorICAgICAgICBpZiAob3RoZXIpCisJCXNvY2tfcHV0KG90aGVyKTsKKwlzY21fZGVzdHJveShzaW9jYi0+c2NtKTsKKwlzaW9jYi0+c2NtID0gTlVMTDsKKwlyZXR1cm4gc2VudCA/IDogZXJyOworfQorCitzdGF0aWMgaW50IHVuaXhfc2VxcGFja2V0X3NlbmRtc2coc3RydWN0IGtpb2NiICpraW9jYiwgc3RydWN0IHNvY2tldCAqc29jaywKKwkJCQkgIHN0cnVjdCBtc2doZHIgKm1zZywgc2l6ZV90IGxlbikKK3sKKwlpbnQgZXJyOworCXN0cnVjdCBzb2NrICpzayA9IHNvY2stPnNrOworCQorCWVyciA9IHNvY2tfZXJyb3Ioc2spOworCWlmIChlcnIpCisJCXJldHVybiBlcnI7CisKKwlpZiAoc2stPnNrX3N0YXRlICE9IFRDUF9FU1RBQkxJU0hFRCkKKwkJcmV0dXJuIC1FTk9UQ09OTjsKKworCWlmIChtc2ctPm1zZ19uYW1lbGVuKQorCQltc2ctPm1zZ19uYW1lbGVuID0gMDsKKworCXJldHVybiB1bml4X2RncmFtX3NlbmRtc2coa2lvY2IsIHNvY2ssIG1zZywgbGVuKTsKK30KKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC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0aGUgdGVybXMgb2YgdGhlIEdOVSBHZW5lcmFsIFB1YmxpYyBMaWNlbnNlCisqCQlhcyBwdWJsaXNoZWQgYnkgdGhlIEZyZWUgU29mdHdhcmUgRm91bmRhdGlvbjsgZWl0aGVyIHZlcnNpb24KKyoJCTIgb2YgdGhlIExpY2Vuc2UsIG9yIChhdCB5b3VyIG9wdGlvbikgYW55IGxhdGVyIHZlcnNpb24uCisqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyogRHVlIENyZWRpdDoKKyogICAgICAgICAgICAgICBXYW5waXBlIHNvY2tldCBsYXllciBpcyBiYXNlZCBvbiBQYWNrZXQgYW5kIAorKiAgICAgICAgICAgICAgIHRoZSBYMjUgc29ja2V0IGxheWVycy4gVGhlIGFib3ZlIHNvY2tldHMgd2VyZSAKKyogICAgICAgICAgICAgICB1c2VkIGZvciB0aGUgc3BlY2lmaWMgdXNlIG9mIFNhbmdvbWEgVGVjaG5vbG9pZ2VzIAorKiAgICAgICAgICAgICAgIEFQSSBwcm9ncmFtcy4gCisqICAgICAgICAgICAgICAgUGFja2V0IHNvY2tldCBBdXRob3JzOiBSb3NzIEJpcm8sIEZyZWQgTi4gdmFuIEtlbXBlbiBhbmQgCisqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBBbGFuIENveC4KKyogICAgICAgICAgICAgICBYMjUgc29ja2V0IEF1dGhvcjogSm9uYXRoYW4gTmF5bG9yLgorKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisqIE1hciAxNSwgMjAwMiAgQXJuYWxkbyBDLiBNZWxvICBvIFVzZSB3cF9zaygpLT5udW0sIGFzIGl0IGlzbnQgYW55bW9yZSBpbiBzb2NrCisqIEFwciAyNSwgMjAwMCAgTmVuYWQgQ29yYmljICAgICBvIEFkZGVkIHRoZSBhYmlsaXR5IHRvIHNlbmQgemVybyBsZW5ndGggcGFja2V0cy4KKyogTWFyIDEzLCAyMDAwICBOZW5hZCBDb3JiaWMJIG8gQWRkZWQgYSB0eCBidWZmZXIgY2hlY2sgdmlhIGlvY3RsIGNhbGwuCisqIE1hciAwNiwgMjAwMCAgTmVuYWQgQ29yYmljICAgICBvIEZpeGVkIHRoZSBjb3JydXB0IHNvY2sgbGNuIHByb2JsZW0uCisqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFNlcnZlciBhbmQgY2xpZW50IGFwcGxpY2F0b24gY2FuIHJ1bgorKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaW11bHRhbmVvdXNseSB3aXRob3V0IGNvbmZsaWN0cy4KKyogRmViIDI5LCAyMDAwICBOZW5hZCBDb3JiaWMgICAgIG8gQWRkZWQgc3VwcG9ydCBmb3IgUFZDIHByb3RvY29scywgc3VjaCBhcworKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDSERMQywgRnJhbWUgUmVsYXkgYW5kIEhETEMgQVBJLgorKiBKYW4gMTcsIDIwMDAgCU5lbmFkIENvcmJpYwkgbyBJbml0aWFsIHZlcnNpb24sIGJhc2VkIG9uIEFGX1BBQ0tFVCBzb2NrZXQuCisqCQkJICAgICAgICAgICBYMjVBUEkgc3VwcG9ydCBvbmx5LiAKKyoKKyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKworI2luY2x1ZGUgPGxpbnV4L2NvbmZpZy5oPgorI2luY2x1ZGUgPGxpbnV4L3R5cGVzLmg+CisjaW5jbHVkZSA8bGludXgvc2NoZWQuaD4KKyNpbmNsdWRlIDxsaW51eC9tbS5oPgorI2luY2x1ZGUgPGxpbnV4L2ZjbnRsLmg+CisjaW5jbHVkZSA8bGludXgvc29ja2V0Lmg+CisjaW5jbHVkZSA8bGludXgvaW4uaD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dGlzdGljcyB3aWxsIGJlIGdlbmVyYXRlZC4gCisgKi8KKworCisvKiBUaGUgY29kZSBiZWxvdyBpcyB1c2VkIHRvIHRlc3QgbWVtb3J5IGxlYWtzLiBJdCBwcmludHMgb3V0CisgKiBhIG1lc3NhZ2UgZXZlcnkgdGltZSBrbWFsbG9jIGFuZCBrZnJlZSBzeXN0ZW0gY2FsbHMgZ2V0IGV4ZWN1dGVkLgorICogSWYgdGhlIGNhbGxzIG1hdGNoIHRoZXJlIGlzIG5vIGxlYWsgOikKKyAqLworCisvKioqKioqKioqKipGT1IgREVCVUdHSU5HIFBVUlBPU0VTKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisjZGVmaW5lIEtNRU1fU0FGRVRZWk9ORSA4CisKK3N0YXRpYyB2b2lkICogZGJnX2ttYWxsb2ModW5zaWduZWQgaW50IHNpemUsIGludCBwcmlvLCBpbnQgbGluZSkgeworCXZvaWQgKiB2ID0ga21hbGxvYyhzaXplLHByaW8pOworCXByaW50ayhLRVJOX0lORk8gImxpbmUgJWQgIGttYWxsb2MoJWQsJWQpID0gJXBcbiIsbGluZSxzaXplLHByaW8sdik7CisJcmV0dXJuIHY7Cit9CitzdGF0aWMgdm9pZCBkYmdfa2ZyZWUodm9pZCAqIHYsIGludCBsaW5lKSB7CisJcHJpbnRrKEtFUk5fSU5GTyAibGluZSAlZCAga2ZyZWUoJXApXG4iLGxpbmUsdik7CisJa2ZyZWUodik7Cit9CisKKyNkZWZpbmUga21hbGxvYyh4LHkpIGRiZ19rbWFsbG9jKHgseSxfX0xJTkVfXykKKyNkZWZpbmUga2ZyZWUoeCkgZGJnX2tmcmVlKHgsX19MSU5FX18pCisqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisKKworLyogTGlzdCBvZiBhbGwgd2FucGlwZSBzb2NrZXRzLiAqLworSExJU1RfSEVBRCh3YW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ZyZWVfc2tiKHNrYik7CisJCQlicmVhazsKKwkJY2FzZSBXQU5fUEFDS0VUX0VSUjoKKwkJCXNrLT5za19zdGF0ZSA9IGNoYW4tPnN0YXRlOworCQkJaWYgKHNvY2tfcXVldWVfZXJyX3NrYihzayxza2IpPDApeworCQkJCXJldHVybiAtRU5PTUVNOworCQkJfQorCQkJYnJlYWs7CisJCWRlZmF1bHQ6CisJCQlwcmludGsoS0VSTl9JTkZPICJ3YW5zb2NrOiBCSCBJbGxlZ2FsIFBhY2tldCBUeXBlIERyb3BwaW5nXG4iKTsKKwkJCWtmcmVlX3NrYihza2IpOyAKKwkJCWJyZWFrOworCX0KKworLy8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/CisvLwlpZiAoc2stPnNrX3N0YXRlID09IFdBTlNPQ0tfRElTQ09OTkVDVEVEKXsKKy8vCQlpZiAoc2stPnNrX3phcHBlZCkgeworLy8JCQkvL3ByaW50ayhLRVJOX0lORk8gIndhbnNvY2s6IERpc2Nvbm5lY3RlZCwga2lsbGluZyBlYXJseVxuIik7CisvLwkJCXdhbnBpcGVfdW5saW5rX2RyaXZlcihzayk7CisvLwkJCXNrLT5za19ib3VuZF9kZXZfaWYgPSAwOworLy8JCX0KKy8vCX0KKworCXJldHVybiAwOworfQorCisvKj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogd2FucGlwZV9saXN0ZW5fcmN2CisgKgorICoJV2FucGlwZSBMSVNURU4gc29ja2V0IGJvdHRvbSBoYWxmIGhhbmRsZXIuICBUaGlzIGZ1bmN0aW9uCisgKiAgICAgIGlzIGNhbGxlZCBieSB0aGUgV0FOUElQRSBkZXZpY2UgZHJpdmVycyB0byBxdWV1ZSBhbgorICogICAgICBpbmNvbWluZyBjYWxsIGludG8gdGhlIHNvY2tldCBsaXN0ZW5pbmcgcXVldWUuIAorICogICAgICBPbmNlIHRoZSBwYWNrZXQgaXMgcXVldWVkLCB0aGUgd2FpdGluZyBhY2NlcHQoKSBwcm9jZXNzIAorICogICAgICBpcyB3b2tlbiB1cC4KKyAqCisgKiAgICAgIER1cmluZyBzb2NrZXQgYmluZCwgdGhpcyBmdW5jdGlvbiBpcyBib3VuZGVkIGludG8KKyAqICAgICAgV0FOUElQRSBkcml2ZXIgcHJpdmF0ZS4gCisgKiAKKyAqICAgICAgSU1QT1JUQU5UIE5PVEU6CisgKiAgICAgICAgICBUaGUgYWNjZXB0IGNhbGwoKSBpcyB3YWl0aW5nIGZvciBhbiBza2IgcGFja2V0CisgKiAgICAgICAgICB3aGljaCBjb250YWlucyBhIHBvaW50ZXIgdG8gYSBkZXZpY2Ugc3RydWN0dXJlLgorICoKKyAqICAgICAgICAgIFdoZW4gd2UgZG8gYSBiaW5kIHRvIGEgZGV2aWNlIHN0cnVjdHJlLCB3ZSAKKyAqICAgICAgICAgIGJpbmQgYSBuZXdseSBjcmVhdGVkIHNvY2tldCBpbnRvICJjaGFuLT5zayIuICBUaHVzLCAKKyAqICAgICAgICAgIHdoZW4gYWNjZXB0IHJlY2VpdmVzIHRoZSBza2IgcGFja2V0LCBpdCB3aWxsIGtub3cgCisgKiAgICAgICAgICBmcm9tIHdoaWNoIGRldiBpdCBjYW1lIGZvcm0sIGFuZCBpbiB0dXJuIGl0IHdpbGwga25vdworICogICAgICAgICAgdGhlIGFkZHJlc3Mgb2YgdGhlIG5ldyBzb2NrLgorICoKKyAqICAJTk9URTogVGhpcyBmdW5jdGlvbiBnZXRzIGNhbGxlZCBmcm9tIGRyaXZlciBJU1IuCisgKj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ki8KKworc3RhdGljIGludCB3YW5waXBlX2xpc3Rlbl9yY3YgKHN0cnVjdCBza19idWZmICpza2IsICBzdHJ1Y3Qgc29jayAqc2spCit7CisJd2FucGlwZV9vcHQgKndwID0gd3Bfc2soc2spLCAqbmV3d3A7CisJc3RydWN0IHd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ICBIb3dldmVyLCB3ZSB1c2UKKwkgKiB0aGUgZGV2IGZpZWxkIGluIHRoZSBhY2NlcHQgZnVuY3Rpb24uKi8gCisJaWYgKGF0b21pY19yZWFkKCZzay0+c2tfcm1lbV9hbGxvYykgKyBza2ItPnRydWVzaXplID49IAorCSAgICAodW5zaWduZWQpc2stPnNrX3JjdmJ1ZikgeworCisgICAgICAgICAJd2FucGlwZV91bmxpbmtfZHJpdmVyKG5ld3NrKTsKKwkJd2FucGlwZV9raWxsX3NvY2tfaXJxIChuZXdzayk7CisJCS0tc2stPnNrX2Fja19iYWNrbG9nOworCQlyZXR1cm4gLUVOT01FTTsKKwl9CQorCisJc2tiX3NldF9vd25lcl9yKHNrYiwgc2spOworCXNrYl9xdWV1ZV90YWlsKCZzay0+c2tfcmVjZWl2ZV9xdWV1ZSwgc2tiKTsKKwlzay0+c2tfZGF0YV9yZWFkeShzaywgc2tiLT5sZW4pOworCQorCXJldHVybiAwOworfQorCisKKworLyo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIHdhbnBpcGVfbWFrZV9uZXcKKyAqCisgKglDcmVhdGUgYSBuZXcgc29jaywgYW5kIGFsbG9jYXRlIGEgd2FucGlwZSBwcml2YXRlCisgKiAgICAgIHN0cnVjdHVyZSB0byBpdC4gQWxzbywgY29weSB0aGUgaW1wb3J0YW50IGRhdGEKKyAqICAgICAgZnJvbSB0aGUgb3JpZ2luYWwgc29jayB0byB0aGUgbmV3IHNvY2suCisgKgorICogICAgICBUaGlzIGZ1bmN0aW9uIGlzIHVzZWQgYnkgd2FucGlwZV9saXN0ZW5fcmN2KCkgbGlzdGVuCisgKiAgICAgIGJvdHRvbSBoYWxmIGhhbmRsZXIuICBBIGNvcHkgb2YgdGhlIGxpc3RlbmluZyBzb2NrCisgKiAgICAgIGlzIGNyZWF0ZWQgdXNpbmcgdGhpcyBmdW5jdGlvbi4KKyAqCisgKj09PT09PT09PT09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B3YW5waXBlX3Byb3RvID0geworCS5uYW1lCSAgPSAiV0FOUElQRSIsCisJLm93bmVyCSAgPSBUSElTX01PRFVMRSwKKwkub2JqX3NpemUgPSBzaXplb2Yoc3RydWN0IHNvY2spLAorfTsKKworLyo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIHdhbnBpcGVfbWFrZV9uZXcKKyAqCisgKglBbGxvY2F0ZSBtZW1vcnkgZm9yIHRoZSBhIG5ldyBzb2NrLCBhbmQgc29jaworICogICAgICBwcml2YXRlIGRhdGEuICAKKyAqCQorICoJSW5jcmVtZW50IHRoZSBtb2R1bGUgdXNlIGNvdW50LgorICogICAgICAgCQorICogICAgICBUaGlzIGZ1bmN0aW9uIGlzIHVzZWQgYnkgd2FucGlwZV9jcmVhdGUoKSBhbmQgCisgKiAgICAgIHdhbnBpcGVfbWFrZV9uZXcoKSBmdW5jdGlvbnMuIAorICoKKyAqPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0qLworCitzdGF0aWMgc3RydWN0IHNvY2sgKndhbnBpcGVfYWxsb2Nfc29ja2V0KHZvaWQpCit7CisJc3RydWN0IHNvY2sgKnNrOworCXN0cnVjdCB3YW5waXBlX29wdCAqd2FuX29wdDsKKworCWlmICgoc2sgPSBza19hbGxvYyhQRl9XQU5QSVBFLCBHRlBfQVRPTUlDLCAmd2FucGlwZV9wcm90bywgMSkpID09IE5VTEwpCisJCXJldHVybiBOVUxMOworCisJaWYgKCh3YW5fb3B0ID0ga21hbGxvYyhzaXplb2Yoc3RydWN0IHdhbnBpcGVfb3B0KSwgR0ZQX0FUT01JQykpID09IE5VTEwpIHsKKwkJc2tfZnJlZShzayk7CisJCXJldHVybiBOVUxMOworCX0KKwltZW1zZXQod2FuX29wdCwgMHgwMCwgc2l6ZW9mKHN0cnVjdCB3YW5waXBlX29wdCkpOworCisJd3Bfc2soc2spID0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RShkZXYpKTsKKwlza2ItPm5oLnJhdyA9IHNrYi0+ZGF0YTsKKworCS8qIFJldHVybnMgLUVGQVVMVCBvbiBlcnJvciAqLworCWVyciA9IG1lbWNweV9mcm9taW92ZWMoc2tiX3B1dChza2IsbGVuKSwgbXNnLT5tc2dfaW92LCBsZW4pOworCWlmIChlcnIpeworCQlnb3RvIG91dF9mcmVlOworCX0KKworCWlmIChkZXYtPmhhcmRfaGVhZGVyKSB7CisJCWludCByZXM7CisJCWVyciA9IC1FSU5WQUw7CisJCXJlcyA9IGRldi0+aGFyZF9oZWFkZXIoc2tiLCBkZXYsIG50b2hzKHByb3RvKSwgYWRkciwgTlVMTCwgbGVuKTsKKwkJaWYgKHJlczwwKXsKKwkJCWdvdG8gb3V0X2ZyZWU7CisJCX0KKwl9CisKKwlza2ItPnByb3RvY29sID0gcHJvdG87CisJc2tiLT5kZXYgPSBkZXY7CisJc2tiLT5wcmlvcml0eSA9IHNrLT5za19wcmlvcml0eTsKKwlza2ItPnBrdF90eXBlID0gV0FOX1BBQ0tFVF9EQVRBOworCisJZXJyID0gLUVORVRET1dOOworCWlmICghKGRldi0+ZmxhZ3MgJiBJRkZfVVApKQorCQlnb3RvIG91dF9mcmVlOworCisJaWYgKGF0b21pY19yZWFkKCZzay0+c2tfd21lbV9hbGxvYykgKyBza2ItPnRydWVzaXplID4KKwkgICAgKHVuc2lnbmVkIGludClzay0+c2tfc25kYnVmKXsKKwkJa2ZyZWVfc2tiKHNrYik7CisJCXJldHVybiAtRU5PQlVGUzsKKwl9CisKKwlza2JfcXVldWVfdGFpbCgmc2stPnNrX3dyaXRlX3F1ZXVlLHNrYik7CisJYXRvbWljX2luYygmd3AtPnBhY2tldF9zZW50KTsKKworCWlmICghKHRlc3RfYW5kX3NldF9iaXQoMCwgJndwLT50aW1lcikpKQorCQltb2RfdGltZXIoJndwLT50eF90aW1lciwgamlmZmllcyArIDEpOworCQorCXJldHVybihsZW4pOworCitvdXRfZnJlZToKKwlrZnJlZV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T09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIHdhbnBpcGVfZGVzdHJveV90aW1lciAKKyAqCisgKglVc2VkIGJ5IHdhbnBpcGVfcmVsZWFzZSwgdG8gZGVsYXkgcmVsZWFzZSBvZgorICogICAgICB0aGUgc29ja2V0LgorICo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PSovCisKK3N0YXRpYyB2b2lkIHdhbnBpcGVfZGVzdHJveV90aW1lcih1bnNpZ25lZCBsb25nIGRhdGEpCit7CisJc3RydWN0IHNvY2sgKnNrPShzdHJ1Y3Qgc29jayAqKWRhdGE7CisJd2FucGlwZV9vcHQgKndwID0gd3Bfc2soc2spOworCisJaWYgKCghYXRvbWljX3JlYWQoJnNrLT5za193bWVtX2FsbG9jKSAmJgorCSAgICAgIWF0b21pY19yZWFkKCZzay0+c2tfcm1lbV9hbGxvYykpIHx8CisJICAgICgrK3dwLT5mb3JjZSA9PSA1KSkgeworCisJCWlmIChhdG9taWNfcmVhZCgmc2stPnNrX3dtZW1fYWxsb2MpIHx8CisJCSAgICBhdG9taWNfcmVhZCgmc2stPnNrX3JtZW1fYWxsb2MpKQorCQkJcHJpbnRrKEtFUk5fSU5GTyAid2Fuc29jazogV2FybmluZywgUGFja2V0IERpc2NhcmRlZCBkdWUgdG8gc29jayBzaHV0ZG93biFcbiIpOworCisJCWtmcmVlKHdwKTsKKwkJd3Bfc2soc2spID0gTlVMTDsKKwkJCisJCWlmIChhdG9taWNfcmVhZCgmc2stPnNrX3JlZmNudCkgIT0gMSkgeworCQkJYXRvbWljX3NldCgmc2stPnNrX3JlZmNudCwgMSk7CisJCQlEQkdfUFJJTlRLKEtFUk5fSU5GTyAid2Fuc29jazogRXJyb3IsIHdyb25nIHJlZmVyZW5jZSBjb3VudDogJWkgISA6ZGVsYXkuXG4iLAorCQkJCQlhdG9taWNfcmVhZCgmc2stPnNrX3JlZmNudCkpOworCQl9CisJCXNvY2tfcHV0KHNrKTsKKwkJYXRvbWljX2RlYygmd2FucGlwZV9zb2Nrc19ucik7CisJCXJldHVybjsKKwl9CisKKwlzay0+c2tfdGltZXIuZXhwaXJlcyA9IGppZmZpZXMgKyA1ICogSFo7CisJYWRkX3RpbWVyKCZzay0+c2tfdGltZXIpOworCXByaW50ayhLRVJOX0lORk8gIndhbnNvY2s6IHBhY2tldCBzayBkZXN0cm95IGRlbGF5ZWRcbiIpOworfQorCisvKj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogd2FucGlwZV91bmxpbmtfZHJpdmVyCisgKgorICogCVdoZW4gdGhlIHNvY2tldCBpcyByZWxlYXNlZCwgdGhpcyBmdW5jdGlvbiBpcyAKKyAqICAgICAgdXNlZCB0byByZW1vdmUgbGlua3MgdGhhdCBiaW5kIHRoZSBzb2NrIGFuZCB0aGUKKyAqICAgICAgZHJpdmVyIHRvZ2V0aGVyLiAgCisgKj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ki8KK3N0YXRpYyB2b2lkIHdhbnBpcGVfdW5saW5rX2RyaXZlciAoc3RydWN0IHNvY2sgKnNrKQoreworCXN0cnVjdCBuZXRfZGV2aWNlICpkZXY7CisJd2FucGlwZV9jb21tb25fdCAqY2hhbj1OVUxMOworCisJc29ja19yZXNldF9mbGFnKHNrLCBTT0NLX1pBUFBFRCk7CisJc2stPnNrX3N0YXRlID0gV0FOU09DS19ESVNDT05ORUNURUQ7CisJd3Bfc2soc2spLT5kZXYgPSBOVUxMOworCisJZGV2ID0gZGV2X2dldF9ieV9pbmRleChzay0+c2tfYm91bmRfZGV2X2lmKTsKKwlpZiAoIWRldil7CisJCXByaW50ayhLRVJOX0lORk8gIndhbnNvY2s6IE5vIGRldiBvbiByZWxlYXNlXG4iKTsKKwkJcmV0dXJuOworCX0JCQkKKwlkZXZfcHV0KGRldik7CisKKwlpZiAoKGNoYW4gPSBkZXYtPnByaXYpID09IE5VTEwpeworCQlwcmludGsoS0VSTl9JTkZPICJ3YW5zb2NrOiBObyBQcml2IEFyZWEgb24gcmVsZWFzZVxuIik7CisJCXJldHVybjsKKwl9CisKKwlzZXRfYml0KDAsJmNoYW4tPmNvbW1vbl9jcml0aWNhbCk7CisJY2hhbi0+c2s9TlVMTDsKKwljaGFuLT5mdW5jPU5VTEw7CisJY2hhbi0+bWJveD1OVUxMOworCWNoYW4tPnR4X3RpbWVyPU5VTEw7CisJY2xlYXJfYml0KDAsJmNoYW4tPmNvbW1vbl9jcml0aWNhbCk7CisJcmVsZWFzZV9kZXZpY2UoZGV2KTsKKwkKKwlyZXR1cm47Cit9CisKKy8qPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiB3YW5waXBlX2xpbmtfZHJpdmVyCisgKgorICogCVVwb24gc3VjY2Vzc2Z1bCBiaW5kKCksIHNvY2sgaXMgbGlua2VkIHRvIGEgZHJpdmVyCisgKiAgICAgIGJ5IGJpbmRpbmcgaW4gdGhlIHdhbnBpcGVfcmN2KCkgYm90dG9tIGhhbGYgaGFuZGxlcgorICogICAgICB0byB0aGUgZHJpdmVyIGZ1bmN0aW9uIHBvaW50ZXIsIGFzIHdlbGwgYXMgc29jayBhbmQKKyAqICAgICAgc29jayBtYWlsYm94IGFkZHJlc3Nlcy4gIFRoaXMgd2F5IGRyaXZlciBjYW4gcGFzcworICogICAgICBkYXRhIHVwIHRoZSBzb2NrZXQuCisgKj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ki8KKworc3RhdGljIHZvaWQgd2FucGlwZV9saW5rX2RyaXZlcihzdHJ1Y3QgbmV0X2RldmljZSAqZGV2LCBzdHJ1Y3Qgc29jayAqc2spCit7CisJd2FucGlwZV9vcHQgKndwID0gd3Bfc2soc2spOworCXdhbnBpcGVfY29tbW9uX3QgKmNoYW4gPSBkZXYtPnByaXY7CisJaWYgKCFjaGFuKQorCQlyZXR1cm47CisJc2V0X2JpdCgwLCZjaGFuLT5jb21tb25fY3JpdGljYWwpOworCWNoYW4tPnNrPXNrOworCWNoYW4tPmZ1bmM9d2FucGlwZV9yY3Y7CisJY2hhbi0+bWJveCA9IHdwLT5tYm94OworCWNoYW4tPnR4X3RpbWVyID0gJndwLT50eF90aW1lcjsKKwl3cC0+ZGV2ID0gZGV2OworCXNvY2tfc2V0X2ZsYWcoc2ssIFNPQ0tfWkFQUEVEKTsKKwljbGVhcl9iaXQoMCwmY2hhbi0+Y29tbW9uX2NyaXRpY2FsKTsKK30KKworCisvKj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogcmVsZWFzZV9kZXZpY2UKKyAqCisgKiAgIAlEdXJpbmcgc29jayByZWxlYXNlLCBjbGVhciBhIGNyaXRpY2FsIGJpdCwgd2hpY2ggCisgKiAgICAgIG1hcmtzIHRoZSBkZXZpY2UgYSBiZWluZyB0YWtlbi4KKyAqPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0qLworCisKK3N0YXRpYyB2b2lkIHJlbGVhc2VfZGV2aWNlKHN0cnVjdCBuZXRfZGV2aWNlICpkZXYpCit7CisJd2FucGlwZV9jb21tb25fdCAqY2hhbj1kZXYtPnByaXY7CisJY2xlYXJfYml0KDAsKHZvaWQqKSZjaGFuLT5yd19iaW5kKTsKK30KKworLyo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIHdhbnBpcGVfcmVsZWFzZQorICoKKyAqCUNsb3NlIGEgUEFDS0VUIHNvY2tldC4gVGhpcyBpcyBmYWlybHkgc2ltcGxlLiBXZSAKKyAqICAgICAgaW1tZWRpYXRlbHkgZ28gdG8gJ2Nsb3NlZCcgc3RhdGUgYW5kIHJlbW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ludGsoS0VSTl9JTkZPICJ3YW5zb2NrOiBLaWxsaW5nIGluIFRpbWVyIFIgJWkgLCBXICVpXG4iLAorCQkJYXRvbWljX3JlYWQoJnNrLT5za19ybWVtX2FsbG9jKSwKKwkJCWF0b21pY19yZWFkKCZzay0+c2tfd21lbV9hbGxvYykpOworCQlzay0+c2tfdGltZXIuZGF0YQk9ICh1bnNpZ25lZCBsb25nKXNrOworCQlzay0+c2tfdGltZXIuZXhwaXJlcwk9IGppZmZpZXMgKyBIWjsKKwkJc2stPnNrX3RpbWVyLmZ1bmN0aW9uCT0gd2FucGlwZV9kZXN0cm95X3RpbWVyOworCQlhZGRfdGltZXIoJnNrLT5za190aW1lcik7CisJCXJldHVybiAwOworCX0KKworCWtmcmVlKHdwKTsKKwl3cF9zayhzaykgPSBOVUxMOworCisJaWYgKGF0b21pY19yZWFkKCZzay0+c2tfcmVmY250KSAhPSAxKSB7CisJCURCR19QUklOVEsoS0VSTl9JTkZPICJ3YW5zb2NrOiBFcnJvciwgd3JvbmcgcmVmZXJlbmNlIGNvdW50OiAlaSAhOnJlbGVhc2UuXG4iLAorCQkJCQlhdG9taWNfcmVhZCgmc2stPnNrX3JlZmNudCkpOworCQlhdG9taWNfc2V0KCZzay0+c2tfcmVmY250LCAxKTsKKwl9CisJc29ja19wdXQoc2spOworCWF0b21pY19kZWMoJndhbnBpcGVfc29ja3NfbnIpOworCXJldHVybiAwOworfQorCisvKj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogY2hlY2tfd3JpdGVfcXVldWUKKyAqCisgKiAgCUR1cmluZyBzb2NrIHNodXRkb3duLCBpZiB0aGUgc29jayBzdGF0ZSBpcyAKKyAqICAgICAgV0FOU09DS19DT05ORUNURUQgYW5kIHRoZXJlIGlzIHRyYW5zbWl0IGRhdGEgCisgKiAgICAgIHBlbmRpbmcuIFdhaXQgdW50aWwgZGF0YSBpcyByZWxlYXNlZCAKKyAqICAgICAgYmVmb3JlIHByb2NlZWRpbmcuCisgKj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ki8KKworc3RhdGljIHZvaWQgY2hlY2tfd3JpdGVfcXVldWUoc3RydWN0IHNvY2sgKnNrKQoreworCisJaWYgKHNrLT5za19zdGF0ZSAhPSBXQU5TT0NLX0NPTk5FQ1RFRCkKKwkJcmV0dXJuOworCisJaWYgKCFhdG9taWNfcmVhZCgmc2stPnNrX3dtZW1fYWxsb2MpKQorCQlyZXR1cm47CisKKwlwcmludGsoS0VSTl9JTkZPICJ3YW5zb2NrOiBNQUpPUiBFUlJPUiwgRGF0YSBsb3N0IG9uIHNvY2sgcmVsZWFzZSAhISFcbiIpOworCit9CisKKy8qPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiByZWxlYXNlX2RyaXZlcgorICoKKyAqCVRoaXMgZnVuY3Rpb24gaXMgY2FsbGVkIGR1cmluZyBzb2NrIHNodXRkb3duLCB0byAKKyAqICAgICAgcmVsZWFzZSBhbnkgcmVzb3VyY2VzIGFuZCBsaW5rcyB0aGF0IGJpbmQgdGhlIHNvY2sKKyAqICAgICAgdG8gdGhlIGRyaXZlci4gIEl0IGFsc28gY2hhbmdlcyB0aGUgc3RhdGUgb2YgdGhlCisgKiAgICAgIHNvY2sgdG8gV0FOU09DS19ESVNDT05ORUNURUQKKyAqPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0qLworCitzdGF0aWMgdm9pZCByZWxlYXNlX2RyaXZlcihzdHJ1Y3Qgc29jayAqc2spCit7CisJd2FucGlwZV9vcHQgKndwOworCXN0cnVjdCBza19idWZmICpza2I9TlVMTDsKKwlzdHJ1Y3Qgc29jayAqZGVhZHNrPU5VTEw7CisKKwlpZiAoc2stPnNrX3N0YXRlID09IFdBTlNPQ0tfTElTVEVOIHx8C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LCBzdGFydCB0aGUgdGltZXIgd2hpY2ggd2lsbCAKKyAqICAgICAgZW52b2tlIHRoZSBraWxsIHJvdXRpbmVzIGZvciBwZW5kaW5nIHNvY2tzLgorICo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PSovCisKKworc3RhdGljIHZvaWQgc3RhcnRfY2xlYW51cF90aW1lciAoc3RydWN0IHNvY2sgKnNrKQoreworCWRlbF90aW1lcigmc2stPnNrX3RpbWVyKTsKKwlzay0+c2tfdGltZXIuZGF0YQk9ICh1bnNpZ25lZCBsb25nKXNrOworCXNrLT5za190aW1lci5leHBpcmVzCT0gamlmZmllcyArIEhaOworCXNrLT5za190aW1lci5mdW5jdGlvbgk9IHdhbnBpcGVfa2lsbF9zb2NrX3RpbWVyOworCWFkZF90aW1lcigmc2stPnNrX3RpbWVyKTsKK30KKworCisvKj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogIHdhbnBpcGVfa2lsbF9zb2NrCisgKgorICoJVGhpcyBpcyBhIGZ1bmN0aW9uIHdoaWNoIHBlcmZvcm1zIGFjdHVhbCBraWxsaW5nCisgKiAgICAgIG9mIHRoZSBzb2NrLiAgSXQgcmVsZWFzZXMgc29ja2V0IHJlc291cmNlcywKKyAqICAgICAgYW5kIHVubGlua3MgdGhlIHNvY2sgZnJvbSB0aGUgZHJpdmVyLiAKKyAqPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0qLworCitzdGF0aWMgdm9pZCB3YW5waXBlX2tpbGxfc29ja190aW1lciAodW5zaWduZWQgbG9uZyBkYXRhKQoreworCisJc3RydWN0IHNvY2sgKnNrID0gKHN0cnVjdCBzb2NrICopZGF0YTsKKwlzdHJ1Y3Qgc29jayAqKnNrcDsKKworCWlmICghc2spCisJCXJldHVybjsKKworCS8qIFRoaXMgZnVuY3Rpb24gY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Cgmc2stPnNrX3dtZW1fYWxsb2MpKSB7CisJCWRlbF90aW1lcigmc2stPnNrX3RpbWVyKTsKKwkJcHJpbnRrKEtFUk5fSU5GTyAid2Fuc29jazogS2lsbGluZyBTT0NLIGluIFRpbWVyXG4iKTsKKwkJc2stPnNrX3RpbWVyLmRhdGEJPSAodW5zaWduZWQgbG9uZylzazsKKwkJc2stPnNrX3RpbWVyLmV4cGlyZXMJPSBqaWZmaWVzICsgSFo7CisJCXNrLT5za190aW1lci5mdW5jdGlvbgk9IHdhbnBpcGVfZGVzdHJveV90aW1lcjsKKwkJYWRkX3RpbWVyKCZzay0+c2tfdGltZXIpOworCQlyZXR1cm47CisJfQorCisJaWYgKHdwX3NrKHNrKSkgeworCQlrZnJlZSh3cF9zayhzaykpOworCQl3cF9zayhzaykgPSBOVUxMOworCX0KKworCWlmIChhdG9taWNfcmVhZCgmc2stPnNrX3JlZmNudCkgIT0gMSkgeworCQlhdG9taWNfc2V0KCZzay0+c2tfcmVmY250LCAxKTsKKwkJREJHX1BSSU5USyhLRVJOX0lORk8gIndhbnNvY2s6IEVycm9yLCB3cm9uZyByZWZlcmVuY2UgY291bnQ6ICVpICEgOnRpbWVyLlxuIiwKKwkJCQkJYXRvbWljX3JlYWQoJnNrLT5za19yZWZjbnQpKTsKKwl9CisJc29ja19wdXQoc2spOworCWF0b21pY19kZWMoJndhbnBpcGVfc29ja3NfbnIpOworCXJldHVybjsKK30KKworc3RhdGljIHZvaWQgd2FucGlwZV9raWxsX3NvY2tfYWNjZXB0IChzdHJ1Y3Qgc29jayAqc2spCit7CisKKwlzdHJ1Y3Qgc29jayAqKnNrcDsKKworCWlmICghc2spCisJCXJldHVybjsKKworCS8qIFRoaXMgZnVuY3Rpb24gY2FuIGJlIGNhbGxlZCBmcm9tIGludGVycnVwdC4gV2UgbXVzdCB1c2UKKwkgKiBhcHByb3ByaWF0ZSBsb2NrcyAqLworCQorCXdyaXRlX2xvY2soJndhbnBpcGVfc2tsaXN0X2xvY2spOworCXNrX2RlbF9ub2RlX2luaXQoc2spOworCXdyaXRlX3VubG9jaygmd2FucGlwZV9za2xpc3RfbG9jayk7CisKKwlzay0+c2tfc29ja2V0ID0gTlVMTDsKKworCisJaWYgKHdwX3NrKHNrKSkgeworCQlrZnJlZSh3cF9zayhzaykpOworCQl3cF9zayhzaykgPSBOVUxMOworCX0KKworCWlmIChhdG9taWNfcmVhZCgmc2stPnNrX3JlZmNudCkgIT0gMSkgeworCQlhdG9taWNfc2V0KCZzay0+c2tfcmVmY250LCAxKTsKKwkJREJHX1BSSU5USyhLRVJOX0lORk8gIndhbnNvY2s6IEVycm9yLCB3cm9uZyByZWZlcmVuY2UgY291bnQ6ICVpICEgOnRpbWVyLlxuIiwKKwkJCQkJYXRvbWljX3JlYWQoJnNrLT5za19yZWZjbnQpKTsKKwl9CisJc29ja19wdXQoc2spOworCWF0b21pY19kZWMoJndhbnBpcGVfc29ja3NfbnIpOworCXJldHVybjsKK30KKworCitzdGF0aWMgdm9pZCB3YW5waXBlX2tpbGxfc29ja19pcnEgKHN0cnVjdCBzb2NrICpzaykKK3sKKworCWlmICghc2spCisJCXJldHVybjsKKworCXNrLT5za19zb2NrZXQgPSBOVUxMOworCisJaWYgKHdwX3NrKHNrKSkgeworCQlrZnJlZSh3cF9zayhzaykpOworCQl3cF9zayhzaykgPSBOVUxMOworCX0KKworCWlmIChhdG9taWNfcmVhZCgmc2stPnNrX3JlZmNudCkgIT0gMSkgeworCQlhdG9taWNfc2V0KCZzay0+c2tfcmVmY250LCAxKTsKKwkJREJHX1BSSU5USyhLRVJOX0lORk8gIndhbnNvY2s6IEVycm9yLCB3cm9uZyByZWZlcmVuY2UgY291bnQ6ICVpICE6bGlzdGVuLlxuIiwKKwkJCQkJYXRvbWljX3JlYWQoJnNrLT5za19yZWZjbnQpKTsKKwl9CisJc29ja19wdXQoc2spOworCWF0b21pY19kZWMoJndhbnBpcGVfc29ja3NfbnIpOworfQorCisKKy8qPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiAgd2FucGlwZV9kb19iaW5kCisgKgorICogCUJvdHRvbSBoYWxmIG9mIHRoZSBiaW5kaW5nIHN5c3RlbSBjYWxsLgorICogICAgICBPbmNlIHRoZSB3YW5waXBlX2JpbmQoKSBmdW5jdGlvbiBjaGVja3MgIHRoZQorICogICAgICBsZWdhbGl0eSBvZiB0aGUgY2FsbCwgdGhpcyBmdW5jdGlvbiBiaW5kcyB0aGUKKyAqICAgICAgc29jayB0byB0aGUgZHJpdmVyLgorICo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PSovCisKK3N0YXRpYyBpbnQgd2FucGlwZV9kb19iaW5kKHN0cnVjdCBzb2NrICpzaywgc3RydWN0IG5ldF9kZXZpY2UgKmRldiwKKwkJCSAgIGludCBwcm90b2NvbCkKK3sKKwl3YW5waXBlX29wdCAqd3AgPSB3cF9zayhzayk7CisJd2FucGlwZV9jb21tb25fdCAqY2hhbj1OVUxMOworCWludCBlcnI9MDsKKworCWlmIChzb2NrX2ZsYWcoc2ssIFNPQ0tfWkFQUEVEKSkgeworCQllcnIgPSAtRUFMUkVBRFk7CisJCWdvdG8gYmluZF91bmxvY2tfZXhpdDsKKwl9CisKKwl3cC0+bnVtID0gcHJvdG9jb2w7CisKKwlpZiAocHJvdG9jb2wgPT0gMCl7CisJCXJlbGVhc2VfZGV2aWNlKGRldik7CisJCWVyciA9IC1FSU5WQUw7CisJCWdvdG8gYmluZF91bmxvY2tfZXhpdDsKKwl9CisKKwlpZiAoZGV2KSB7CisJCWlmIChkZXYtPmZsYWdzJklGRl9VUCkgeworCQkJY2hhbj1kZXYtPnByaXY7CisJCQlzay0+c2tfc3RhdGUgPSBjaGFuLT5zdGF0ZTsKKworCQkJaWYgKHdwLT5udW0gPT0gaHRvbnMoWDI1X1BST1QpICYmIAorCQkJICAgIHNrLT5za19zdGF0ZSAhPSBXQU5TT0NLX0RJU0NPTk5FQ1RFRCAmJiAKKwkJCSAgICBzay0+c2tfc3RhdGUgIT0gV0FOU09DS19DT05ORUNUSU5HKSB7CisJCQkJREJHX1BSSU5USyhLRVJOX0lORk8gCisJCQkJCSJ3YW5zb2NrOiBCaW5kaW5nIHRvIERldmljZSBub3QgRElTQ09OTkVDVEVEICVpXG4iLAorCQkJCQkJc2stPnNrX3N0YXRlKTsKKwkJCQlyZWxlYXNlX2RldmljZShkZXYpOworCQkJCWVyciA9IC1FQUdBSU47CisJCQkJZ290byBiaW5kX3VubG9ja19leGl0OworCQkJfQorCisJCQl3YW5waXBlX2xpbmtfZHJpdmVyKGRldixzayk7CisJCQlzay0+c2tfYm91bmRfZGV2X2lmID0gZGV2LT5pZmluZGV4OworCisJCQkvKiBYMjUgU3BlY2lmaWMgb3B0aW9uICovCisJCQlpZiAod3AtPm51bSA9PSBodG9ucyhYMjVfUFJPVCkpCisJCQkJd3Bfc2soc2spLT5zdmMgPSBjaGFuLT5zdmM7CisKKwkJfSBlbHNlIHsKKwkJCXNrLT5za19lcnIgPSBFTkVURE9XTjsKKwkJCXNrLT5za19lcnJvcl9yZXBvcnQoc2spOworCQkJcmVsZWFzZV9kZXZpY2UoZGV2KTsKKwkJCWVyciA9IC1FSU5WQUw7CisJCX0KKwl9IGVsc2UgeworCQllcnIgPSAtRU5PREVWOworCX0KK2JpbmRfdW5sb2NrX2V4aXQ6CisJLyogRklYTUUgd2hlcmUgaXMgdGhpcyBsb2NrICovCisKKwlyZXR1cm4gZXJyOworfQorCisvKj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogIHdhbnBpcGVfYmluZAorICoKKyAqICAgICAgQklORCgpIFN5c3RlbSBjYWxsLCB3aGljaCBpcyBib3VuZCB0byB0aGUgQUZfV0FOUElQRQorICogICAgICBvcGVyYXRpb25zIHN0cnVjdHVyZS4gIEl0IGNoZWNrcyBmb3IgY29ycmVjd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KKwlyZXR1cm4gd2FucGlwZV9kb19iaW5kKHNrLCBkZXYsIHNsbC0+c2xsX3Byb3RvY29sID8gOiB3cC0+bnVtKTsKK30KKworLyo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIGdldF9hdG9taWNfZGV2aWNlCisgKgkKKyAqCVNldHMgYSBiaXQgYXRvbWljYWxseSB3aGljaCBpbmRpY2F0ZXMgdGhhdCAKKyAqICAgICAgdGhlIGludGVyZmFjZSBpcyB0YWtlbi4gVGhpcyBhdm9pZHMgcmFjZSBjb25kaXRpb25zLgorICo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PSovCisKKworc3RhdGljIGlubGluZSBpbnQgZ2V0X2F0b21pY19kZXZpY2Uoc3RydWN0IG5ldF9kZXZpY2UgKmRldikKK3sKKwl3YW5waXBlX2NvbW1vbl90ICpjaGFuID0gZGV2LT5wcml2OworCWlmICghdGVzdF9hbmRfc2V0X2JpdCgwLCh2b2lkICopJmNoYW4tPnJ3X2JpbmQpKXsKKwkJcmV0dXJuIDA7CisJfQorCXJldHVybiAxOworfQorCisvKj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogY2hlY2tfZGV2CisgKgkKKyAqICAJQ2hlY2sgdGhhdCBkZXZpY2UgbmFtZSBiZWxvbmdzIHRvIGEgcGFydGljdWxhciBjYXJkLgorICo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PSovCisKK3N0YXRpYyBpbnQgY2hlY2tfZGV2KHN0cnVjdCBuZXRfZGV2aWNlICpkZXYsIHNkbGFfdCAqY2FyZCkKK3sKKwlzdHJ1Y3QgbmV0X2RldmljZSogdG1wX2RldjsKKworCWZvciAodG1wX2RldiA9IGNhcmQtPndhbmRldi5kZXY7IHRtcF9kZXY7CisJICAgICB0bXBfZGV2ID0gKigoc3RydWN0IG5ldF9kZXZpY2UgKiopdG1wX2Rldi0+cHJpdikpIHsKKwkJaWYgKHRtcF9kZXYtPmlmaW5kZXggPT0gZGV2LT5pZmluZGV4KXsgCisJCQlyZXR1cm4gMDsJCisJCX0KKwl9CisJcmV0dXJuIDE7Cit9CisKKy8qPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiAgd2FucGlwZV9maW5kX2ZyZWVfZGV2CisgKgkKKyAqCUZpbmQgYSBmcmVlIG5ldHdvcmsgaW50ZXJmYWNlLiBJZiBmb3VuZCBzZXQgYXRvbWljCisgKiAgICAgIGJpdCBpbmRpY2F0aW5nIHRoYXQgdGhlIGludGVyZmFjZSBpcyB0YWtlbi4KKyAqICAgICAgWDI1QVBJIFNwZWNpZmljLgorICo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PSovCisKK3N0cnVjdCBuZXRfZGV2aWNlICp3YW5waXBlX2ZpbmRfZnJlZV9kZXYoc2RsYV90ICpjYXJkKQoreworCXN0cnVjdCBuZXRfZGV2aWNlKiBkZXY7CisJdm9sYXRpbGUgd2FucGlwZV9jb21tb25fdCAqY2hhbjsKKworCWlmICh0ZXN0X2FuZF9zZXRfYml0KDAsJmZpbmRfZnJlZV9jcml0aWNhbCkpeworCQlwcmludGsoS0VSTl9JTkZPICJDUklUSUNBTCBpbiBGaW5kIEZyZWVcbiIpOworCX0JCisKKwlmb3IgKGRldiA9IGNhcmQtPndhbmRldi5kZXY7IGRldjsKKwkgICAgIGRldiA9ICooKHN0cnVjdCBuZXRfZGV2aWNlICoqKWRldi0+cHJpdikpIHsKKwkJY2hhbiA9IGRldi0+cHJpdjsKKwkJaWYgKCFjaGFuKSAKKwkJCWNvbnRpbnVlOworCQlpZiAoY2hhbi0+dXNlZGJ5ID09IEFQSSAmJiBjaGFuLT5zdmMpeworC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Y2stPnN0YXRlID0gU1NfVU5DT05ORUNURUQ7CisKKwlpZiAoKHNrID0gd2FucGlwZV9hbGxvY19zb2NrZXQoKSkgPT0gTlVMTCkKKwkJcmV0dXJuIC1FTk9CVUZTOworCisJc2stPnNrX3JldXNlID0gMTsKKwlzb2NrLT5vcHMgPSAmd2FucGlwZV9vcHM7CisJc29ja19pbml0X2RhdGEoc29jayxzayk7CisKKwlzb2NrX3Jlc2V0X2ZsYWcoc2ssIFNPQ0tfWkFQUEVEKTsKKwlzay0+c2tfZmFtaWx5CSAgICA9IFBGX1dBTlBJUEU7CisJd3Bfc2soc2spLT5udW0JICAgID0gcHJvdG9jb2w7CisJc2stPnNrX3N0YXRlCSAgICA9IFdBTlNPQ0tfRElTQ09OTkVDVEVEOworCXNrLT5za19hY2tfYmFja2xvZyAgPSAwOworCXNrLT5za19ib3VuZF9kZXZfaWYgPSAwOworCisJYXRvbWljX2luYygmd2FucGlwZV9zb2Nrc19ucik7CisJCisJLyogV2UgbXVzdCBkaXNhYmxlIGludGVycnVwdHMgYmVjYXVzZSB0aGUgSVNSCisJICogY2FuIGFsc28gY2hhbmdlIHRoZSBsaXN0ICovCisJc2V0X2JpdCgxLCZ3YW5waXBlX3R4X2NyaXRpY2FsKTsKKwl3cml0ZV9sb2NrKCZ3YW5waXBlX3NrbGlzdF9sb2NrKTsKKwlza19hZGRfbm9kZShzaywgJndhbnBpcGVfc2tsaXN0KTsKKwl3cml0ZV91bmxvY2soJndhbnBpcGVfc2tsaXN0X2xvY2spOworCWNsZWFyX2JpdCgxLCZ3YW5waXBlX3R4X2NyaXRpY2FsKTsKKworCXJldHVybigwKTsKK30KKworCisvKj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogIHdhbnBpcGVfcmVjdm1zZworICoJCisgKglQdWxsIGEgcGFja2V0IGZyb20gb3VyIHJlY2VpdmUgcXVldWUgYW5kIGhhbmQgaXQgCisgKiAgICAgIHR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VudHJhbmN5IGlzc3VlcyBmcm9tIHVzLgorCSAqLworCWVyciA9IChmbGFncyZNU0dfVFJVTkMpID8gc2tiLT5sZW4gOiBjb3BpZWQ7CisKK291dF9mcmVlOgorCXNrYl9mcmVlX2RhdGFncmFtKHNrLCBza2IpOworb3V0OgorCXJldHVybiBlcnI7Cit9CisKKworLyo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqICB3YW5waXBlX3dha2V1cF9kcml2ZXIKKyAqCQorICogCUlmIHNvY2tldCByZWNlaXZlIGJ1ZmZlciBpcyBmdWxsIGFuZCBkcml2ZXIgY2Fubm90CisgKiAgICAgIHBhc3MgZGF0YSB1cCB0aGUgc29jaywgaXQgc2V0cyBhIHBhY2tldF9ibG9jayBmbGFnLgorICogICAgICBUaGlzIGZ1bmN0aW9uIGNoZWNrIHRoYXQgZmxhZyBhbmQgaWYgc29jayByZWNlaXZlIAorICogICAgICBxdWV1ZSBoYXMgcm9vbSBpdCBraWNrcyB0aGUgZHJpdmVyIEJIIGhhbmRsZXIuIAorICoKKyAqIAlUaGlzIHdheSwgZHJpdmVyIGRvZXNuJ3QgaGF2ZSB0byBwb2xsIHRoZSBzb2NrIAorICogICAgICByZWNlaXZlIHF1ZXVlLgorICo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PSovCisKK3N0YXRpYyB2b2lkIHdhbnBpcGVfd2FrZXVwX2RyaXZlcihzdHJ1Y3Qgc29jayAqc2spCit7CisJc3RydWN0IG5ldF9kZXZpY2UgKmRldiA9IE5VTEw7CisJd2FucGlwZV9jb21tb25fdCAqY2hhbj1OVUxMOworCisJZGV2ID0gZGV2X2dldF9ieV9pbmRleChzay0+c2tfYm91bmRfZGV2X2lmKTsKKwlpZiAoIWRldikKKwkJcmV0dXJuOworCisJZGV2X3B1dChkZXYpOworCisJaWYgKChjaGFuID0gZGV2LT5wcml2KSA9PSBOVUxMKQorCQlyZXR1cm47CisJCisJaWYgKGF0b21pY19yZWFkKCZjaGFuLT5yZWNlaXZlX2Jsb2NrKSl7ICAKKwkJaWYgKGF0b21pY19yZWFkKCZzay0+c2tfcm1lbV9hbGxvYykgPAorCQkgICAgKCh1bnNpZ25lZClzay0+c2tfcmN2YnVmICogMC45KSkgeworCQkJcHJpbnRrKEtFUk5fSU5GTyAid2Fuc29jazogUXVldWluZyB0YXNrIGZvciB3YW5waXBlXG4iKTsKKwkJCWF0b21pY19zZXQoJmNoYW4tPnJlY2VpdmVfYmxvY2ssMCk7CisJCQl3YW5waXBlX3F1ZXVlX3RxKCZjaGFuLT53YW5waXBlX3Rhc2spOworCQkJd2FucGlwZV9tYXJrX2JoKCk7CisJCX0KKwl9CQorfQkKKworLyo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqICB3YW5waXBlX2dldG5hbWUKKyAqCQorICogCUkgZG9uJ3Qga25vdyB3aGF0IHRvIGRvIHdpdGggdGhpcyB5ZXQuIAorICogICAgICBVc2VyIGNhbiB1c2UgdGhpcyBmdW5jdGlvbiB0byBnZXQgc29jayBhZGRyZXNzCisgKiAgICAgIGluZm9ybWF0aW9uLiBOb3QgdmVyeSB1c2VmdWwgZm9yIFNhbmdvbWEncyBwdXJwb3Nlcy4KKyAqPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0qLworCisKK3N0YXRpYyBpbnQgd2FucGlwZV9nZXRuYW1lKHN0cnVjdCBzb2NrZXQgKnNvY2ssIHN0cnVjdCBzb2NrYWRkciAqdWFkZHIsCisJCQkgIGludCAqdWFkZHJfbGVuLCBpbnQgcGVlcikKK3sKKwlzdHJ1Y3QgbmV0X2RldmljZSAqZGV2OworCXN0cnVjdCBzb2NrICpzayA9IHNvY2stPnNrOworCXN0cnVjdCB3YW5fc29ja2FkZHJfbGwgKnNsbCA9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CisgKj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ki8KKworc3RhdGljIGludCB3YW5waXBlX25vdGlmaWVyKHN0cnVjdCBub3RpZmllcl9ibG9jayAqdGhpcywgdW5zaWduZWQgbG9uZyBtc2csIHZvaWQgKmRhdGEpCit7CisJc3RydWN0IHNvY2sgKnNrOworCWhsaXN0X25vZGUgKm5vZGU7CisJc3RydWN0IG5ldF9kZXZpY2UgKmRldiA9IChzdHJ1Y3QgbmV0X2RldmljZSAqKWRhdGE7CisKKwlza19mb3JfZWFjaChzaywgbm9kZSwgJndhbnBpcGVfc2tsaXN0KSB7CisJCXN0cnVjdCB3YW5waXBlX29wdCAqcG8gPSB3cF9zayhzayk7CisKKwkJaWYgKCFwbykKKwkJCWNvbnRpbnVlOworCQlpZiAoZGV2ID09IE5VTEwpCisJCQljb250aW51ZTsKKwkJCisJCXN3aXRjaCAobXNnKSB7CisJCWNhc2UgTkVUREVWX0RPV046CisJCWNhc2UgTkVUREVWX1VOUkVHSVNURVI6CisJCQlpZiAoZGV2LT5pZmluZGV4ID09IHNrLT5za19ib3VuZF9kZXZfaWYpIHsKKwkJCQlwcmludGsoS0VSTl9JTkZPICJ3YW5zb2NrOiBEZXZpY2UgZG93biAlc1xuIixkZXYtPm5hbWUpOworCQkJCWlmIChzb2NrX2ZsYWcoc2ssIFNPQ0tfWkFQUEVEKSkgeworCQkJCQl3YW5waXBlX3VubGlua19kcml2ZXIoc2spOworCQkJCQlzay0+c2tfZXJyID0gRU5FVERPV047CisJCQkJCXNrLT5za19lcnJvcl9yZXBvcnQoc2spOworCQkJCX0KKworCQkJCWlmIChtc2cgPT0gTkVUREVWX1VOUkVHSVNURVIpIHsKKwkJCQkJcHJpbnRrKEtFUk5fSU5GTyAid2Fuc29jazogVW5yZWdpc3RlcmluZyBEZXZpY2U6ICVzXG4iLAorCQkJCQkJIAkgIGRldi0+bmFtZSk7CisJCQkJCXdhbnBpcGVfdW5saW5rX2RyaXZlcihzayk7CisJCQkJCXNrLT5za19ib3VuZF9kZXZfaWYgPSAwOworCQkJCX0KKwkJCX0KKwkJCWJyZWFrOworCQljYXNlIE5FVERFVl9VUDoKKwkJCWlmIChkZXYtPmlmaW5kZXggPT0gc2stPnNrX2JvdW5kX2Rldl9pZiAmJgorCQkJICAgIHBvLT5udW0gJiYgIXNvY2tfZmxhZyhzaywgU09DS19aQVBQRUQpKSB7CisJCQkJcHJpbnRrKEtFUk5fSU5GTyAid2Fuc29jazogUmVnaXN0ZXJpbmcgRGV2aWNlOiAlc1xuIiwKKwkJCQkJCWRldi0+bmFtZSk7CisJCQkJd2FucGlwZV9saW5rX2RyaXZlcihkZXYsc2spOworCQkJfQorCQkJYnJlYWs7CisJCX0KKwl9CisJcmV0dXJuIE5PVElGWV9ET05FOworfQorCisvKj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogIHdhbnBpcGVfaW9jdGwKKyAqCQorICogCUV4ZWN1dGUgYSB1c2VyIGNvbW1hbmRzLCBhbmQgc2V0IHNvY2tldCBvcHRpb25zLgorICoKKyAqIEZJWE1FOiBNb3JlIHRob3VnaHQgc2hvdWxkIGdvIGludG8gdGhpcyBmdW5jdGlvbi4KKyAqCisgKj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ki8KKworc3RhdGljIGludCB3YW5waXBlX2lvY3RsKHN0cnVjdCBzb2NrZXQgKnNvY2ssIHVuc2lnbmVkIGludCBjbWQsIHVuc2lnbmVkIGxvbmcgYXJnKQoreworCXN0cnVjdCBzb2NrICpzayA9IHNvY2stPnNrOworCWludCBlcnI7CisKKwlzd2l0Y2goY21kKSAKKwl7CisJCWNhc2UgU0lPQ0dTVEFNUDoKKwkJCXJldHVybiBzb2NrX2dldF90aW1lc3RhbXAoc2ssIChzdHJ1Y3QgdGltZXZhbCBfX3VzZXIgKilhc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ncyB8PSBPX05PTkJMT0NLOworCQkJcmV0dXJuIDA7CisJCisjaWZkZWYgQ09ORklHX0lORVQKKwkJY2FzZSBTSU9DQUREUlQ6CisJCWNhc2UgU0lPQ0RFTFJUOgorCQljYXNlIFNJT0NEQVJQOgorCQljYXNlIFNJT0NHQVJQOgorCQljYXNlIFNJT0NTQVJQOgorCQljYXNlIFNJT0NEUkFSUDoKKwkJY2FzZSBTSU9DR1JBUlA6CisJCWNhc2UgU0lPQ1NSQVJQOgorCQljYXNlIFNJT0NHSUZBRERSOgorCQljYXNlIFNJT0NTSUZBRERSOgorCQljYXNlIFNJT0NHSUZCUkRBRERSOgorCQljYXNlIFNJT0NTSUZCUkRBRERSOgorCQljYXNlIFNJT0NHSUZORVRNQVNLOgorCQljYXNlIFNJT0NTSUZORVRNQVNLOgorCQljYXNlIFNJT0NHSUZEU1RBRERSOgorCQljYXNlIFNJT0NTSUZEU1RBRERSOgorCQljYXNlIFNJT0NTSUZGTEFHUzoKKwkJCXJldHVybiBpbmV0X2RncmFtX29wcy5pb2N0bChzb2NrLCBjbWQsIGFyZyk7CisjZW5kaWYKKworCQlkZWZhdWx0OgorCQkJcmV0dXJuIGRldl9pb2N0bChjbWQsKHZvaWQgX191c2VyICopIGFyZyk7CisJfQorCS8qTk9UUkVBQ0hFRCovCit9CisKKy8qPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiAgd2FucGlwZV9kZWJ1ZworICoJCisgKglUaGlzIGZ1bmN0aW9uIHdpbGwgcGFzcyB1cCBpbmZvcm1hdGlvbiBhYm91dCBhbGwKKyAqICAgICAgYWN0aXZlIHNvY2tldHMuCisgKgorICogRklYTUU6IE1vcmUgdGhvdWdodCBzaG91bGQgZ28gaW50byB0aGlzIGZ1bmN0aW9uLgorICoKKyAqPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0qLworCitzdGF0aWMg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mNtZC5sZW5ndGggPiAwKXsKKwkJaWYgKG1ib3hfcHRyLT5jbWQubGVuZ3RoID4gWDI1X01BWF9EQVRBKQorCQkJcmV0dXJuIC1FSU5WQUw7CisKKwkJaWYgKGNvcHlfdG9fdXNlcih1c3JfZGF0YS0+ZGF0YSwgbWJveF9wdHItPmRhdGEsIG1ib3hfcHRyLT5jbWQubGVuZ3RoKSl7CisJCQlwcmludGsoS0VSTl9JTkZPICJ3YW5zb2NrOiBDb3B5IGZhaWxlZCAhISFcbiIpOworCQkJcmV0dXJuIC1FRkFVTFQ7CisJCX0KKwl9CisJcmV0dXJuIDA7Cit9IAorCisvKj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogIHNldF9pb2N0bF9jbWQKKyAqCQorICoJQmVmb3JlIGNvbW1hbmQgY2FuIGJlIGV4ZWN1dGUsIHNvY2tldCBNQk9YIG11c3QKKyAqICAgICAgYmUgY3JlYXRlZCwgYW5kIGluaXRpYWxpemVkIHdpdGggdXNlciBkYXRhLgkKKyAqPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0qLworCitzdGF0aWMgaW50IHNldF9pb2N0bF9jbWQgKHN0cnVjdCBzb2NrICpzaywgdm9pZCAqYXJnKQoreworCXgyNWFwaV90ICp1c3JfZGF0YSA9ICh4MjVhcGlfdCAqKWFyZzsKKwltYm94X2NtZF90ICptYm94X3B0cjsKKwlpbnQgZXJyOworCisJaWYgKCF3cF9zayhzayktPm1ib3gpIHsKKwkJdm9pZCAqbWJveF9wdHI7CisJCXN0cnVjdCBuZXRfZGV2aWNlICpkZXYgPSBkZXZfZ2V0X2J5X2luZGV4KHNrLT5za19ib3VuZF9kZXZfaWYpOworCQlpZiAoIWRldikKKwkJCXJldHVybiAtRU5PREVWOworCisJCWRldl9wdXQoZGV2KTsKKwkJCisJCWlmICgobWJveF9wdHIgPSBrbWFsbG9jKHN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qIHRyYW5zbWl0IHF1ZXVlICovCisKKwlpZiAod3Bfc2soc2spLT5udW0gPT0gaHRvbnMoWDI1X1BST1QpKSB7CisJCWlmIChhdG9taWNfcmVhZCgmd3Bfc2soc2spLT5wYWNrZXRfc2VudCkpCisJCQlyZXR1cm4gbWFzazsKKwl9CisKKwkvKiB3cml0YWJsZT8gKi8KKwlpZiAoc29ja193cml0ZWFibGUoc2spKXsKKwkJbWFzayB8PSBQT0xMT1VUIHwgUE9MTFdSTk9STSB8IFBPTExXUkJBTkQ7CisJfWVsc2V7CisJCXNldF9iaXQoU09DS19BU1lOQ19OT1NQQUNFLCAmc2stPnNrX3NvY2tldC0+ZmxhZ3MpOworCX0KKwkJCisJcmV0dXJuIG1hc2s7Cit9CisKKy8qPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogd2FucGlwZV9saXN0ZW4KKyAqCisgKglYMjVBUEkgU3BlY2lmaWMgZnVuY3Rpb24uIFNldCBhIHNvY2tldCBpbnRvIExJU1RFTklORyAgTU9ERS4KKyAqPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ki8KKworCitzdGF0aWMgaW50IHdhbnBpcGVfbGlzdGVuKHN0cnVjdCBzb2NrZXQgKnNvY2ssIGludCBiYWNrbG9nKQoreworCXN0cnVjdCBzb2NrICpzayA9IHNvY2stPnNrOworCisgCS8qIFRoaXMgaXMgeDI1IHNwZWNpZmljIGFyZWEgaWYgcHJvdG9jb2wgZG9lc24ndAorICAgICAgICAgKiBtYXRjaCwgcmV0dXJuIGVycm9yICovCisJaWYgKHdwX3NrKHNrKS0+bnVtICE9IGh0b25zKFgyNV9QUk9UKSkKKwkJcmV0dXJuIC1FSU5WQUw7CisKKwlpZiAoc2stPnNrX3N0YXRlID09IFdBTlNPQ0tfQklORF9MSVNURU4pIHsKKworCQlzay0+c2tfbWF4X2Fja19iYWNrbG9nID0gYmFja2xvZzsKKwkJc2stPnNrX3N0YXRlICAgICAgICAgICA9IFdBTlNPQ0tfTElTVEVOOworCQlyZXR1cm4gMDsKKwl9ZWxzZXsKKwkJcHJpbnRrKEtFUk5fSU5GTyAid2Fuc29jazogTGlzdGVuaW5nIHNvY2sgd2FzIG5vdCBiaW5kZWRcbiIpOworCX0KKworCXJldHVybiAtRUlOVkFMOworfQorCisvKj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIHdhbnBpcGVfbGlua19jYXJkCisgKgorICoJQ29ubmVjdHMgdGhlIGxpc3RlbmluZyBzb2NrZXQgdG8gdGhlIGRyaXZlcgorICo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0qLworCitzdGF0aWMgaW50IHdhbnBpcGVfbGlua19jYXJkIChzdHJ1Y3Qgc29jayAqc2spCit7CisJc2RsYV90ICpjYXJkID0gKHNkbGFfdCopd3Bfc2soc2spLT5jYXJkOworCisJaWYgKCFjYXJkKQorCQlyZXR1cm4gLUVOT01FTTsKKworCWlmICgoY2FyZC0+c2sgIT0gTlVMTCkgfHwgKGNhcmQtPmZ1bmMgIT0gTlVMTCkpeworCQlwcmludGsoS0VSTl9JTkZPICJ3YW5zb2NrOiBMaXN0ZW5pbmcgcXVldWUgaXMgYWxyZWFkeSBlc3RhYmxpc2hlZFxuIik7CisJCXJldHVybiAtRUlOVkFMOworCX0KKworCWNhcmQtPnNrPXNrOworCWNhcmQtPmZ1bmM9d2FucGlwZV9saXN0ZW5fcmN2OworCXNvY2tfc2V0X2ZsYWcoc2ssIFNPQ0tfWkFQUEVEKTsKKyAKKwlyZXR1cm4gMDsKK30KKworLyo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiB3YW5waXBlX2xpc3RlbgorICoKKyAqCVgyNUFQSSBTcGVjaWZpYyBmdW5jdGlvbi4gRGlzY29ubmVjdCBsaXN0ZW5pbmcgc29ja2V0IGZyb20KKyAqICAgICAgdGhlIGRyaXZlci4KKyAqPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ki8KKworc3RhdGljIHZvaWQgd2FucGlwZV91bmxpbmtfY2FyZCAoc3RydWN0IHNvY2sgKnNrKQoreworCXNkbGFfdCAqY2FyZCA9IChzZGxhX3QqKXdwX3NrKHNrKS0+Y2FyZDsgCisKKwlpZiAoY2FyZCl7CisJCWNhcmQtPnNrPU5VTEw7CisJCWNhcmQtPmZ1bmM9TlVMTDsKKwl9Cit9CisKKy8qPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogd2FucGlwZV9leGVjX2NtZAorICoKKyAqCUlvY3RsIGZ1bmN0aW9uIGNhbGxzIHRoaXMgZnVuY3Rpb24gdG8gZXhlY3V0ZSB1c2VyIGNvbW1hbmQuCisgKiAgICAgIENvbm5lY3QoKSBzeXRlbSBjYWxsIGFsc28gY2FsbHMgdGhpcyBmdW5jdGlvbiB0byBleGVjdXRlCisgKiAgICAgIHBsYWNlIGNhbGwuICBUaGlzIGZ1bmN0aW9uIGJsb2NrcyB1bnRpbCBjb21tYW5kIGlzIGV4ZWN1dGVkLgorICo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0qLworCitzdGF0aWMgaW50IHdhbnBpcGVfZXhlY19jbWQoc3RydWN0IHNvY2sgKnNrLCBpbnQgY21kLCB1bnNpZ25lZCBpbnQgZmxhZ3MpCit7CisJaW50IGVyciA9IC1FSU5WQUw7CisJd2FucGlwZV9vcHQgKndwID0gd3Bfc2soc2spOworCW1ib3hfY21kX3QgKm1ib3hfcHRyID0gKG1ib3hfY21kX3QqKXdwLT5tYm94OworCisJaWYgKCFtYm94X3B0cil7CisJCXByaW50ayhLRVJOX0lORk8gIk5PIE1CT1ggUFRSICEhISEhXG4iKTsKKwkJcmV0dXJuIC1FSU5WQUw7CisJfQorCQorCS8qIFRoaXMgaXMgeDI1IHNwZWNpZmljIGFyZWEgaWYgcHJvdG9jb2wgZG9lc24ndAorICAgICAgICAgKiBtYXRjaCwgcmV0dXJuIGVycm9yICovCisJaWYgKHdwLT5udW0gIT0gaHRvbnMoWDI1X1BST1QpKQorCQlyZXR1cm4gLUVJTlZBTDsKKworCisJc3dpdGNoIChjbWQpeworCisJCWNhc2UgU0lPQ19XQU5QSVBFX0FDQ0VQVF9DQUxMOgorCisJCQlpZiAoc2stPnNrX3N0YXRlICE9IFdBTlNPQ0tfQ09OTkVDVElORykgeworCQkJCWVyciA9IC1FSE9TVERPV047CisJCQkJYnJlYWs7CisJCQl9CisJCQkKKwkJCWVyciA9IGV4ZWN1dGVfY29tbWFuZChzayxYMjVfQUNDRVBUX0NBTEwsMCk7CisJCQlpZiAoZXJyIDwgMCkKKwkJCQlicmVhazsKKworCQkJLyogVXBkYXRlLiBNYXI2IDIwMDAuIAorICAgICAgICAgICAgICAgICAgICAgICAgICogRG8gbm90IHNldCB0aGUgc29jayBsY24gbnVtYmVyIGhlcmUsIHNpbmNlCisgICAgICAgICAgICAgICAgICAgICAgICAgKiBpdCBpcyBkb25lIGluIHdhbnBpcGVfbGlzdGVuX3JjdigpLiAKKyAgICAgICAgICAgICAgICAgICAgICAgICAqLyAKKwkJIAlpZiAoc2stPnNrX3N0YXRlID09IFdBTlNPQ0tfQ09OTkVDVEVEKSB7CisJCQkJd3AtPmxjbiA9ICgobWJveF9jbWRfdCopd3AtPm1ib3gpLT5jbWQubGNuOwkKKwkJCQlEQkdfUFJJTlRLKEtFUk5fSU5GTyAiXG53YW5zb2NrOiBBY2NlcHQgT0sgJWlcbiIsCisJCQkJCXdwLT5sY24pOworCQkJCWVyciA9IDA7CisKKwkJCX1lbHNleworCQkJCURCR19QUklOVEsgKEtFUk5fSU5GTyAiXG53YW5zb2NrOiBBY2NlcHQgRmFpbGVkICVpXG4iLAorCQkJCQl3cC0+bGNuKTsKKwkJCQl3cC0+bGNuID0gMDsKKwkJCQllcnIgPSAtRUNPTk5SRUZVU0VEOworCQkJfQorCQkJYnJlYWs7CisKKwkJY2FzZSBTSU9DX1dBTlBJUEVfQ0xFQVJfQ0FMTDoKKworCQkJaWYgKHNrLT5za19zdGF0ZSA9PSBXQU5TT0NLX0RJU0NPTk5FQ1RFRCkgeworCQkJCWVyciA9IC1FSU5WQUw7CisJCQkJYnJlYWs7CisJCQl9CisKKworCQkJLyogQ2hlY2sgaWYgZGF0YSBidWZmZXJzIGFyZSBwZW5kaW5nIGZvciB0cmFuc21pc3Npb24sCisgICAgICAgICAgICAgICAgICAgICAgICAgKiBpZiBzbywgY2hlY2sgd2hldGhlciB1c2VyIHdhbnRzIHRvIHdhaXQgdW50aWwgZGF0YQorICAgICAgICAgICAgICAgICAgICAgICAgICogaXMgdHJhbnNtaXR0ZWQsIG9yIGNsZWFyIGEgY2FsbCBhbmQgZHJvcCBwYWNrZXRzICovCisgICAgICAgICAgICAgICAgICAgICAgICAgIAorCQkJaWYgKGF0b21pY19yZWFkKCZzay0+c2tfd21lbV9hbGxvYykgfHwKKwkJCSAgICBjaGVja19kcml2ZXJfYnVzeShzaykpIHsKKwkJCSAgCW1ib3hfY21kX3QgKm1ib3ggPSB3cC0+bWJveDsKKwkJCQlpZiAobWJveC0+Y21kLnFkbSAmIDB4ODApeworCQkJCQltYm94LT5jbWQucmVzdWx0ID0gMHgzNTsKKwkJCQkJZXJyID0gLUVBR0FJTjsJCisJCQkJCWJyZWFrOworCQkJCX0KKwkJCX0KKworCQkJc2stPnNrX3N0YXRlID0gV0FOU09DS19ESVNDT05ORUNUSU5HOworCisJCQllcnIgPSBleGVjdXRlX2NvbW1hbmQoc2ssWDI1X0NMRUFSX0NBTEwsMCk7CisJCQlpZiAoZXJyIDwgMCkKKwkJCQlicmVhazsKKworCQkJZXJyID0gLUVDT05OUkVGVVNFRDsKKwkJCWlmIChzay0+c2tfc3RhdGUgPT0gV0FOU09DS19ESVNDT05ORUNURUQpIHsKKwkJCQlEQkdfUFJJTlRLKEtFUk5fSU5GTyAiXG53YW5zb2NrOiBDTEVBUiBPSyAlaVxuIiwKKwkJCQkJICAgd3AtPmxjbik7CisJCQkJd3AtPmxjbiA9IDA7CisJCQkJZXJyID0gMDsKKwkJCX0KKwkJCWJyZWFrOworCisJCWNhc2UgU0lPQ19XQU5QSVBFX1JFU0VUX0NBTEw6CisKKwkJCWlmIChzay0+c2tfc3RhdGUgIT0gV0FOU09DS19DT05ORUNURUQpIHsKKwkJCQllcnIgPSAtRUlOVkFMOworCQkJCWJyZWFrOworCQkJfQorCisKKwkJCS8qIENoZWNrIGlmIGRhdGEgYnVmZmVycyBhcmUgcGVuZGluZyBmb3IgdHJhbnNtaXNzaW9uLAorICAgICAgICAgICAgICAgICAgICAgICAgICogaWYgc28sIGNoZWNrIHdoZXRoZXIgdXNlciB3YW50cyB0byB3YWl0IHVudGlsIGRhdGEKKyAgICAgICAgICAgICAgICAgICAgICAgICAqIGlzIHRyYW5zbWl0dGVkLCBvciByZXNldCBhIGNhbGwgYW5kIGRyb3AgcGFja2V0cyAqLworICAgICAgICAgICAgICAgICAgICAgICAgICAKKwkJCWlmIChhdG9taWNfcmVhZCgmc2stPnNrX3dtZW1fYWxsb2MpIHx8CisJCQkgICAgY2hlY2tfZHJpdmVyX2J1c3koc2spKSB7CisJCQkgIAltYm94X2NtZF90ICptYm94ID0gd3AtPm1ib3g7CisJCQkJaWYgKG1ib3gtPmNtZC5xZG0gJiAweDgwKXsKKwkJCQkJbWJveC0+Y21kLnJlc3VsdCA9IDB4MzU7CisJCQkJCWVyciA9IC1FQUdBSU47CQorCQkJCQlicmVhazsKKwkJCQl9CisJCQl9CisKKworCQkJZX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N0YXRpYyBpbnQgY2hlY2tfZHJpdmVyX2J1c3kgKHN0cnVjdCBzb2NrICpzaykKK3sKKwlzdHJ1Y3QgbmV0X2RldmljZSAqZGV2ID0gZGV2X2dldF9ieV9pbmRleChzay0+c2tfYm91bmRfZGV2X2lmKTsKKwl3YW5waXBlX2NvbW1vbl90ICpjaGFuOworCisJaWYgKCFkZXYpCisJCXJldHVybiAwOworCisJZGV2X3B1dChkZXYpOworCisJaWYgKChjaGFuPWRldi0+cHJpdikgPT0gTlVMTCkKKwkJcmV0dXJuIDA7CisKKwlyZXR1cm4gYXRvbWljX3JlYWQoJmNoYW4tPmRyaXZlcl9idXN5KTsKK30KKworCisvKj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIHdhbnBpcGVfYWNjZXB0CisgKgorICoJQUNDRVBUKCkgU3lzdGVtIGNhbGwuCVgyNUFQSSBTcGVjaWZpYyBmdW5jdGlvbi4gCisgKglGb3IgZWFjaCBpbmNvbWluZyBjYWxsLCBjcmVhdGUgYSBuZXcgc29ja2V0IGFuZCAKKyAqICAgICAgcmV0dXJuIGl0IHRvIHRoZSB1c2VyLgkKKyAqPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ki8KKworc3RhdGljIGludCB3YW5waXBlX2FjY2VwdChzdHJ1Y3Qgc29ja2V0ICpzb2NrLCBzdHJ1Y3Qgc29ja2V0ICpuZXdzb2NrLCBpbnQgZmxhZ3MpCit7CisJc3RydWN0IHNvY2sgKnNrOworCXN0cnVjdCBzb2NrICpuZXdzazsKKwlzdHJ1Y3Qgc2tfYnVmZiAqc2tiOworCURFQ0xBUkVfV0FJVFFVRVVFKHdhaXQsIGN1cnJlbnQpOworCWludCBlcnI9MDsKKworCWlmIChuZXdzb2NrLT5zayAhPSBOVUxMKXsKKwkJd2FucGlwZV9raWxsX3NvY2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OworCXdyaXRlX3VubG9jaygmd2FucGlwZV9za2xpc3RfbG9jayk7CisJY2xlYXJfYml0KDEsJndhbnBpcGVfdHhfY3JpdGljYWwpOworCisJbmV3c2stPnNrX3NvY2tldCA9IG5ld3NvY2s7CisJbmV3c2stPnNrX3NsZWVwID0gJm5ld3NvY2stPndhaXQ7CisKKwkvKiBOb3cgYXR0YWNoIHVwIHRoZSBuZXcgc29ja2V0ICovCisJc2stPnNrX2Fja19iYWNrbG9nLS07CisJbmV3c29jay0+c2sgPSBuZXdzazsKKwkKKwlrZnJlZV9za2Ioc2tiKTsKKworCURCR19QUklOVEsoS0VSTl9JTkZPICJcbndhbnNvY2s6IEFDQ0VQVCBHb3QgTENOICVpXG4iLAorCQkgICB3cF9zayhuZXdzayktPmxjbik7CisJcmV0dXJuIDA7Cit9CisKKy8qPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogIGdldF9uZXdza19mcm9tX3NrYgorICoKKyAqCUFjY2VwdCgpIHVzZXMgdGhpcyBmdW5jdGlvbiB0byBnZXQgdGhlIGFkZHJlc3Mgb2YgdGhlIG5ldworICogICAgICBzb2NrZXQgc3RydWN0dXJlLgorICo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0qLworCitzdHJ1Y3Qgc29jayAqIGdldF9uZXdza19mcm9tX3NrYiAoc3RydWN0IHNrX2J1ZmYgKnNrYikKK3sKKwlzdHJ1Y3QgbmV0X2RldmljZSAqZGV2ID0gc2tiLT5kZXY7CisJd2FucGlwZV9jb21tb25fdCAqY2hhbjsJCisKKwlpZiAoIWRldil7CisJCXJldHVybiBOVUxMOworCX0KKwkJCisJaWYgKChjaGFuID0gZGV2LT5wcml2KSA9PSBOVUxMKXsKKwkJcmV0dXJuIE5VTEw7CisJfQorCQkKKwlpZiAoIWNoYW4tPnNrKXsKKwkJcmV0dXJuIE5VTEw7CisJfQorCXJldHVybiAoc3RydWN0IHNvY2sgKiljaGFuLT5zazsKK30KKworLyo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiAgd2FucGlwZV9jb25uZWN0CisgKgorICogIAlDT05ORUNUKCkgU3lzdGVtIENhbGwuIFgyNUFQSSBzcGVjaWZpYyBmdW5jdGlvbgorICogCUNoZWNrIHRoZSBzdGF0ZSBvZiB0aGUgc29jaywgYW5kIGV4ZWN1dGUgUExBQ0VfQ0FMTCBjb21tYW5kLgorICogICAgICBDb25uZWN0IGNhbiBldGhlciBibG9jayBvciByZXR1cm4gd2l0aG91dCB3YWl0aW5nIGZvciBjb25uZWN0aW9uLCAKKyAqICAgICAgaWYgc3BlY2lmaWVkIGJ5IHVzZXIuCisgKj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PSovCisKK3N0YXRpYyBpbnQgd2FucGlwZV9jb25uZWN0KHN0cnVjdCBzb2NrZXQgKnNvY2ssIHN0cnVjdCBzb2NrYWRkciAqdWFkZHIsIGludCBhZGRyX2xlbiwgaW50IGZsYWdzKQoreworCXN0cnVjdCBzb2NrICpzayA9IHNvY2stPnNrOworCXN0cnVjdCB3YW5fc29ja2FkZHJfbGwgKmFkZHIgPSAoc3RydWN0IHdhbl9zb2NrYWRkcl9sbCopdWFkZHI7CisJc3RydWN0IG5ldF9kZXZpY2UgKmRldjsKKwlpbnQgZXJyOworCisJaWYgKHdwX3NrKHNrKS0+bnVtICE9IGh0b25zKFgyNV9QUk9UKSkKKwkJcmV0dXJuIC1FSU5WQUw7CisKKwlpZiAoc2stPnNrX3N0YXRlID09IFdBTlNPQ0tfQ09OTkVDVEVEKQorCQlyZXR1cm4gLUVJU0NPTk47CS8qIE5vIHJlY29ubmVjdCBvbiBhIHNlcXBhY2tldCBzb2NrZXQgKi8KKworCW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ZXIgdGhlIHRlcm1zIG9mIHRoZSBHTlUgR2VuZXJhbCBQdWJsaWMgTGljZW5zZQorKgkJYXMgcHVibGlzaGVkIGJ5IHRoZSBGcmVlIFNvZnR3YXJlIEZvdW5kYXRpb247IGVpdGhlciB2ZXJzaW9uCisqCQkyIG9mIHRoZSBMaWNlbnNlLCBvciAoYXQgeW91ciBvcHRpb24pIGFueSBsYXRlciB2ZXJzaW9uLgorKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisqIEp1biAwMiwgMTk5OSAgR2lkZW9uIEhhY2sJVXBkYXRlcyBmb3IgTGludXggMi4yLlgga2VybmVscy4KKyogSnVuIDI5LCAxOTk3CUFsYW4gQ294CU1lcmdlZCB3aXRoIDEuMC4zIHZlbmRvciBjb2RlCisqIEphbiAyOSwgMTk5NwlHZW5lIEtvemluCXYxLjAuMS4gSW1wbGVtZW50ZWQgL3Byb2MgcmVhZCByb3V0aW5lcworKiBKYW4gMzAsIDE5OTcJQWxhbiBDb3gJSGFja2VkIGFyb3VuZCBmb3IgMi4xCisqIERlYyAxMywgMTk5NglHZW5lIEtvemluCUluaXRpYWwgdmVyc2lvbiAoYmFzZWQgb24gU2FuZ29tYSdzIFdBTlBJUEUpCisqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKworI2luY2x1ZGUgPGxpbnV4L2NvbmZpZy5oPgorI2luY2x1ZGUgPGxpbnV4L2luaXQuaD4JCS8qIF9faW5pdGZ1bmMgZXQgYWwuICovCisjaW5jbHVkZSA8bGludXgvc3RkZGVmLmg+CS8qIG9mZnNldG9mKCksIGV0Yy4gKi8KKyNpbmNsdWRlIDxsaW51eC9lcnJuby5oPgkvKiByZXR1cm4gY29kZXMgKi8KKyNpbmNsdWRlIDxsaW51eC9rZXJuZWwuaD4KKyNpbmNsdWRlIDxsaW51eC9tb2R1bGUuaD4KKyNpbmNsdWRlIDxsaW51eC93YW5yb3V0ZXIuaD4JLyogV0FOIHJvdXRlciBBUEkgZGVmaW5pdGlvbnMgKi8KKyNpbmNsdWRlIDxsaW51eC9zZXFfZmlsZS5oPgorI2luY2x1ZGUgPGxpbnV4L3NtcF9sb2NrLmg+CisKKyNpbmNsdWRlIDxhc20vaW8uaD4KKworI2RlZmluZSBQUk9DX1NUQVRTX0ZPUk1BVCAiJTMwczogJTEybHVcbiIKKworLyoqKioqKiBEZWZpbmVzIGFuZCBNYWNyb3MgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisKKyNkZWZpbmUgUFJPVF9ERUNPREUocHJvdCkgKChwcm90ID09IFdBTkNPTkZJR19GUikgPyAiIEZSIiA6XAorCQkJICAgICAgKHByb3QgPT0gV0FOQ09ORklHX1gyNSkgPyAiIFgyNSIgOiBcCisJCQkgICAgICAgICAocHJvdCA9PSBXQU5DT05GSUdfUFBQKSA/ICIgUFBQIiA6IFwKKwkJCQkgICAgKHByb3QgPT0gV0FOQ09ORklHX0NIRExDKSA/ICIgQ0hETEMiOiBcCisJCQkJICAgICAgIChwcm90ID09IFdBTkNPTkZJR19NUFBQKSA/ICIgTVBQUCIgOiBcCisJCQkJICAgICAgICAgICAiIFVua25vd24iICkKKworLyoqKioqKiBGdW5jdGlvbiBQcm90b3R5cGVzICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisKKyNpZmRlZiBDT05GSUdfUFJPQ19GUworCisvKiBNaXNjZWxsYW5lb3VzICovCisKKy8qCisgKglTdHJ1Y3R1cmVzIGZvciBpbnRlcmZhY2luZyB3aXRoIHRoZSAvcHJvYyBmaWxlc3lzdGVtLgorICoJUm91dGVyIGNyZWF0ZXMgaXRzIG93biBkaXJlY3RvcnkgL3Byb2MvbmV0L3JvdXRlciB3aXRoIHRoZSBmb2xvd2luZworICoJZW50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FkZHI7CisJfQorCisJbXNnLT5tc2dfbmFtZWxlbiA9IHNpemVvZihzdHJ1Y3Qgc29ja2FkZHJfeDI1KTsKKworCWxvY2tfc29jayhzayk7CisJeDI1X2NoZWNrX3JidWYoc2spOworCXJlbGVhc2Vfc29jayhzayk7CisJcmMgPSBjb3BpZWQ7CitvdXRfZnJlZV9kZ3JhbToKKwlza2JfZnJlZV9kYXRhZ3JhbShzaywgc2tiKTsKK291dDoKKwlyZXR1cm4gcmM7Cit9CisKKworc3RhdGljIGludCB4MjVfaW9jdGwoc3RydWN0IHNvY2tldCAqc29jaywgdW5zaWduZWQgaW50IGNtZCwgdW5zaWduZWQgbG9uZyBhcmcpCit7CisJc3RydWN0IHNvY2sgKnNrID0gc29jay0+c2s7CisJc3RydWN0IHgyNV9zb2NrICp4MjUgPSB4MjVfc2soc2spOworCXZvaWQgX191c2VyICphcmdwID0gKHZvaWQgX191c2VyICopYXJnOworCWludCByYzsKKworCXN3aXRjaCAoY21kKSB7CisJCWNhc2UgVElPQ09VVFE6IHsKKwkJCWludCBhbW91bnQgPSBzay0+c2tfc25kYnVmIC0KKwkJCQkgICAgIGF0b21pY19yZWFkKCZzay0+c2tfd21lbV9hbGxvYyk7CisJCQlpZiAoYW1vdW50IDwgMCkKKwkJCQlhbW91bnQgPSAwOworCQkJcmMgPSBwdXRfdXNlcihhbW91bnQsICh1bnNpZ25lZCBpbnQgX191c2VyICopYXJncCk7CisJCQlicmVhazsKKwkJfQorCisJCWNhc2UgVElPQ0lOUTogeworCQkJc3RydWN0IHNrX2J1ZmYgKnNrYjsKKwkJCWludCBhbW91bnQgPSAwOworCQkJLyoKKwkJCSAqIFRoZXNlIHR3byBhcmUgc2FmZSBvbiBhIHNpbmdsZSBDUFUgc3lzdGVtIGFzCisJCQkgKiBvbmx5IHVzZXIgdGFza3MgZmlkZGxlIGhlcmUKKwkJCSAqLworCQkJaWYgKChza2IgPSBza2JfcGVlaygmc2stPnNrX3JlY2VpdmVfcXVldWUpKS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pemVfaW4pIHsKKwkJCVNPQ0tfREVCVUcoc2ssICJYLjI1OiBwYWNrZXQgc2l6ZSBpbndhcmRzIG5lZ290aWF0ZWQgZG93biIpOworCQkJbmV3LT5wYWNzaXplX2luID0gdGhlaXJzLnBhY3NpemVfaW47CisJCX0KKwkJaWYgKHRoZWlycy5wYWNzaXplX291dCA8IG91cnMtPnBhY3NpemVfb3V0KSB7CisJCQlTT0NLX0RFQlVHKHNrLCAiWC4yNTogcGFja2V0IHNpemUgb3V0d2FyZHMgbmVnb3RpYXRlZCBkb3duIik7CisJCQluZXctPnBhY3NpemVfb3V0ID0gdGhlaXJzLnBhY3NpemVfb3V0OworCQl9CisJfQorCisJaWYgKHRoZWlycy53aW5zaXplX2luICYmIHRoZWlycy53aW5zaXplX291dCkgeworCQlpZiAodGhlaXJzLndpbnNpemVfaW4gPCBvdXJzLT53aW5zaXplX2luKSB7CisJCQlTT0NLX0RFQlVHKHNrLCAiWC4yNTogd2luZG93IHNpemUgaW53YXJkcyBuZWdvdGlhdGVkIGRvd24iKTsKKwkJCW5ldy0+d2luc2l6ZV9pbiA9IHRoZWlycy53aW5zaXplX2luOworCQl9CisJCWlmICh0aGVpcnMud2luc2l6ZV9vdXQgPCBvdXJzLT53aW5zaXplX291dCkgeworCQkJU09DS19ERUJVRyhzaywgIlguMjU6IHdpbmRvdyBzaXplIG91dHdhcmRzIG5lZ290aWF0ZWQgZG93biIpOworCQkJbmV3LT53aW5zaXplX291dCA9IHRoZWlycy53aW5zaXplX291dDsKKwkJfQorCX0KKworCXJldHVybiBsZW47Cit9CisKKy8qCisgKglMaW1pdCB2YWx1ZXMgb2YgY2VydGFpbiBmYWNpbGl0aWVzIGFjY29yZGluZyB0byB0aGUgY2FwYWJpbGl0eSBvZiB0aGUgCisgKiAgICAgIGN1cnJlbnRseSBhdHRhY2hlZCB4MjUgbGluay4KKyAqLwordm9pZCB4MjVfbGltaXRfZmFjaWxpdGllcyhzdHJ1Y3QgeDI1X2ZhY2lsaX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Qkuc2FkYl9hbGdfaWQgPSBTQURCX1hfRUFMR19CTE9XRklTSENCQywKKwkJLnNhZGJfYWxnX2l2bGVuID0gOCwKKwkJLnNhZGJfYWxnX21pbmJpdHMgPSA0MCwKKwkJLnNhZGJfYWxnX21heGJpdHMgPSA0NDgKKwl9Cit9LAoreworCS5uYW1lID0gImFlcyIsCisKKwkudWluZm8gPSB7CisJCS5lbmNyID0geworCQkJLmJsb2NrYml0cyA9IDEyOCwKKwkJCS5kZWZrZXliaXRzID0gMTI4LAorCQl9CisJfSwKKworCS5kZXNjID0geworCQkuc2FkYl9hbGdfaWQgPSBTQURCX1hfRUFMR19BRVNDQkMsCisJCS5zYWRiX2FsZ19pdmxlbiA9IDgsCisJCS5zYWRiX2FsZ19taW5iaXRzID0gMTI4LAorCQkuc2FkYl9hbGdfbWF4Yml0cyA9IDI1NgorCX0KK30sCit7CisgICAgICAgIC5uYW1lID0gInNlcnBlbnQiLAorCisgICAgICAgIC51aW5mbyA9IHsKKyAgICAgICAgICAgICAgICAuZW5jciA9IHsKKyAgICAgICAgICAgICAgICAgICAgICAgIC5ibG9ja2JpdHMgPSAxMjgsCisgICAgICAgICAgICAgICAgICAgICAgICAuZGVma2V5Yml0cyA9IDEyOCwKKyAgICAgICAgICAgICAgICB9CisgICAgICAgIH0sCisKKyAgICAgICAgLmRlc2MgPSB7CisgICAgICAgICAgICAgICAgLnNhZGJfYWxnX2lkID0gU0FEQl9YX0VBTEdfU0VSUEVOVENCQywKKyAgICAgICAgICAgICAgICAuc2FkYl9hbGdfaXZsZW4gPSA4LAorICAgICAgICAgICAgICAgIC5zYWRiX2FsZ19taW5iaXRzID0gMTI4LAorICAgICAgICAgICAgICAgIC5zYWRiX2FsZ19tYXhiaXRzID0gMjU2LAorICAgICAgICB9Cit9LAoreworICAgICAgICAubmFtZSA9ICJ0d29maXNoIiwKKyAgICAgICAgICAgICAgICAgCisgICAgICAgIC51aW5mbyA9IHsKKyAgICAgICAgICAgICAgICAuZW5jciA9IHsKKyAgICAgICAgICAgICAgICAgICAgICAgIC5ibG9ja2JpdHMgPSAxMjgsCisgICAgICAgICAgICAgICAgICAgICAgICAuZGVma2V5Yml0cyA9IDEyOCwKKyAgICAgICAgICAgICAgICB9CisgICAgICAgIH0sCisKKyAgICAgICAgLmRlc2MgPSB7CisgICAgICAgICAgICAgICAgLnNhZGJfYWxnX2lkID0gU0FEQl9YX0VBTEdfVFdPRklTSENCQywKKyAgICAgICAgICAgICAgICAuc2FkYl9hbGdfaXZsZW4gPSA4LAorICAgICAgICAgICAgICAgIC5zYWRiX2FsZ19taW5iaXRzID0gMTI4LAorICAgICAgICAgICAgICAgIC5zYWRiX2FsZ19tYXhiaXRzID0gMjU2CisgICAgICAgIH0KK30sCit9OworCitzdGF0aWMgc3RydWN0IHhmcm1fYWxnb19kZXNjIGNhbGdfbGlzdFtdID0geworeworCS5uYW1lID0gImRlZmxhdGUiLAorCS51aW5mbyA9IHsKKwkJLmNvbXAgPSB7CisJCQkudGhyZXNob2xkID0gOTAsCisJCX0KKwl9LAorCS5kZXNjID0geyAuc2FkYl9hbGdfaWQgPSBTQURCX1hfQ0FMR19ERUZMQVRFIH0KK30sCit7CisJLm5hbWUgPSAibHpzIiwKKwkudWluZm8gPSB7CisJCS5jb21wID0geworCQkJLnRocmVzaG9sZCA9IDkwLAorCQl9CisJfSwKKwkuZGVzYyA9IHsgLnNhZGJfYWxnX2lkID0gU0FEQl9YX0NBTEdfTFpTIH0KK30sCit7CisJLm5hbWUgPSAibHpqaCIsCisJLnVpbmZvID0geworCQkuY29tcCA9IHsKKwkJCS50aHJlc2hvbGQgPSA1MCwKKwkJfQorCX0sCisJLmRlc2MgPSB7IC5zYWRiX2FsZ19pZCA9IFNBREJfWF9DQUxHX0xaSkggfQorfSwKK307CisKK3N0YXRpYyBpbmxpbmUgaW50IGFhbGdfZW50cmllcyh2b2lkKQoreworCXJldHVybiBBUlJBWV9TSVpFKGFhbGdfbGlzdCk7Cit9CisKK3N0YXRpYyB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