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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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WMgaW50IG1pbl90M1sxXSwgICAJCW1heF90M1tdID0gezM2MDAgKiBIWn07CitzdGF0aWMgaW50IG1pbl9pZGxlWzFdLCAgCQltYXhfaWRsZVtdID0gezY1NTM1ICogSFp9Oworc3RhdGljIGludCBtaW5fbjJbXSA9IHsxfSwJCW1heF9uMltdID0gezMxfTsKK3N0YXRpYyBpbnQgbWluX3BhY2xlbltdID0gezF9LAkJbWF4X3BhY2xlbltdID0gezUxMn07CitzdGF0aWMgaW50IG1pbl9wcm90b1sxXSwJCW1heF9wcm90b1tdID0gezN9Oworc3RhdGljIGludCBtaW5fZHNfdGltZW91dFsxXSwgICAJbWF4X2RzX3RpbWVvdXRbXSA9IHs2NTUzNSAqIEhafTsKKworc3RhdGljIHN0cnVjdCBjdGxfdGFibGVfaGVhZGVyICpheDI1X3RhYmxlX2hlYWRlcjsKKworc3RhdGljIGN0bF90YWJsZSAqYXgyNV90YWJsZTsKK3N0YXRpYyBpbnQgYXgyNV90YWJsZV9zaXplOworCitzdGF0aWMgY3RsX3RhYmxlIGF4MjVfZGlyX3RhYmxlW10gPSB7CisJeworCQkuY3RsX25hbWUJPSBORVRfQVgyNSwKKwkJLnByb2NuYW1lCT0gImF4MjUiLAorCQkubW9kZQkJPSAwNTU1LAorCX0sCisJeyAuY3RsX25hbWUgPSAwIH0KK307CisKK3N0YXRpYyBjdGxfdGFibGUgYXgyNV9yb290X3RhYmxlW10gPSB7CisJeworCQkuY3RsX25hbWUJPSBDVExfTkVULAorCQkucHJvY25hbWUJPSAibmV0IiwKKwkJLm1vZGUJCT0gMDU1NSwKKwkJLmNoaWxkCQk9IGF4MjVfZGlyX3RhYmxlCisJfSwKKwl7IC5jdGxfbmFtZSA9IDAgfQorfTsKKworc3RhdGljIGNvbnN0IGN0bF90YWJsZSBheDI1X3BhcmFtX3RhYmxlW10gPSB7CisJeworCQkuY3RsX25hbWUJPSBORVRfQVgyNV9JUF9ERUZBVUxUX01PREUsCisJCS5wcm9jbmFtZQk9ICJp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zdHJhdGVneQk9ICZzeXNjdGxfaW50dmVjLAorCQkuZXh0cmExCQk9ICZtaW5fdDEsCisJCS5leHRyYTIJCT0gJm1heF90MQorCX0sCisJeworCQkuY3RsX25hbWUJPSBORVRfQVgyNV9UMl9USU1FT1VULAorCQkucHJvY25hbWUJPSAidDJfdGltZW91dCIsCisJCS5tYXhsZW4JCT0gc2l6ZW9mKGludCksCisJCS5tb2RlCQk9IDA2NDQsCisJCS5wcm9jX2hhbmRsZXIJPSAmcHJvY19kb2ludHZlY19taW5tYXgsCisJCS5zdHJhdGVneQk9ICZzeXNjdGxfaW50dmVjLAorCQkuZXh0cmExCQk9ICZtaW5fdDIsCisJCS5leHRyYTIJCT0gJm1heF90MgorCX0sCisJeworCQkuY3RsX25hbWUJPSBORVRfQVgyNV9UM19USU1FT1VULAorCQkucHJvY25hbWUJPSAidDNfdGltZW91dCIsCisJCS5tYXhsZW4JCT0gc2l6ZW9mKGludCksCisJCS5tb2RlCQk9IDA2NDQsCisJCS5wcm9jX2hhbmRsZXIJPSAmcHJvY19kb2ludHZlY19taW5tYXgsCisJCS5zdHJhdGVneQk9ICZzeXNjdGxfaW50dmVjLAorCQkuZXh0cmExCQk9ICZtaW5fdDMsCisJCS5leHRyYTIJCT0gJm1heF90MworCX0sCisJeworCQkuY3RsX25hbWUJPSBORVRfQVgyNV9JRExFX1RJTUVPVVQsCisJCS5wcm9jbmFtZQk9ICJpZGxlX3RpbWVvdXQiLAorCQkubWF4bGVuCQk9IHNpemVvZihpbnQpLAorCQkubW9kZQkJPSAwNjQ0LAorCQkucHJvY19oYW5kbGVyCT0gJnByb2NfZG9pbnR2ZWNfbWlubWF4LAorCQkuc3RyYXRlZ3kJPSAmc3lzY3RsX2ludHZlYywKKwkJLmV4dHJhMQkJPSAmbWluX2lkbGUsCisJCS5leHRyYTIJCT0gJm1heF9pZGxlCisJfSwKKwl7CisJCS5jdGxfbmFtZQk9IE5FVF9BWDI1X04yLAorCQkucHJvY25hbWUJPSAibWF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ja19pbml0KHZvaWQpOworZXh0ZXJuIGludCBoY2lfc29ja19jbGVhbnVwKHZvaWQpOworCitleHRlcm4gaW50IGJ0X3N5c2ZzX2luaXQodm9pZCk7CitleHRlcm4gaW50IGJ0X3N5c2ZzX2NsZWFudXAodm9pZCk7CisKK3N0YXRpYyBpbnQgX19pbml0IGJ0X2luaXQodm9pZCkKK3sKKwlCVF9JTkZPKCJDb3JlIHZlciAlcyIsIFZFUlNJT04pOworCisJcHJvY19idCA9IHByb2NfbWtkaXIoImJsdWV0b290aCIsIE5VTEwpOworCWlmIChwcm9jX2J0KQorCQlwcm9jX2J0LT5vd25lciA9IFRISVNfTU9EVUxFOworCisJc29ja19yZWdpc3RlcigmYnRfc29ja19mYW1pbHlfb3BzKTsKKworCUJUX0lORk8oIkhDSSBkZXZpY2UgYW5kIGNvbm5lY3Rpb24gbWFuYWdlciBpbml0aWFsaXplZCIpOworCisJYnRfc3lzZnNfaW5pdCgpOworCisJaGNpX3NvY2tfaW5pdCgpOworCisJcmV0dXJuIDA7Cit9CisKK3N0YXRpYyB2b2lkIF9fZXhpdCBidF9leGl0KHZvaWQpCit7CisJaGNpX3NvY2tfY2xlYW51cCgpOworCisJYnRfc3lzZnNfY2xlYW51cCgpOworCisJc29ja191bnJlZ2lzdGVyKFBGX0JMVUVUT09USCk7CisKKwlyZW1vdmVfcHJvY19lbnRyeSgiYmx1ZXRvb3RoIiwgTlVMTCk7Cit9CisKK3N1YnN5c19pbml0Y2FsbChidF9pbml0KTsKK21vZHVsZV9leGl0KGJ0X2V4aXQpOworCitNT0RVTEVfQVVUSE9SKCJNYXhpbSBLcmFzbnlhbnNreSA8bWF4a0BxdWFsY29tbS5jb20+LCBNYXJjZWwgSG9sdG1hbm4gPG1hcmNlbEBob2x0bWFubi5vcmc+Iik7CitNT0RVTEVfREVTQ1JJUFRJT04oIkJsdWV0b290aCBDb3JlIHZlciAiIFZFUlNJT04pOworTU9EVUxFX1ZFUlNJT04oVkVSU0lPTik7CitNT0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9wdXQobnNrYiwgMikpOworCQlicmVhazsKKwl9CisKKwltZW1jcHkoX19za2JfcHV0KG5za2IsIHNrYi0+bGVuKSwgc2tiLT5kYXRhLCBza2ItPmxlbik7CisJa2ZyZWVfc2tiKHNrYik7CisJCisJcy0+c3RhdHMucnhfcGFja2V0cysrOworCW5za2ItPmRldiAgICAgICA9IGRldjsKKwluc2tiLT5pcF9zdW1tZWQgPSBDSEVDS1NVTV9OT05FOworCW5za2ItPnByb3RvY29sICA9IGV0aF90eXBlX3RyYW5zKG5za2IsIGRldik7CisJbmV0aWZfcnhfbmkobnNrYik7CisJcmV0dXJuIDA7CisKK2JhZGZyYW1lOgorCXMtPnN0YXRzLnJ4X2Vycm9ycysrOworCWtmcmVlX3NrYihza2IpOworCXJldHVybiAwOworfQorCitzdGF0aWMgdTggX19ibmVwX3R4X3R5cGVzW10gPSB7CisJQk5FUF9HRU5FUkFMLAorCUJORVBfQ09NUFJFU1NFRF9TUkNfT05MWSwKKwlCTkVQX0NPTVBSRVNTRURfRFNUX09OTFksCisJQk5FUF9DT01QUkVTU0VECit9OworCitzdGF0aWMgaW5saW5lIGludCBibmVwX3R4X2ZyYW1lKHN0cnVjdCBibmVwX3Nlc3Npb24gKnMsIHN0cnVjdCBza19idWZmICpza2IpCit7CisJc3RydWN0IGV0aGhkciAqZWggPSAodm9pZCAqKSBza2ItPmRhdGE7CisJc3RydWN0IHNvY2tldCAqc29jayA9IHMtPnNvY2s7CisJc3RydWN0IGt2ZWMgaXZbM107CisJaW50IGxlbiA9IDAsIGlsID0gMDsKKwl1OCB0eXBlID0gMDsKKworCUJUX0RCRygic2tiICVwIGRldiAlcCB0eXBlICVkIiwgc2tiLCBza2ItPmRldiwgc2tiLT5wa3RfdHlwZSk7CisKKwlpZiAoIXNrYi0+ZGV2KSB7CisJCS8qIENvbnRyb2wgZnJhbWUgc2VudCBieSB1cyAqLworCQlnb3RvIHNlbmQ7CisJfQorCisJaXZbaWwrK10gPSAoc3RydWN0IGt2Z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weV90b191c2VyKGFyZ3AsICZjaSwgc2l6ZW9mKGNpKSkpCisJCQlyZXR1cm4gLUVGQVVMVDsKKworCQlyZXR1cm4gZXJyOworCisJZGVmYXVsdDoKKwkJcmV0dXJuIC1FSU5WQUw7CisJfQorCisJcmV0dXJuIDA7Cit9CisKK3N0YXRpYyBzdHJ1Y3QgcHJvdG9fb3BzIGJuZXBfc29ja19vcHMgPSB7CisJLmZhbWlseSAgICAgPSBQRl9CTFVFVE9PVEgsCisJLm93bmVyICAgICAgPSBUSElTX01PRFVMRSwKKwkucmVsZWFzZSAgICA9IGJuZXBfc29ja19yZWxlYXNlLAorCS5pb2N0bCAgICAgID0gYm5lcF9zb2NrX2lvY3RsLAorCS5iaW5kICAgICAgID0gc29ja19ub19iaW5kLAorCS5nZXRuYW1lICAgID0gc29ja19ub19nZXRuYW1lLAorCS5zZW5kbXNnICAgID0gc29ja19ub19zZW5kbXNnLAorCS5yZWN2bXNnICAgID0gc29ja19ub19yZWN2bXNnLAorCS5wb2xsICAgICAgID0gc29ja19ub19wb2xsLAorCS5saXN0ZW4gICAgID0gc29ja19ub19saXN0ZW4sCisJLnNodXRkb3duICAgPSBzb2NrX25vX3NodXRkb3duLAorCS5zZXRzb2Nrb3B0ID0gc29ja19ub19zZXRzb2Nrb3B0LAorCS5nZXRzb2Nrb3B0ID0gc29ja19ub19nZXRzb2Nrb3B0LAorCS5jb25uZWN0ICAgID0gc29ja19ub19jb25uZWN0LAorCS5zb2NrZXRwYWlyID0gc29ja19ub19zb2NrZXRwYWlyLAorCS5hY2NlcHQgICAgID0gc29ja19ub19hY2NlcHQsCisJLm1tYXAgICAgICAgPSBzb2NrX25vX21tYXAKK307CisKK3N0YXRpYyBzdHJ1Y3QgcHJvdG8gYm5lcF9wcm90byA9IHsKKwkubmFtZQkJPSAiQk5FUCIsCisJLm93bmVyCQk9IFRISVNfTU9EVUxFLAorCS5vYmpfc2l6ZQk9IHNpemVvZihzdHJ1Y3QgYnRfc29jaykKK307CisK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wlfX3UxNiAqcHRyOworCWludCBpOworCisJc2tiX3B1bGwoc2tiLCBzaXplb2YoKmV2KSk7CisKKwlCVF9EQkcoIiVzIG51bV9obmRsICVkIiwgaGRldi0+bmFtZSwgZXYtPm51bV9obmRsKTsKKworCWlmIChza2ItPmxlbiA8IGV2LT5udW1faG5kbCAqIDQpIHsKKwkJQlRfREJHKCIlcyBiYWQgcGFyYW1ldGVycyIsIGhkZXYtPm5hbWUpOworCQlyZXR1cm47CisJfQorCisJdGFza2xldF9kaXNhYmxlKCZoZGV2LT50eF90YXNrKTsKKworCWZvciAoaSA9IDAsIHB0ciA9IChfX3UxNiAqKSBza2ItPmRhdGE7IGkgPCBldi0+bnVtX2huZGw7IGkrKykgeworCQlzdHJ1Y3QgaGNpX2Nvbm4gKmNvbm47CisJCV9fdTE2ICBoYW5kbGUsIGNvdW50OworCisJCWhhbmRsZSA9IF9fbGUxNl90b19jcHUoZ2V0X3VuYWxpZ25lZChwdHIrKykpOworCQljb3VudCAgPSBfX2xlMTZfdG9fY3B1KGdldF91bmFsaWduZWQocHRyKyspKTsKKworCQljb25uID0gaGNpX2Nvbm5faGFzaF9sb29rdXBfaGFuZGxlKGhkZXYsIGhhbmRsZSk7CisJCWlmIChjb25uKSB7CisJCQljb25uLT5zZW50IC09IGNvdW50OworCisJCQlpZiAoY29ubi0+dHlwZSA9PSBTQ09fTElOSykgeworCQkJCWlmICgoaGRldi0+c2NvX2NudCArPSBjb3VudCkgPiBoZGV2LT5zY29fcGt0cykKKwkJCQkJaGRldi0+c2NvX2NudCA9IGhkZXYtPnNjb19wa3RzOworCQkJfSBlbHNlIHsKKwkJCQlpZiAoKGhkZXYtPmFjbF9jbnQgKz0gY291bnQpID4gaGRldi0+YWNsX3BrdHMpCisJCQkJCWhkZXYtPmFjbF9jbnQgPSBoZGV2LT5hY2xfcGt0czsKKwkJCX0KKwkJfQorCX0KKwloY2lfc2NoZWRfdHgoaGRldik7CisKKwl0YXNrbGV0X2VuYWJsZSgma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GhhZGRyLT5oY2lfZmFtaWx5ICE9IEFGX0JMVUVUT09USCkKKwkJcmV0dXJuIC1FSU5WQUw7CisKKwlsb2NrX3NvY2soc2spOworCisJaWYgKGhjaV9waShzayktPmhkZXYpIHsKKwkJZXJyID0gLUVBTFJFQURZOworCQlnb3RvIGRvbmU7CisJfQorCisJaWYgKGhhZGRyLT5oY2lfZGV2ICE9IEhDSV9ERVZfTk9ORSkgeworCQlpZiAoIShoZGV2ID0gaGNpX2Rldl9nZXQoaGFkZHItPmhjaV9kZXYpKSkgeworCQkJZXJyID0gLUVOT0RFVjsKKwkJCWdvdG8gZG9uZTsKKwkJfQorCisJCWF0b21pY19pbmMoJmhkZXYtPnByb21pc2MpOworCX0KKworCWhjaV9waShzayktPmhkZXYgPSBoZGV2OworCXNrLT5za19zdGF0ZSA9IEJUX0JPVU5EOworCitkb25lOgorCXJlbGVhc2Vfc29jayhzayk7CisJcmV0dXJuIGVycjsKK30KKworc3RhdGljIGludCBoY2lfc29ja19nZXRuYW1lKHN0cnVjdCBzb2NrZXQgKnNvY2ssIHN0cnVjdCBzb2NrYWRkciAqYWRkciwgaW50ICphZGRyX2xlbiwgaW50IHBlZXIpCit7CisJc3RydWN0IHNvY2thZGRyX2hjaSAqaGFkZHIgPSAoc3RydWN0IHNvY2thZGRyX2hjaSAqKSBhZGRyOworCXN0cnVjdCBzb2NrICpzayA9IHNvY2stPnNrOworCisJQlRfREJHKCJzb2NrICVwIHNrICVwIiwgc29jaywgc2spOworCisJbG9ja19zb2NrKHNrKTsKKworCSphZGRyX2xlbiA9IHNpemVvZigqaGFkZHIpOworCWhhZGRyLT5oY2lfZmFtaWx5ID0gQUZfQkxVRVRPT1RIOworCWhhZGRyLT5oY2lfZGV2ICAgID0gaGNpX3BpKHNrKS0+aGRldi0+aWQ7CisKKwlyZWxlYXNlX3NvY2soc2spOworCXJldHVybiAwOworfQorCitzdGF0aWMgaW5saW5lIHZvaWQgaGNpX3NvY2tfY21zZyhzdHJ1Y3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isJaWYgKCFsMmNhcF9waShzayktPnBzbSkgeworCQliZGFkZHJfdCAqc3JjID0gJmJ0X3NrKHNrKS0+c3JjOworCQl1MTYgcHNtOworCisJCWVyciA9IC1FSU5WQUw7CisKKwkJd3JpdGVfbG9ja19iaCgmbDJjYXBfc2tfbGlzdC5sb2NrKTsKKworCQlmb3IgKHBzbSA9IDB4MTAwMTsgcHNtIDwgMHgxMTAwOyBwc20gKz0gMikKKwkJCWlmICghX19sMmNhcF9nZXRfc29ja19ieV9hZGRyKHBzbSwgc3JjKSkgeworCQkJCWwyY2FwX3BpKHNrKS0+cHNtICAgPSBodG9icyhwc20pOworCQkJCWwyY2FwX3BpKHNrKS0+c3BvcnQgPSBodG9icyhwc20pOworCQkJCWVyciA9IDA7CisJCQkJYnJlYWs7CisJCQl9CisKKwkJd3JpdGVfdW5sb2NrX2JoKCZsMmNhcF9za19saXN0LmxvY2spOworCisJCWlmIChlcnIgPCAwKQorCQkJZ290byBkb25lOworCX0KKworCXNrLT5za19tYXhfYWNrX2JhY2tsb2cgPSBiYWNrbG9nOworCXNrLT5za19hY2tfYmFja2xvZyA9IDA7CisJc2stPnNrX3N0YXRlID0gQlRfTElTVEVOOworCitkb25lOgorCXJlbGVhc2Vfc29jayhzayk7CisJcmV0dXJuIGVycjsKK30KKworc3RhdGljIGludCBsMmNhcF9zb2NrX2FjY2VwdChzdHJ1Y3Qgc29ja2V0ICpzb2NrLCBzdHJ1Y3Qgc29ja2V0ICpuZXdzb2NrLCBpbnQgZmxhZ3MpCit7CisJREVDTEFSRV9XQUlUUVVFVUUod2FpdCwgY3VycmVudCk7CisJc3RydWN0IHNvY2sgKnNrID0gc29jay0+c2ssICpuc2s7CisJbG9uZyB0aW1lbzsKKwlpbnQgZXJyID0gMDsKKworCWxvY2tfc29jayhzayk7CisKKwlpZiAoc2stPnNrX3N0YXRlICE9IEJUX0xJU1RFTikgeworCQllcnIgPSAtRUJBREZEOworCQlnb3RvIGRvbmU7CisJfQorCisJdGltZW8gPSBzb2NrX3JjdnRpbWVvKHNrLCBmbGFncyAmIE9fTk9OQkxPQ0spOworCisJQlRfREJHKCJzayAlcCB0aW1lbyAlbGQiLCBzaywgdGltZW8pOworCisJLyogV2FpdCBmb3IgYW4gaW5jb21pbmcgY29ubmVjdGlvbi4gKHdha2Utb25lKS4gKi8KKwlhZGRfd2FpdF9xdWV1ZV9leGNsdXNpdmUoc2stPnNrX3NsZWVwLCAmd2FpdCk7CisJd2hpbGUgKCEobnNrID0gYnRfYWNjZXB0X2RlcXVldWUoc2ssIG5ld3NvY2spKSkgeworCQlzZXRfY3VycmVudF9zdGF0ZShUQVNLX0lOVEVSUlVQVElCTEUpOworCQlpZiAoIXRpbWVvKSB7CisJCQllcnIgPSAtRUFHQUlOOworCQkJYnJlYWs7CisJCX0KKworCQlyZWxlYXNlX3NvY2soc2spOworCQl0aW1lbyA9IHNjaGVkdWxlX3RpbWVvdXQodGltZW8pOworCQlsb2NrX3NvY2soc2spOworCisJCWlmIChzay0+c2tfc3RhdGUgIT0gQlRfTElTVEVOKSB7CisJCQllcnIgPSAtRUJBREZEOworCQkJYnJlYWs7CisJCX0KKworCQlpZiAoc2lnbmFsX3BlbmRpbmcoY3VycmVudCkpIHsKKwkJCWVyciA9IHNvY2tfaW50cl9lcnJubyh0aW1lbyk7CisJCQlicmVhazsKKwkJfQorCX0KKwlzZXRfY3VycmVudF9zdGF0ZShUQVNLX1JVTk5JTkcpOworCXJlbW92ZV93YWl0X3F1ZXVlKHNrLT5za19zbGVlcCwgJndhaXQpOworCisJaWYgKGVycikKKwkJZ290byBkb25lOworCisJbmV3c29jay0+c3RhdGUgPSBTU19DT05ORUNURUQ7CisKKwlCVF9EQkcoIm5ldyBzb2NrZXQgJXAiLCBuc2spOworCitkb25lOgorCXJlbGVhc2Vfc29jayhzayk7CisJcmV0dXJuIGVycjsKK30KKworc3RhdGljIGludCBsMmNhcF9zb2NrX2dldG5hbWUoc3RydWN0IHNvY2tldCAqc29jaywgc3RydWN0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IChtZW1jcHlfZnJvbWlvdmVjKHNrYl9wdXQoKmZyYWcsIGNvdW50KSwgbXNnLT5tc2dfaW92LCBjb3VudCkpIHsKKwkJCWVyciA9IC1FRkFVTFQ7CisJCQlnb3RvIGZhaWw7CisJCX0KKworCQlzZW50ICs9IGNvdW50OworCQlsZW4gIC09IGNvdW50OworCisJCWZyYWcgPSAmKCpmcmFnKS0+bmV4dDsKKwl9CisKKwlpZiAoKGVyciA9IGhjaV9zZW5kX2FjbChjb25uLT5oY29uLCBza2IsIDApKSA8IDApCisJCWdvdG8gZmFpbDsKKworCXJldHVybiBzZW50OworCitmYWlsOgorCWtmcmVlX3NrYihza2IpOworCXJldHVybiBlcnI7Cit9CisKK3N0YXRpYyBpbnQgbDJjYXBfc29ja19zZW5kbXNnKHN0cnVjdCBraW9jYiAqaW9jYiwgc3RydWN0IHNvY2tldCAqc29jaywgc3RydWN0IG1zZ2hkciAqbXNnLCBzaXplX3QgbGVuKQoreworCXN0cnVjdCBzb2NrICpzayA9IHNvY2stPnNrOworCWludCBlcnIgPSAwOworCisJQlRfREJHKCJzb2NrICVwLCBzayAlcCIsIHNvY2ssIHNrKTsKKworCWlmIChzay0+c2tfZXJyKQorCQlyZXR1cm4gc29ja19lcnJvcihzayk7CisKKwlpZiAobXNnLT5tc2dfZmxhZ3MgJiBNU0dfT09CKQorCQlyZXR1cm4gLUVPUE5PVFNVUFA7CisKKwkvKiBDaGVjayBvdXRnb2luZyBNVFUgKi8KKwlpZiAoc2stPnNrX3R5cGUgIT0gU09DS19SQVcgJiYgbGVuID4gbDJjYXBfcGkoc2spLT5vbXR1KQorCQlyZXR1cm4gLUVJTlZBTDsKKworCWxvY2tfc29jayhzayk7CisKKwlpZiAoc2stPnNrX3N0YXRlID09IEJUX0NPTk5FQ1RFRCkKKwkJZXJyID0gbDJjYXBfZG9fc2VuZChzaywgbXNnLCBsZW4pOworCWVsc2UKKwkJZXJyID0gLUVOT1RDT05OOworCisJcmVsZWFzZV9zb2NrKH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X2hkciAqKSBza2JfcHV0KHNrYiwgTDJDQVBfSERSX1NJWkUpOworCWxoLT5sZW4gPSBfX2NwdV90b19sZTE2KEwyQ0FQX0NNRF9IRFJfU0laRSArIGRsZW4pOworCWxoLT5jaWQgPSBfX2NwdV90b19sZTE2KDB4MDAwMSk7CisKKwljbWQgPSAoc3RydWN0IGwyY2FwX2NtZF9oZHIgKikgc2tiX3B1dChza2IsIEwyQ0FQX0NNRF9IRFJfU0laRSk7CisJY21kLT5jb2RlICA9IGNvZGU7CisJY21kLT5pZGVudCA9IGlkZW50OworCWNtZC0+bGVuICAgPSBfX2NwdV90b19sZTE2KGRsZW4pOworCisJaWYgKGRsZW4pIHsKKwkJY291bnQgLT0gTDJDQVBfSERSX1NJWkUgKyBMMkNBUF9DTURfSERSX1NJWkU7CisJCW1lbWNweShza2JfcHV0KHNrYiwgY291bnQpLCBkYXRhLCBjb3VudCk7CisJCWRhdGEgKz0gY291bnQ7CisJfQorCisJbGVuIC09IHNrYi0+bGVuOworCisJLyogQ29udGludWF0aW9uIGZyYWdtZW50cyAobm8gTDJDQVAgaGVhZGVyKSAqLworCWZyYWcgPSAmc2tiX3NoaW5mbyhza2IpLT5mcmFnX2xpc3Q7CisJd2hpbGUgKGxlbikgeworCQljb3VudCA9IG1pbl90KHVuc2lnbmVkIGludCwgY29ubi0+bXR1LCBsZW4pOworCisJCSpmcmFnID0gYnRfc2tiX2FsbG9jKGNvdW50LCBHRlBfQVRPTUlDKTsKKwkJaWYgKCEqZnJhZykKKwkJCWdvdG8gZmFpbDsKKworCQltZW1jcHkoc2tiX3B1dCgqZnJhZywgY291bnQpLCBkYXRhLCBjb3VudCk7CisKKwkJbGVuICAtPSBjb3VudDsKKwkJZGF0YSArPSBjb3VudDsKKworCQlmcmFnID0gJigqZnJhZyktPm5leHQ7CisJfQorCisJcmV0dXJuIHNrYjsKKworZmFpbDoKKwlrZnJlZV9za2Ioc2tiKTsKKwlyZXR1cm4gTlVMTDsKK30KKworc3RhdGlj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RlKQoreworCXN3aXRjaCAoY29kZSkgeworCWNhc2UgMDoKKwkJcmV0dXJuIDA7CisKKwljYXNlIDB4MDE6CisJCXJldHVybiBFQkFEUlFDOworCisJY2FzZSAweDAyOgorCQlyZXR1cm4gRU5PVENPTk47CisKKwljYXNlIDB4MDM6CisJCXJldHVybiBFSU87CisKKwljYXNlIDB4MDQ6CisJCXJldHVybiBFSE9TVERPV047CisKKwljYXNlIDB4MDU6CisJCXJldHVybiBFQUNDRVM7CisKKwljYXNlIDB4MDY6CisJCXJldHVybiBFQkFERTsKKworCWNhc2UgMHgwNzoKKwkJcmV0dXJuIEVOT01FTTsKKworCWNhc2UgMHgwODoKKwkJcmV0dXJuIEVUSU1FRE9VVDsKKworCWNhc2UgMHgwOToKKwkJcmV0dXJuIEVNTElOSzsKKworCWNhc2UgMHgwYToKKwkJcmV0dXJuIEVNTElOSzsKKworCWNhc2UgMHgwYjoKKwkJcmV0dXJuIEVBTFJFQURZOworCisJY2FzZSAweDBjOgorCQlyZXR1cm4gRUJVU1k7CisKKwljYXNlIDB4MGQ6CisJY2FzZSAweDBlOgorCWNhc2UgMHgwZjoKKwkJcmV0dXJuIEVDT05OUkVGVVNFRDsKKworCWNhc2UgMHgxMDoKKwkJcmV0dXJuIEVUSU1FRE9VVDsKKworCWNhc2UgMHgxMToKKwljYXNlIDB4Mjc6CisJY2FzZSAweDI5OgorCWNhc2UgMHgyMDoKKwkJcmV0dXJuIEVPUE5PVFNVUFA7CisKKwljYXNlIDB4MTI6CisJCXJldHVybiBFSU5WQUw7CisKKwljYXNlIDB4MTM6CisJY2FzZSAweDE0OgorCWNhc2UgMHgxNToKKwkJcmV0dXJuIEVDT05OUkVTRVQ7CisKKwljYXNlIDB4MTY6CisJCXJldHVybiBFQ09OTkFCT1JURUQ7CisKKwljYXNlIDB4MTc6CisJCXJldHVybiBFTE9PUDsKKworCWNhc2UgMHgxODoKKwkJcmV0dXJuIEVBQ0NFUzsKKworCWNhc2UgMHgxYToKKwkJc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isKK3N0YXRpYyB2b2lkIHJmY29tbV9tYWtlX3VpaChzdHJ1Y3Qgc2tfYnVmZiAqc2tiLCB1OCBhZGRyKQoreworCXN0cnVjdCByZmNvbW1faGRyICpoZHI7CisJaW50IGxlbiA9IHNrYi0+bGVuOworCXU4ICpjcmM7CisKKwlpZiAobGVuID4gMTI3KSB7CisJCWhkciA9ICh2b2lkICopIHNrYl9wdXNoKHNrYiwgNCk7CisJCXB1dF91bmFsaWduZWQoaHRvYnMoX19sZW4xNihsZW4pKSwgKHUxNiAqKSAmaGRyLT5sZW4pOworCX0gZWxzZSB7CisJCWhkciA9ICh2b2lkICopIHNrYl9wdXNoKHNrYiwgMyk7CisJCWhkci0+bGVuID0gX19sZW44KGxlbik7CisJfQorCWhkci0+YWRkciA9IGFkZHI7CisJaGRyLT5jdHJsID0gX19jdHJsKFJGQ09NTV9VSUgsIDApOworCisJY3JjID0gc2tiX3B1dChza2IsIDEpOworCSpjcmMgPSBfX2Zjcygodm9pZCAqKSBoZHIpOworfQorCisvKiAtLS0tIFJGQ09NTSBmcmFtZSByZWNlcHRpb24gLS0tLSAqLworc3RhdGljIGludCByZmNvbW1fcmVjdl91YShzdHJ1Y3QgcmZjb21tX3Nlc3Npb24gKnMsIHU4IGRsY2kpCit7CisJQlRfREJHKCJzZXNzaW9uICVwIHN0YXRlICVsZCBkbGNpICVkIiwgcywgcy0+c3RhdGUsIGRsY2kpOworCisJaWYgKGRsY2kpIHsKKwkJLyogRGF0YSBjaGFubmVsICovCisJCXN0cnVjdCByZmNvbW1fZGxjICpkID0gcmZjb21tX2RsY19nZXQocywgZGxjaSk7CisJCWlmICghZCkgeworCQkJcmZjb21tX3NlbmRfZG0ocywgZGxjaSk7CisJCQlyZXR1cm4gMDsKKwkJfQorCisJCXN3aXRjaCAoZC0+c3RhdGUpIHsKKwkJY2FzZSBCVF9DT05ORUNUOgorCQkJcmZjb21tX2RsY19jbGVhcl90aW1lcihkKTsKKworCQkJcmZjb21tX2RsY19sb2N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Kwlwcm9jX2J0X3JmY29tbSA9IHByb2NfbWtkaXIoInJmY29tbSIsIHByb2NfYnQpOworCWlmIChwcm9jX2J0X3JmY29tbSkgeworCQlwcm9jX2J0X3JmY29tbS0+b3duZXIgPSBUSElTX01PRFVMRTsKKworICAgICAgICAJcCA9IGNyZWF0ZV9wcm9jX2VudHJ5KCJkbGMiLCBTX0lSVUdPLCBwcm9jX2J0X3JmY29tbSk7CisJCWlmIChwKQorICAgICAgICAJCXAtPnByb2NfZm9wcyA9ICZyZmNvbW1fc2VxX2ZvcHM7CisJfQorICAgICAgICByZXR1cm4gMDsKK30KKworc3RhdGljIHZvaWQgX19leGl0IHJmY29tbV9wcm9jX2NsZWFudXAodm9pZCkKK3sKKyAgICAgICAgcmVtb3ZlX3Byb2NfZW50cnkoImRsYyIsIHByb2NfYnRfcmZjb21tKTsKKworCXJlbW92ZV9wcm9jX2VudHJ5KCJyZmNvbW0iLCBwcm9jX2J0KTsKK30KKworI2Vsc2UgLyogQ09ORklHX1BST0NfRlMgKi8KKworc3RhdGljIGludCAgX19pbml0IHJmY29tbV9wcm9jX2luaXQodm9pZCkKK3sKKyAgICAgICAgcmV0dXJuIDA7Cit9CisKK3N0YXRpYyB2b2lkIF9fZXhpdCByZmNvbW1fcHJvY19jbGVhbnVwKHZvaWQpCit7CisgICAgICAgIHJldHVybjsKK30KKyNlbmRpZiAvKiBDT05GSUdfUFJPQ19GUyAqLworCisvKiAtLS0tIEluaXRpYWxpemF0aW9uIC0tLS0gKi8KK3N0YXRpYyBpbnQgX19pbml0IHJmY29tbV9pbml0KHZvaWQpCit7CisJbDJjYXBfbG9hZCgpOworCisJaGNpX3JlZ2lzdGVyX2NiKCZyZmNvbW1fY2IpOworCisJa2VybmVsX3RocmVhZChyZmNvbW1fcnVuLCBOVUxMLCBDTE9ORV9LRVJORUwpOworCisJQlRfSU5GTygiUkZDT01NIHZlciAlcyIsIFZFUlNJT04pOworCisJcmZjb21tX3Byb2NfaW5pdCgpOworCisJcm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UxMOworCX0KKworCWQtPmRhdGFfcmVhZHkgICA9IHJmY29tbV9za19kYXRhX3JlYWR5OworCWQtPnN0YXRlX2NoYW5nZSA9IHJmY29tbV9za19zdGF0ZV9jaGFuZ2U7CisKKwlyZmNvbW1fcGkoc2spLT5kbGMgPSBkOworCWQtPm93bmVyID0gc2s7CisKKwlzay0+c2tfZGVzdHJ1Y3QgPSByZmNvbW1fc29ja19kZXN0cnVjdDsKKwlzay0+c2tfc25kdGltZW8gPSBSRkNPTU1fQ09OTl9USU1FT1VUOworCisJc2stPnNrX3NuZGJ1ZiAgID0gUkZDT01NX01BWF9DUkVESVRTICogUkZDT01NX0RFRkFVTFRfTVRVICogMTA7CisJc2stPnNrX3JjdmJ1ZiAgID0gUkZDT01NX01BWF9DUkVESVRTICogUkZDT01NX0RFRkFVTFRfTVRVICogMTA7CisKKwlzb2NrX3Jlc2V0X2ZsYWcoc2ssIFNPQ0tfWkFQUEVEKTsKKworCXNrLT5za19wcm90b2NvbCA9IHByb3RvOworCXNrLT5za19zdGF0ZQk9IEJUX09QRU47CisKKwlidF9zb2NrX2xpbmsoJnJmY29tbV9za19saXN0LCBzayk7CisKKwlCVF9EQkcoInNrICVwIiwgc2spOworCXJldHVybiBzazsKK30KKworc3RhdGljIGludCByZmNvbW1fc29ja19jcmVhdGUoc3RydWN0IHNvY2tldCAqc29jaywgaW50IHByb3RvY29sKQoreworCXN0cnVjdCBzb2NrICpzazsKKworCUJUX0RCRygic29jayAlcCIsIHNvY2spOworCisJc29jay0+c3RhdGUgPSBTU19VTkNPTk5FQ1RFRDsKKworCWlmIChzb2NrLT50eXBlICE9IFNPQ0tfU1RSRUFNICYmIHNvY2stPnR5cGUgIT0gU09DS19SQVcpCisJCXJldHVybiAtRVNPQ0tUTk9TVVBQT1JUOworCisJc29jay0+b3BzID0gJnJmY29tbV9zb2NrX29wczsKKworCWlmICghKHNrID0gcmZjb21tX3NvY2tfYWxsb2Moc29jaywgcHJvdG9jb2wsIEdGUF9LRVJORUwpKSkKKwkJcmV0dXJuIC1FTk9NRU07CisKKwlyZmNvbW1fc29ja19pbml0KHNrLCBOVUxMKTsKKwlyZXR1cm4gMDsKK30KKworc3RhdGljIGludCByZmNvbW1fc29ja19iaW5kKHN0cnVjdCBzb2NrZXQgKnNvY2ssIHN0cnVjdCBzb2NrYWRkciAqYWRkciwgaW50IGFkZHJfbGVuKQoreworCXN0cnVjdCBzb2NrYWRkcl9yYyAqc2EgPSAoc3RydWN0IHNvY2thZGRyX3JjICopIGFkZHI7CisJc3RydWN0IHNvY2sgKnNrID0gc29jay0+c2s7CisJaW50IGVyciA9IDA7CisKKwlCVF9EQkcoInNrICVwICVzIiwgc2ssIGJhdG9zdHIoJnNhLT5yY19iZGFkZHIpKTsKKworCWlmICghYWRkciB8fCBhZGRyLT5zYV9mYW1pbHkgIT0gQUZfQkxVRVRPT1RIKQorCQlyZXR1cm4gLUVJTlZBTDsKKworCWxvY2tfc29jayhzayk7CisKKwlpZiAoc2stPnNrX3N0YXRlICE9IEJUX09QRU4pIHsKKwkJZXJyID0gLUVCQURGRDsKKwkJZ290byBkb25lOworCX0KKworCXdyaXRlX2xvY2tfYmgoJnJmY29tbV9za19saXN0LmxvY2spOworCisJaWYgKHNhLT5yY19jaGFubmVsICYmIF9fcmZjb21tX2dldF9zb2NrX2J5X2FkZHIoc2EtPnJjX2NoYW5uZWwsICZzYS0+cmNfYmRhZGRyKSkgeworCQllcnIgPSAtRUFERFJJTlVTRTsKKwl9IGVsc2UgeworCQkvKiBTYXZlIHNvdXJjZSBhZGRyZXNzICovCisJCWJhY3B5KCZidF9zayhzayktPnNyYywgJnNhLT5yY19iZGFkZHIpOworCQlyZmNvbW1fcGkoc2spLT5jaGFubmVsID0gc2EtPnJjX2NoYW5uZWw7CisJCXNrLT5za19zdGF0ZSA9IEJUX0JPVU5EOworCX0KKworCXdyaXRlX3VubG9ja19iaCgmcmZjb21tX3NrX2xpc3QubG9jayk7CisKK2RvbmU6CisJcmVsZWFzZV9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CisJCQlicmVhazsKKwkJfQorCX0KKwlzZXRfY3VycmVudF9zdGF0ZShUQVNLX1JVTk5JTkcpOworCXJlbW92ZV93YWl0X3F1ZXVlKHNrLT5za19zbGVlcCwgJndhaXQpOworCisJaWYgKGVycikKKwkJZ290byBkb25lOworCisJbmV3c29jay0+c3RhdGUgPSBTU19DT05ORUNURUQ7CisKKwlCVF9EQkcoIm5ldyBzb2NrZXQgJXAiLCBuc2spOworCitkb25lOgorCXJlbGVhc2Vfc29jayhzayk7CisJcmV0dXJuIGVycjsKK30KKworc3RhdGljIGludCByZmNvbW1fc29ja19nZXRuYW1lKHN0cnVjdCBzb2NrZXQgKnNvY2ssIHN0cnVjdCBzb2NrYWRkciAqYWRkciwgaW50ICpsZW4sIGludCBwZWVyKQoreworCXN0cnVjdCBzb2NrYWRkcl9yYyAqc2EgPSAoc3RydWN0IHNvY2thZGRyX3JjICopIGFkZHI7CisJc3RydWN0IHNvY2sgKnNrID0gc29jay0+c2s7CisKKwlCVF9EQkcoInNvY2sgJXAsIHNrICVwIiwgc29jaywgc2spOworCisJc2EtPnJjX2ZhbWlseSAgPSBBRl9CTFVFVE9PVEg7CisJc2EtPnJjX2NoYW5uZWwgPSByZmNvbW1fcGkoc2spLT5jaGFubmVsOworCWlmIChwZWVyKQorCQliYWNweSgmc2EtPnJjX2JkYWRkciwgJmJ0X3NrKHNrKS0+ZHN0KTsKKwllbHNlCisJCWJhY3B5KCZzYS0+cmNfYmRhZGRyLCAmYnRfc2soc2spLT5zcmMpOworCisJKmxlbiA9IHNpemVvZihzdHJ1Y3Qgc29ja2FkZHJfcmMpOworCXJldHVybiAwOworfQorCitzdGF0aWMgaW50IHJmY29tbV9zb2NrX3NlbmRtc2coc3RydWN0IGtpb2NiICppb2NiLCBzdHJ1Y3Qgc29ja2V0ICpzb2NrLAorCQkJICAgICAgIHN0cnVjdCBtc2doZHIgKm1zZywgc2l6ZV90IGxlbikKK3sKKwlzdHJ1Y3Qgc29jayAqc2sgPSBzb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CisJQlRfREJHKCJzayAlcCIsIHNrKTsKKworCWxvY2tfc29jayhzayk7CisKKwlzd2l0Y2ggKG9wdG5hbWUpIHsKKwljYXNlIFJGQ09NTV9MTToKKwkJaWYgKGdldF91c2VyKG9wdCwgKHUzMiBfX3VzZXIgKikgb3B0dmFsKSkgeworCQkJZXJyID0gLUVGQVVMVDsKKwkJCWJyZWFrOworCQl9CisKKwkJcmZjb21tX3BpKHNrKS0+bGlua19tb2RlID0gb3B0OworCQlicmVhazsKKworCWRlZmF1bHQ6CisJCWVyciA9IC1FTk9QUk9UT09QVDsKKwkJYnJlYWs7CisJfQorCisJcmVsZWFzZV9zb2NrKHNrKTsKKwlyZXR1cm4gZXJyOworfQorCitzdGF0aWMgaW50IHJmY29tbV9zb2NrX2dldHNvY2tvcHQoc3RydWN0IHNvY2tldCAqc29jaywgaW50IGxldmVsLCBpbnQgb3B0bmFtZSwgY2hhciBfX3VzZXIgKm9wdHZhbCwgaW50IF9fdXNlciAqb3B0bGVuKQoreworCXN0cnVjdCBzb2NrICpzayA9IHNvY2stPnNrOworCXN0cnVjdCBzb2NrICpsMmNhcF9zazsKKwlzdHJ1Y3QgcmZjb21tX2Nvbm5pbmZvIGNpbmZvOworCWludCBsZW4sIGVyciA9IDA7CisKKwlCVF9EQkcoInNrICVwIiwgc2spOworCisJaWYgKGdldF91c2VyKGxlbiwgb3B0bGVuKSkKKwkJcmV0dXJuIC1FRkFVTFQ7CisKKwlsb2NrX3NvY2soc2spOworCisJc3dpdGNoIChvcHRuYW1lKSB7CisJY2FzZSBSRkNPTU1fTE06CisJCWlmIChwdXRfdXNlcihyZmNvbW1fcGkoc2spLT5saW5rX21vZGUsICh1MzIgX191c2VyICopIG9wdHZhbCkpCisJCQllcnIgPSAtRUZBVUxUOworCQlicmVhazsKKworCWNhc2UgUkZDT01NX0NPTk5JTkZPOgorCQlpZiAoc2stPnNrX3N0YXRlICE9IEJUX0NPTk5FQ1RFRCkgeworCQkJZXJyID0gLUVOT1RDT05OOworCQkJYnJlYWs7CisJCX0KKworCQlsMmNhcF9zayA9IHJmY29tbV9waShzayktPmRsYy0+c2Vzc2lvbi0+c29jay0+c2s7CisKKwkJY2luZm8uaGNpX2hhbmRsZSA9IGwyY2FwX3BpKGwyY2FwX3NrKS0+Y29ubi0+aGNvbi0+aGFuZGxlOworCQltZW1jcHkoY2luZm8uZGV2X2NsYXNzLCBsMmNhcF9waShsMmNhcF9zayktPmNvbm4tPmhjb24tPmRldl9jbGFzcywgMyk7CisKKwkJbGVuID0gbWluX3QodW5zaWduZWQgaW50LCBsZW4sIHNpemVvZihjaW5mbykpOworCQlpZiAoY29weV90b191c2VyKG9wdHZhbCwgKGNoYXIgKikgJmNpbmZvLCBsZW4pKQorCQkJZXJyID0gLUVGQVVMVDsKKworCQlicmVhazsKKworCWRlZmF1bHQ6CisJCWVyciA9IC1FTk9QUk9UT09QVDsKKwkJYnJlYWs7CisJfQorCisJcmVsZWFzZV9zb2NrKHNrKTsKKwlyZXR1cm4gZXJyOworfQorCitzdGF0aWMgaW50IHJmY29tbV9zb2NrX2lvY3RsKHN0cnVjdCBzb2NrZXQgKnNvY2ssIHVuc2lnbmVkIGludCBjbWQsIHVuc2lnbmVkIGxvbmcgYXJnKQoreworCXN0cnVjdCBzb2NrICpzayA9IHNvY2stPnNrOworCWludCBlcnI7CisKKwlsb2NrX3NvY2soc2spOworCisjaWZkZWYgQ09ORklHX0JUX1JGQ09NTV9UVFkKKwllcnIgPSByZmNvbW1fZGV2X2lvY3RsKHNrLCBjbWQsICh2b2lkIF9fdXNlciAqKWFyZyk7CisjZWxzZQorCWVyciA9IC1FT1BOT1RTVVBQOworI2VuZGlmCisKKwlyZWxlYXNlX3NvY2soc2spOworCXJldHVybiBlcnI7Cit9CisKK3N0YXRpYyBpbnQgcmZjb21tX3NvY2tfc2h1dGRvd24oc3RydWN0IHNvY2tldCAqc29jaywgaW50IGhvdykKK3sKKwlzdHJ1Y3Qgc29jayAqc2sgPSBzb2NrLT5zazsKKwlpbnQgZXJyID0gMDsKKworCUJUX0RCRygic29jayAlcCwgc2sgJXAiLCBzb2NrLCBzayk7CisKKwlpZiAoIXNrKSByZXR1cm4gMDsKKworCWxvY2tfc29jayhzayk7CisJaWYgKCFzay0+c2tfc2h1dGRvd24pIHsKKwkJc2stPnNrX3NodXRkb3duID0gU0hVVERPV05fTUFTSzsKKwkJX19yZmNvbW1fc29ja19jbG9zZShzayk7CisKKwkJaWYgKHNvY2tfZmxhZyhzaywgU09DS19MSU5HRVIpICYmIHNrLT5za19saW5nZXJ0aW1lKQorCQkJZXJyID0gYnRfc29ja193YWl0X3N0YXRlKHNrLCBCVF9DTE9TRUQsIHNrLT5za19saW5nZXJ0aW1lKTsKKwl9CisJcmVsZWFzZV9zb2NrKHNrKTsKKwlyZXR1cm4gZXJyOworfQorCitzdGF0aWMgaW50IHJmY29tbV9zb2NrX3JlbGVhc2Uoc3RydWN0IHNvY2tldCAqc29jaykKK3sKKwlzdHJ1Y3Qgc29jayAqc2sgPSBzb2NrLT5zazsKKwlpbnQgZXJyOworCisJQlRfREJHKCJzb2NrICVwLCBzayAlcCIsIHNvY2ssIHNrKTsKKworCWlmICghc2spCisJCXJldHVybiAwOworCisJZXJyID0gcmZjb21tX3NvY2tfc2h1dGRvd24oc29jaywgMik7CisKKwlzb2NrX29ycGhhbihzayk7CisJcmZjb21tX3NvY2tfa2lsbChzayk7CisJcmV0dXJuIGVycjsKK30KKworLyogLS0tLSBSRkNPTU0gY29yZSBsYXllciBjYWxsYmFja3MgLS0tLSAKKyAqCisgKiBjYWxsZWQgdW5kZXIgcmZjb21tX2xvY2soKQorICovCitpbnQgcmZjb21tX2Nvbm5lY3RfaW5kKHN0cnVjdCByZmNvbW1fc2Vzc2lvbiAqcywgdTggY2hhbm5lbCwgc3RydWN0IHJmY29tbV9kbGMgKipkKQoreworCXN0cnVjdCBzb2NrICpzaywgKnBhcmVudDsKKwliZGFkZHJfdCBzcmMsIGRzdDsKKwlpbnQgcmVzdWx0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IHJmY29tbV9zZXFfb3BzID0geworCS5zdGFydCAgPSByZmNvbW1fc2VxX3N0YXJ0LAorCS5uZXh0ICAgPSByZmNvbW1fc2VxX25leHQsCisJLnN0b3AgICA9IHJmY29tbV9zZXFfc3RvcCwKKwkuc2hvdyAgID0gcmZjb21tX3NlcV9zaG93IAorfTsKKworc3RhdGljIGludCByZmNvbW1fc2VxX29wZW4oc3RydWN0IGlub2RlICppbm9kZSwgc3RydWN0IGZpbGUgKmZpbGUpCit7CisJcmV0dXJuIHNlcV9vcGVuKGZpbGUsICZyZmNvbW1fc2VxX29wcyk7Cit9CisKK3N0YXRpYyBzdHJ1Y3QgZmlsZV9vcGVyYXRpb25zIHJmY29tbV9zZXFfZm9wcyA9IHsKKwkub3duZXIJID0gVEhJU19NT0RVTEUsCisJLm9wZW4gICAgPSByZmNvbW1fc2VxX29wZW4sCisJLnJlYWQgICAgPSBzZXFfcmVhZCwKKwkubGxzZWVrICA9IHNlcV9sc2VlaywKKwkucmVsZWFzZSA9IHNlcV9yZWxlYXNlLAorfTsKKworc3RhdGljIGludCAgX19pbml0IHJmY29tbV9zb2NrX3Byb2NfaW5pdCh2b2lkKQoreworICAgICAgICBzdHJ1Y3QgcHJvY19kaXJfZW50cnkgKnAgPSBjcmVhdGVfcHJvY19lbnRyeSgic29jayIsIFNfSVJVR08sIHByb2NfYnRfcmZjb21tKTsKKyAgICAgICAgaWYgKCFwKQorICAgICAgICAgICAgICAgIHJldHVybiAtRU5PTUVNOworICAgICAgICBwLT5wcm9jX2ZvcHMgPSAmcmZjb21tX3NlcV9mb3BzOworICAgICAgICByZXR1cm4gMDsKK30KKworc3RhdGljIHZvaWQgX19leGl0IHJmY29tbV9zb2NrX3Byb2NfY2xlYW51cCh2b2lkKQoreworICAgICAgICByZW1vdmVfcHJvY19lbnRyeSgic29jayIsIHByb2NfYnRfcmZjb21tKTsKK30KKworI2Vsc2UgLyogQ09ORklHX1BST0NfRlMgKi8KKworc3RhdGljIGludCAgX19pbml0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YtPmZsYWdzOworCWRpLmNoYW5uZWwgPSBkZXYtPmNoYW5uZWw7CisJZGkuc3RhdGUgICA9IGRldi0+ZGxjLT5zdGF0ZTsKKwliYWNweSgmZGkuc3JjLCAmZGV2LT5zcmMpOworCWJhY3B5KCZkaS5kc3QsICZkZXYtPmRzdCk7CisKKwlpZiAoY29weV90b191c2VyKGFyZywgJmRpLCBzaXplb2YoZGkpKSkKKwkJZXJyID0gLUVGQVVMVDsKKworCXJmY29tbV9kZXZfcHV0KGRldik7CisJcmV0dXJuIGVycjsKK30KKworaW50IHJmY29tbV9kZXZfaW9jdGwoc3RydWN0IHNvY2sgKnNrLCB1bnNpZ25lZCBpbnQgY21kLCB2b2lkIF9fdXNlciAqYXJnKQoreworCUJUX0RCRygiY21kICVkIGFyZyAlcCIsIGNtZCwgYXJnKTsKKworCXN3aXRjaCAoY21kKSB7CisJY2FzZSBSRkNPTU1DUkVBVEVERVY6CisJCXJldHVybiByZmNvbW1fY3JlYXRlX2RldihzaywgYXJnKTsKKworCWNhc2UgUkZDT01NUkVMRUFTRURFVjoKKwkJcmV0dXJuIHJmY29tbV9yZWxlYXNlX2RldihhcmcpOworCisJY2FzZSBSRkNPTU1HRVRERVZMSVNUOgorCQlyZXR1cm4gcmZjb21tX2dldF9kZXZfbGlzdChhcmcpOworCisJY2FzZSBSRkNPTU1HRVRERVZJTkZPOgorCQlyZXR1cm4gcmZjb21tX2dldF9kZXZfaW5mbyhhcmcpOworCX0KKworCXJldHVybiAtRUlOVkFMOworfQorCisvKiAtLS0tIERMQyBjYWxsYmFja3MgLS0tLSAqLworc3RhdGljIHZvaWQgcmZjb21tX2Rldl9kYXRhX3JlYWR5KHN0cnVjdCByZmNvbW1fZGxjICpkbGMsIHN0cnVjdCBza19idWZmICpza2IpCit7CisJc3RydWN0IHJmY29tbV9kZXYgKmRldiA9IGRsYy0+b3duZXI7CisJc3RydWN0IHR0eV9zdHJ1Y3QgKnR0eTsKKyAgICAgICAKKwlpZiAoIWRldi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NvX2Nvbm4gKmNvbm47CisKKwlpZiAoKGNvbm4gPSBoY29uLT5zY29fZGF0YSkpCisJCXJldHVybiBjb25uOworCisJaWYgKHN0YXR1cykKKwkJcmV0dXJuIGNvbm47CisKKwlpZiAoIShjb25uID0ga21hbGxvYyhzaXplb2Yoc3RydWN0IHNjb19jb25uKSwgR0ZQX0FUT01JQykpKQorCQlyZXR1cm4gTlVMTDsKKwltZW1zZXQoY29ubiwgMCwgc2l6ZW9mKHN0cnVjdCBzY29fY29ubikpOworCisJc3Bpbl9sb2NrX2luaXQoJmNvbm4tPmxvY2spOworCisJaGNvbi0+c2NvX2RhdGEgPSBjb25uOworCWNvbm4tPmhjb24gPSBoY29uOworCisJY29ubi0+c3JjID0gJmhkZXYtPmJkYWRkcjsKKwljb25uLT5kc3QgPSAmaGNvbi0+ZHN0OworCisJaWYgKGhkZXYtPnNjb19tdHUgPiAwKQorCQljb25uLT5tdHUgPSBoZGV2LT5zY29fbXR1OworCWVsc2UKKwkJY29ubi0+bXR1ID0gNjA7CisKKwlCVF9EQkcoImhjb24gJXAgY29ubiAlcCIsIGhjb24sIGNvbm4pOworCXJldHVybiBjb25uOworfQorCitzdGF0aWMgaW5saW5lIHN0cnVjdCBzb2NrICpzY29fY2hhbl9nZXQoc3RydWN0IHNjb19jb25uICpjb25uKQoreworCXN0cnVjdCBzb2NrICpzayA9IE5VTEw7CisJc2NvX2Nvbm5fbG9jayhjb25uKTsKKwlzayA9IGNvbm4tPnNrOworCXNjb19jb25uX3VubG9jayhjb25uKTsKKwlyZXR1cm4gc2s7Cit9CisKK3N0YXRpYyBpbnQgc2NvX2Nvbm5fZGVsKHN0cnVjdCBoY2lfY29ubiAqaGNvbiwgaW50IGVycikKK3sKKwlzdHJ1Y3Qgc2NvX2Nvbm4gKmNvbm47CisJc3RydWN0IHNvY2sgKnNrOworCisJaWYgKCEoY29ubiA9IGhjb24tPnNjb19kYXRhKSkgCisJCXJldHVybiAwOworCisJQlRfREJHKCJoY29uICVwIGNvbm4gJXAsIGVyciAlZCIsIGhjb24sIGNvbm4sIGVycik7CisKKwkvKiBLaWxsIHNvY2tldCAqLworCWlmICgoc2sgPSBzY29fY2hhbl9nZXQoY29ubikpKSB7CisJCWJoX2xvY2tfc29jayhzayk7CisJCXNjb19zb2NrX2NsZWFyX3RpbWVyKHNrKTsKKwkJc2NvX2NoYW5fZGVsKHNrLCBlcnIpOworCQliaF91bmxvY2tfc29jayhzayk7CisJCXNjb19zb2NrX2tpbGwoc2spOworCX0KKworCWhjb24tPnNjb19kYXRhID0gTlVMTDsKKwlrZnJlZShjb25uKTsKKwlyZXR1cm4gMDsKK30KKworc3RhdGljIGlubGluZSBpbnQgc2NvX2NoYW5fYWRkKHN0cnVjdCBzY29fY29ubiAqY29ubiwgc3RydWN0IHNvY2sgKnNrLCBzdHJ1Y3Qgc29jayAqcGFyZW50KQoreworCWludCBlcnIgPSAwOworCisJc2NvX2Nvbm5fbG9jayhjb25uKTsKKwlpZiAoY29ubi0+c2spIHsKKwkJZXJyID0gLUVCVVNZOworCX0gZWxzZSB7CisJCV9fc2NvX2NoYW5fYWRkKGNvbm4sIHNrLCBwYXJlbnQpOworCX0KKwlzY29fY29ubl91bmxvY2soY29ubik7CisJcmV0dXJuIGVycjsKK30KKworc3RhdGljIGludCBzY29fY29ubmVjdChzdHJ1Y3Qgc29jayAqc2spCit7CisJYmRhZGRyX3QgKnNyYyA9ICZidF9zayhzayktPnNyYzsKKwliZGFkZHJfdCAqZHN0ID0gJmJ0X3NrKHNrKS0+ZHN0OworCXN0cnVjdCBzY29fY29ubiAqY29ubjsKKwlzdHJ1Y3QgaGNpX2Nvbm4gKmhjb247CisJc3RydWN0IGhjaV9kZXYgICpoZGV2OworCWludCBlcnIgPSAwOworCisJQlRfREJHKCIlcyAtPiAlcyIsIGJhdG9zdHIoc3JjKSwgYmF0b3N0cihkc3QpKTsKKworCWlmICghKGhkZXYgPSBoY2lfZ2V0X3JvdXRlKGRzdCwgc3JjKSkpCisJCX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T5tdHUpCisJCXJldHVybiAtRUlOVkFMOworCisJQlRfREJHKCJzayAlcCBsZW4gJWQiLCBzaywgbGVuKTsKKworCWNvdW50ID0gbWluX3QodW5zaWduZWQgaW50LCBjb25uLT5tdHUsIGxlbik7CisJaWYgKCEoc2tiID0gYnRfc2tiX3NlbmRfYWxsb2Moc2ssIGNvdW50LCBtc2ctPm1zZ19mbGFncyAmIE1TR19ET05UV0FJVCwgJmVycikpKQorCQlyZXR1cm4gZXJyOworCisJaWYgKG1lbWNweV9mcm9taW92ZWMoc2tiX3B1dChza2IsIGNvdW50KSwgbXNnLT5tc2dfaW92LCBjb3VudCkpIHsKKwkJZXJyID0gLUVGQVVMVDsKKwkJZ290byBmYWlsOworCX0KKworCWlmICgoZXJyID0gaGNpX3NlbmRfc2NvKGNvbm4tPmhjb24sIHNrYikpIDwgMCkKKwkJZ290byBmYWlsOworCisJcmV0dXJuIGNvdW50OworCitmYWlsOgorCWtmcmVlX3NrYihza2IpOworCXJldHVybiBlcnI7Cit9CisKK3N0YXRpYyBpbmxpbmUgdm9pZCBzY29fcmVjdl9mcmFtZShzdHJ1Y3Qgc2NvX2Nvbm4gKmNvbm4sIHN0cnVjdCBza19idWZmICpza2IpCit7CisJc3RydWN0IHNvY2sgKnNrID0gc2NvX2NoYW5fZ2V0KGNvbm4pOworCisJaWYgKCFzaykKKwkJZ290byBkcm9wOworCisJQlRfREJHKCJzayAlcCBsZW4gJWQiLCBzaywgc2tiLT5sZW4pOworCisJaWYgKHNrLT5za19zdGF0ZSAhPSBCVF9DT05ORUNURUQpCisJCWdvdG8gZHJvcDsKKworCWlmICghc29ja19xdWV1ZV9yY3Zfc2tiKHNrLCBza2IpKQorCQlyZXR1cm47CisKK2Ryb3A6CisJa2ZyZWVfc2tiKHNrYik7CisJcmV0dXJuOworfQorCisvKiAtLS0tLS0tLSBTb2NrZXQgaW50ZXJmYWNlIC0tLS0tLS0tLS0gKi8KK3N0YXRpYyBzdHJ1Y3Qgc29jayAqX19z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jb19zb2NrX2Nvbm5lY3Qoc3RydWN0IHNvY2tldCAqc29jaywgc3RydWN0IHNvY2thZGRyICphZGRyLCBpbnQgYWxlbiwgaW50IGZsYWdzKQoreworCXN0cnVjdCBzb2NrYWRkcl9zY28gKnNhID0gKHN0cnVjdCBzb2NrYWRkcl9zY28gKikgYWRkcjsKKwlzdHJ1Y3Qgc29jayAqc2sgPSBzb2NrLT5zazsKKwlpbnQgZXJyID0gMDsKKworCisJQlRfREJHKCJzayAlcCIsIHNrKTsKKworCWlmIChhZGRyLT5zYV9mYW1pbHkgIT0gQUZfQkxVRVRPT1RIIHx8IGFsZW4gPCBzaXplb2Yoc3RydWN0IHNvY2thZGRyX3NjbykpCisJCXJldHVybiAtRUlOVkFMOworCisJaWYgKHNrLT5za19zdGF0ZSAhPSBCVF9PUEVOICYmIHNrLT5za19zdGF0ZSAhPSBCVF9CT1VORCkKKwkJcmV0dXJuIC1FQkFERkQ7CisKKwlpZiAoc2stPnNrX3R5cGUgIT0gU09DS19TRVFQQUNLRVQpCisJCXJldHVybiAtRUlOVkFMOworCisJbG9ja19zb2NrKHNrKTsKKworCS8qIFNldCBkZXN0aW5hdGlvbiBhZGRyZXNzIGFuZCBwc20gKi8KKwliYWNweSgmYnRfc2soc2spLT5kc3QsICZzYS0+c2NvX2JkYWRkcik7CisKKwlpZiAoKGVyciA9IHNjb19jb25uZWN0KHNrKSkpCisJCWdvdG8gZG9uZTsKKworCWVyciA9IGJ0X3NvY2tfd2FpdF9zdGF0ZShzaywgQlRfQ09OTkVDVEVELCAKKwkJCXNvY2tfc25kdGltZW8oc2ssIGZsYWdzICYgT19OT05CTE9DSykpOworCitkb25lOgorCXJlbGVhc2Vfc29jayhzayk7CisJcmV0dXJuIGVycjsKK30KKworc3RhdGljIGludCBzY29fc29ja19saXN0ZW4oc3RydWN0IHNvY2tldCAqc29jaywgaW50IGJhY2tsb2cpCit7CisJc3RydWN0IHNvY2sgKnNrID0gc29jay0+c2s7CisJaW50IGVyciA9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CQlzZXRfY3VycmVudF9zdGF0ZShUQVNLX0lOVEVSUlVQVElCTEUpOworCQlpZiAoIXRpbWVvKSB7CisJCQllcnIgPSAtRUFHQUlOOworCQkJYnJlYWs7CisJCX0KKworCQlyZWxlYXNlX3NvY2soc2spOworCQl0aW1lbyA9IHNjaGVkdWxlX3RpbWVvdXQodGltZW8pOworCQlsb2NrX3NvY2soc2spOworCisJCWlmIChzay0+c2tfc3RhdGUgIT0gQlRfTElTVEVOKSB7CisJCQllcnIgPSAtRUJBREZEOworCQkJYnJlYWs7CisJCX0KKworCQlpZiAoc2lnbmFsX3BlbmRpbmcoY3VycmVudCkpIHsKKwkJCWVyciA9IHNvY2tfaW50cl9lcnJubyh0aW1lbyk7CisJCQlicmVhazsKKwkJfQorCX0KKwlzZXRfY3VycmVudF9zdGF0ZShUQVNLX1JVTk5JTkcpOworCXJlbW92ZV93YWl0X3F1ZXVlKHNrLT5za19zbGVlcCwgJndhaXQpOworCisJaWYgKGVycikKKwkJZ290byBkb25lOworCisJbmV3c29jay0+c3RhdGUgPSBTU19DT05ORUNURUQ7CisKKwlCVF9EQkcoIm5ldyBzb2NrZXQgJXAiLCBjaCk7CisKK2RvbmU6CisJcmVsZWFzZV9zb2NrKHNrKTsKKwlyZXR1cm4gZXJyOworfQorCitzdGF0aWMgaW50IHNjb19zb2NrX2dldG5hbWUoc3RydWN0IHNvY2tldCAqc29jaywgc3RydWN0IHNvY2thZGRyICphZGRyLCBpbnQgKmxlbiwgaW50IHBlZXIpCit7CisJc3RydWN0IHNvY2thZGRyX3NjbyAqc2EgPSAoc3RydWN0IHNvY2thZGRyX3NjbyAqKSBhZGRyOworCXN0cnVjdCBzb2NrICpzayA9IHNvY2stPnNrOworCisJQlRfREJHKCJzb2NrICVwLCBzayAlcCIsIHNvY2ssIHNrKTsKKworCWFkZHItPnNhX2ZhbWlseSA9IEFGX0JMVUVUT09USDsKKwkqbGVuID0gc2l6ZW9mKHN0cnVjdCBzb2NrYWRkcl9zY28pOworCisJaWYgKHBlZXIpCisJCWJhY3B5KCZzYS0+c2NvX2JkYWRkciwgJmJ0X3NrKHNrKS0+ZHN0KTsKKwllbHNlCisJCWJhY3B5KCZzYS0+c2NvX2JkYWRkciwgJmJ0X3NrKHNrKS0+c3JjKTsKKworCXJldHVybiAwOworfQorCitzdGF0aWMgaW50IHNjb19zb2NrX3NlbmRtc2coc3RydWN0IGtpb2NiICppb2NiLCBzdHJ1Y3Qgc29ja2V0ICpzb2NrLCAKKwkJCSAgICBzdHJ1Y3QgbXNnaGRyICptc2csIHNpemVfdCBsZW4pCit7CisJc3RydWN0IHNvY2sgKnNrID0gc29jay0+c2s7CisJaW50IGVyciA9IDA7CisKKwlCVF9EQkcoInNvY2sgJXAsIHNrICVwIiwgc29jaywgc2spOworCisJaWYgKHNrLT5za19lcnIpCisJCXJldHVybiBzb2NrX2Vycm9yKHNrKTsKKworCWlmIChtc2ctPm1zZ19mbGFncyAmIE1TR19PT0IpCisJCXJldHVybiAtRU9QTk9UU1VQUDsKKworCWxvY2tfc29jayhzayk7CisKKwlpZiAoc2stPnNrX3N0YXRlID09IEJUX0NPTk5FQ1RFRCkKKwkJZXJyID0gc2NvX3NlbmRfZnJhbWUoc2ssIG1zZywgbGVuKTsKKwllbHNlCisJCWVyciA9IC1FTk9UQ09OTjsKKworCXJlbGVhc2Vfc29jayhzayk7CisJcmV0dXJuIGVycjsKK30KKworc3RhdGljIGludCBzY29fc29ja19zZXRzb2Nrb3B0KHN0cnVjdCBzb2NrZXQgKnNvY2ssIGludCBsZXZlbCwgaW50IG9wdG5hbWUsIGNoYXIgX191c2VyICpvcHR2YWwsIGludCBvcHRsZW4pCit7CisJc3RydWN0IHNvY2sgKnNrID0gc29jay0+c2s7CisJaW50IGVyciA9IDA7CisKKwlCVF9EQkcoInNrICVwIiwgc2spOworCisJbG9ja19zb2NrKHNrKTsKKworCXN3aXRjaCAob3B0bmFtZSkgeworCWRlZmF1bHQ6CisJCWVyciA9IC1FTk9QUk9UT09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KTsKKworCXNjb19waShzayktPmNvbm4gPSBjb25uOworCWNvbm4tPnNrID0gc2s7CisKKwlpZiAocGFyZW50KQorCQlidF9hY2NlcHRfZW5xdWV1ZShwYXJlbnQsIHNrKTsKK30KKworLyogRGVsZXRlIGNoYW5uZWwuIAorICogTXVzdCBiZSBjYWxsZWQgb24gdGhlIGxvY2tlZCBzb2NrZXQuICovCitzdGF0aWMgdm9pZCBzY29fY2hhbl9kZWwoc3RydWN0IHNvY2sgKnNrLCBpbnQgZXJyKQoreworCXN0cnVjdCBzY29fY29ubiAqY29ubjsKKworCWNvbm4gPSBzY29fcGkoc2spLT5jb25uOworCisJQlRfREJHKCJzayAlcCwgY29ubiAlcCwgZXJyICVkIiwgc2ssIGNvbm4sIGVycik7CisKKwlpZiAoY29ubikgeyAKKwkJc2NvX2Nvbm5fbG9jayhjb25uKTsKKwkJY29ubi0+c2sgPSBOVUxMOworCQlzY29fcGkoc2spLT5jb25uID0gTlVMTDsKKwkJc2NvX2Nvbm5fdW5sb2NrKGNvbm4pOworCQloY2lfY29ubl9wdXQoY29ubi0+aGNvbik7CisJfQorCisJc2stPnNrX3N0YXRlID0gQlRfQ0xPU0VEOworCXNrLT5za19lcnIgICA9IGVycjsKKwlzay0+c2tfc3RhdGVfY2hhbmdlKHNrKTsKKworCXNvY2tfc2V0X2ZsYWcoc2ssIFNPQ0tfWkFQUEVEKTsKK30KKworc3RhdGljIHZvaWQgc2NvX2Nvbm5fcmVhZHkoc3RydWN0IHNjb19jb25uICpjb25uKQoreworCXN0cnVjdCBzb2NrICpwYXJlbnQsICpzazsKKworCUJUX0RCRygiY29ubiAlcCIsIGNvbm4pOworCisJc2NvX2Nvbm5fbG9jayhjb25uKTsKKworCWlmICgoc2sgPSBjb25uLT5zaykpIHsKKwkJc2NvX3NvY2tfY2xlYXJfdGltZXIoc2spOworCQliaF9sb2NrX3NvY2soc2spOworCQlzay0+c2tfc3RhdGUgPSBCVF9DT05ORUNURUQ7CisJCXNrLT5za19zdGF0ZV9jaGFuZ2Uoc2spOworCQliaF91bmxvY2tfc29jayhzayk7CisJfSBlbHNlIHsKKwkJcGFyZW50ID0gc2NvX2dldF9zb2NrX2xpc3Rlbihjb25uLT5zcmMpOworCQlpZiAoIXBhcmVudCkKKwkJCWdvdG8gZG9uZTsKKworCQliaF9sb2NrX3NvY2socGFyZW50KTsKKworCQlzayA9IHNjb19zb2NrX2FsbG9jKE5VTEwsIEJUUFJPVE9fU0NPLCBHRlBfQVRPTUlDKTsKKwkJaWYgKCFzaykgeworCQkJYmhfdW5sb2NrX3NvY2socGFyZW50KTsKKwkJCWdvdG8gZG9uZTsKKwkJfQorCisJCXNjb19zb2NrX2luaXQoc2ssIHBhcmVudCk7CisKKwkJYmFjcHkoJmJ0X3NrKHNrKS0+c3JjLCBjb25uLT5zcmMpOworCQliYWNweSgmYnRfc2soc2spLT5kc3QsIGNvbm4tPmRzdCk7CisKKwkJaGNpX2Nvbm5faG9sZChjb25uLT5oY29uKTsKKwkJX19zY29fY2hhbl9hZGQoY29ubiwgc2ssIHBhcmVudCk7CisKKwkJc2stPnNrX3N0YXRlID0gQlRfQ09OTkVDVEVEOworCisJCS8qIFdha2UgdXAgcGFyZW50ICovCisJCXBhcmVudC0+c2tfZGF0YV9yZWFkeShwYXJlbnQsIDEpOworCisJCWJoX3VubG9ja19zb2NrKHBhcmVudCk7CisJfQorCitkb25lOgorCXNjb19jb25uX3VubG9jayhjb25uKTsKK30KKworLyogLS0tLS0gU0NPIGludGVyZmFjZSB3aXRoIGxvd2VyIGxheWVyIChIQ0kpIC0tLS0tICovCitzdGF0aWMgaW50IHNjb19jb25uZWN0X2luZChzdHJ1Y3QgaGNpX2RldiAqaGRldiwgYmRhZGRyX3QgKmJkYWRkciwgX191OCB0eXBlKQoreworCUJUX0RCRygiaGRldiAlcywgYmRhZGRyICVzIiwgaGRldi0+bmFtZSwgYmF0b3N0cihiZGFkZHIpKTsKKworCS8qIEFsd2F5cyBhY2NlcHQgY29ubmVjdGl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YnJpZGdlX3BvcnQgKnA7CisJaW50IG10dSA9IDA7CisKKwlBU1NFUlRfUlROTCgpOworCisJaWYgKGxpc3RfZW1wdHkoJmJyLT5wb3J0X2xpc3QpKQorCQltdHUgPSAxNTAwOworCWVsc2UgeworCQlsaXN0X2Zvcl9lYWNoX2VudHJ5KHAsICZici0+cG9ydF9saXN0LCBsaXN0KSB7CisJCQlpZiAoIW10dSAgfHwgcC0+ZGV2LT5tdHUgPCBtdHUpCisJCQkJbXR1ID0gcC0+ZGV2LT5tdHU7CisJCX0KKwl9CisJcmV0dXJuIG10dTsKK30KKworLyogY2FsbGVkIHdpdGggUlROTCAqLworaW50IGJyX2FkZF9pZihzdHJ1Y3QgbmV0X2JyaWRnZSAqYnIsIHN0cnVjdCBuZXRfZGV2aWNlICpkZXYpCit7CisJc3RydWN0IG5ldF9icmlkZ2VfcG9ydCAqcDsKKwlpbnQgZXJyID0gMDsKKworCWlmIChkZXYtPmZsYWdzICYgSUZGX0xPT1BCQUNLIHx8IGRldi0+dHlwZSAhPSBBUlBIUkRfRVRIRVIpCisJCXJldHVybiAtRUlOVkFMOworCisJaWYgKGRldi0+aGFyZF9zdGFydF94bWl0ID09IGJyX2Rldl94bWl0KQorCQlyZXR1cm4gLUVMT09QOworCisJaWYgKGRldi0+YnJfcG9ydCAhPSBOVUxMKQorCQlyZXR1cm4gLUVCVVNZOworCisJaWYgKElTX0VSUihwID0gbmV3X25icChiciwgZGV2LCBicl9pbml0aWFsX3BvcnRfY29zdChkZXYpKSkpCisJCXJldHVybiBQVFJfRVJSKHApOworCisgCWlmICgoZXJyID0gYnJfZmRiX2luc2VydChiciwgcCwgZGV2LT5kZXZfYWRkcikpKQorCQlkZXN0cm95X25icChwKTsKKyAKKwllbHNlIGlmICgoZXJyID0gYnJfc3lzZnNfYWRkaWYocCkpKQorCQlkZWxfbmJwKHApOworCWVsc2UgeworCQlkZXZfc2V0X3Byb21pc2N1aXR5KGRldiwgMSk7CisKKwkJbGlzdF9hZGR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G9va19vcHMgYnJfbmZfb3BzW10gPSB7CisJeyAuaG9vayA9IGJyX25mX3ByZV9yb3V0aW5nLCAKKwkgIC5vd25lciA9IFRISVNfTU9EVUxFLCAKKwkgIC5wZiA9IFBGX0JSSURHRSwgCisJICAuaG9va251bSA9IE5GX0JSX1BSRV9ST1VUSU5HLCAKKwkgIC5wcmlvcml0eSA9IE5GX0JSX1BSSV9CUk5GLCB9LAorCXsgLmhvb2sgPSBicl9uZl9sb2NhbF9pbiwKKwkgIC5vd25lciA9IFRISVNfTU9EVUxFLAorCSAgLnBmID0gUEZfQlJJREdFLAorCSAgLmhvb2tudW0gPSBORl9CUl9MT0NBTF9JTiwKKwkgIC5wcmlvcml0eSA9IE5GX0JSX1BSSV9CUk5GLCB9LAorCXsgLmhvb2sgPSBicl9uZl9mb3J3YXJkX2lwLAorCSAgLm93bmVyID0gVEhJU19NT0RVTEUsCisJICAucGYgPSBQRl9CUklER0UsCisJICAuaG9va251bSA9IE5GX0JSX0ZPUldBUkQsCisJICAucHJpb3JpdHkgPSBORl9CUl9QUklfQlJORiAtIDEsIH0sCisJeyAuaG9vayA9IGJyX25mX2ZvcndhcmRfYXJwLAorCSAgLm93bmVyID0gVEhJU19NT0RVTEUsCisJICAucGYgPSBQRl9CUklER0UsCisJICAuaG9va251bSA9IE5GX0JSX0ZPUldBUkQsCisJICAucHJpb3JpdHkgPSBORl9CUl9QUklfQlJORiwgfSwKKwl7IC5ob29rID0gYnJfbmZfbG9jYWxfb3V0LAorCSAgLm93bmVyID0gVEhJU19NT0RVTEUsCisJICAucGYgPSBQRl9CUklER0UsCisJICAuaG9va251bSA9IE5GX0JSX0xPQ0FMX09VVCwKKwkgIC5wcmlvcml0eSA9IE5GX0JSX1BSSV9GSVJTVCwgfSwKKwl7IC5ob29rID0gYnJfbmZfcG9zdF9yb3V0aW5nLAorCSAgLm93bmVyID0gVEhJU19NT0RVTEUsCisJICAucGYgPSBQRl9CUklER0UsCisJICAuaG9va251bSA9IE5GX0J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i44YmY2ZDlmCi0tLSAvZGV2L251bGwKKysrIGIvbmV0L2JyaWRnZS9uZXRmaWx0ZXIvTWFrZWZpbGUKQEAgLTAsMCArMSwzMiBAQAorIworIyBNYWtlZmlsZSBmb3IgdGhlIG5ldGZpbHRlciBtb2R1bGVzIGZvciBMaW5rIExheWVyIGZpbHRlcmluZyBvbiBhIGJyaWRnZS4KKyMKKworb2JqLSQoQ09ORklHX0JSSURHRV9ORl9FQlRBQkxFUykgKz0gZWJ0YWJsZXMubworCisjIHRhYmxlcworb2JqLSQoQ09ORklHX0JSSURHRV9FQlRfQlJPVVRFKSArPSBlYnRhYmxlX2Jyb3V0ZS5vCitvYmotJChDT05GSUdfQlJJREdFX0VCVF9UX0ZJTFRFUikgKz0gZWJ0YWJsZV9maWx0ZXIubworb2JqLSQoQ09ORklHX0JSSURHRV9FQlRfVF9OQVQpICs9IGVidGFibGVfbmF0Lm8KKworI21hdGNoZXMKK29iai0kKENPTkZJR19CUklER0VfRUJUXzgwMl8zKSArPSBlYnRfODAyXzMubworb2JqLSQoQ09ORklHX0JSSURHRV9FQlRfQU1PTkcpICs9IGVidF9hbW9uZy5vCitvYmotJChDT05GSUdfQlJJREdFX0VCVF9BUlApICs9IGVidF9hcnAubworb2JqLSQoQ09ORklHX0JSSURHRV9FQlRfSVApICs9IGVidF9pcC5vCitvYmotJChDT05GSUdfQlJJREdFX0VCVF9MSU1JVCkgKz0gZWJ0X2xpbWl0Lm8KK29iai0kKENPTkZJR19CUklER0VfRUJUX01BUkspICs9IGVidF9tYXJrX20ubworb2JqLSQoQ09ORklHX0JSSURHRV9FQlRfUEtUVFlQRSkgKz0gZWJ0X3BrdHR5cGUubworb2JqLSQoQ09ORklHX0JSSURHRV9FQlRfU1RQKSArPSBlYnRfc3RwLm8KK29iai0kKENPTkZJR19CUklER0VfRUJUX1ZMQU4pICs9IGVidF92bGFuLm8KKworIyB0YXJnZXRzCitvYmotJChDT05GSUdfQlJJREdFX0VCVF9BUlBSRVBMWS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JCWlmICh2ZXJkaWN0ID09IEVCVF9DT05USU5VRSkKKwkJCWdvdG8gbGV0c2NvbnRpbnVlOworI2lmZGVmIENPTkZJR19ORVRGSUxURVJfREVCVUcKKwkJaWYgKHZlcmRpY3QgPCAwKSB7CisJCQlCVUdQUklOVCgiYm9ndXMgc3RhbmRhcmQgdmVyZGljdFxuIik7CisJCQlyZWFkX3VubG9ja19iaCgmdGFibGUtPmxvY2spOworCQkJcmV0dXJuIE5GX0RST1A7CisJCX0KKyNlbmRpZgorCQkvKiBqdW1wIHRvIGEgdWRjICovCisJCWNzW3NwXS5uID0gaSArIDE7CisJCWNzW3NwXS5jaGFpbmluZm8gPSBjaGFpbmluZm87CisJCWNzW3NwXS5lID0gKHN0cnVjdCBlYnRfZW50cnkgKikKKwkJICAgKCgoY2hhciAqKXBvaW50KSArIHBvaW50LT5uZXh0X29mZnNldCk7CisJCWkgPSAwOworCQljaGFpbmluZm8gPSAoc3RydWN0IGVidF9lbnRyaWVzICopIChiYXNlICsgdmVyZGljdCk7CisjaWZkZWYgQ09ORklHX05FVEZJTFRFUl9ERUJVRworCQlpZiAoY2hhaW5pbmZvLT5kaXN0aW5ndWlzaGVyKSB7CisJCQlCVUdQUklOVCgianVtcCB0byBub24tY2hhaW5cbiIpOworCQkJcmVhZF91bmxvY2tfYmgoJnRhYmxlLT5sb2NrKTsKKwkJCXJldHVybiBORl9EUk9QOworCQl9CisjZW5kaWYKKwkJbmVudHJpZXMgPSBjaGFpbmluZm8tPm5lbnRyaWVzOworCQlwb2ludCA9IChzdHJ1Y3QgZWJ0X2VudHJ5ICopY2hhaW5pbmZvLT5kYXRhOworCQljb3VudGVyX2Jhc2UgPSBjYl9iYXNlICsgY2hhaW5pbmZvLT5jb3VudGVyX29mZnNldDsKKwkJc3ArKzsKKwkJY29udGludWU7CitsZXRzY29udGludWU6CisJCXBvaW50ID0gKHN0cnVjdCBlYnRfZW50cnkgKikKKwkJICAgKCgoY2hhciAqKXBvaW50KSArIHBvaW50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XJldCA9IGRvd25faW50ZXJydXB0aWJsZSgmZWJ0X211dGV4KTsKKwlpZiAocmV0ICE9IDApCisJCXJldHVybiByZXQ7CisJaWYgKCFsaXN0X25hbWVkX2luc2VydCgmZWJ0X3RhcmdldHMsIHRhcmdldCkpIHsKKwkJdXAoJmVidF9tdXRleCk7CisJCXJldHVybiAtRUVYSVNUOworCX0KKwl1cCgmZWJ0X211dGV4KTsKKworCXJldHVybiAwOworfQorCit2b2lkIGVidF91bnJlZ2lzdGVyX3RhcmdldChzdHJ1Y3QgZWJ0X3RhcmdldCAqdGFyZ2V0KQoreworCWRvd24oJmVidF9tdXRleCk7CisJTElTVF9ERUxFVEUoJmVidF90YXJnZXRzLCB0YXJnZXQpOworCXVwKCZlYnRfbXV0ZXgpOworfQorCitpbnQgZWJ0X3JlZ2lzdGVyX21hdGNoKHN0cnVjdCBlYnRfbWF0Y2ggKm1hdGNoKQoreworCWludCByZXQ7CisKKwlyZXQgPSBkb3duX2ludGVycnVwdGlibGUoJmVidF9tdXRleCk7CisJaWYgKHJldCAhPSAwKQorCQlyZXR1cm4gcmV0OworCWlmICghbGlzdF9uYW1lZF9pbnNlcnQoJmVidF9tYXRjaGVzLCBtYXRjaCkpIHsKKwkJdXAoJmVidF9tdXRleCk7CisJCXJldHVybiAtRUVYSVNUOworCX0KKwl1cCgmZWJ0X211dGV4KTsKKworCXJldHVybiAwOworfQorCit2b2lkIGVidF91bnJlZ2lzdGVyX21hdGNoKHN0cnVjdCBlYnRfbWF0Y2ggKm1hdGNoKQoreworCWRvd24oJmVidF9tdXRleCk7CisJTElTVF9ERUxFVEUoJmVidF9tYXRjaGVzLCBtYXRjaCk7CisJdXAoJmVidF9tdXRleCk7Cit9CisKK2ludCBlYnRfcmVnaXN0ZXJfd2F0Y2hlcihzdHJ1Y3QgZWJ0X3dhdGNoZXIgKndhdGNoZXIpCit7CisJaW50IHJldDsKKworCXJldCA9IGRvd25faW50ZXJydXB0aWJsZSgmZWJ0X211dGV4KTsK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oZHIuY21zZ190eXBlID0gdHlwZTsKKwljbWhkci5jbXNnX2xlbiA9IGNtbGVuOworCisJaWYoY29weV90b191c2VyKGNtLCAmY21oZHIsIHNpemVvZiBjbWhkcikpCisJCXJldHVybiAtRUZBVUxUOworCWlmKGNvcHlfdG9fdXNlcihDTVNHX0NPTVBBVF9EQVRBKGNtKSwgZGF0YSwgY21sZW4gLSBzaXplb2Yoc3RydWN0IGNvbXBhdF9jbXNnaGRyKSkpCisJCXJldHVybiAtRUZBVUxUOworCWNtbGVuID0gQ01TR19DT01QQVRfU1BBQ0UobGVuKTsKKwlrbXNnLT5tc2dfY29udHJvbCArPSBjbWxlbjsKKwlrbXNnLT5tc2dfY29udHJvbGxlbiAtPSBjbWxlbjsKKwlyZXR1cm4gMDsKK30KKwordm9pZCBzY21fZGV0YWNoX2Zkc19jb21wYXQoc3RydWN0IG1zZ2hkciAqa21zZywgc3RydWN0IHNjbV9jb29raWUgKnNjbSkKK3sKKwlzdHJ1Y3QgY29tcGF0X2Ntc2doZHIgX191c2VyICpjbSA9IChzdHJ1Y3QgY29tcGF0X2Ntc2doZHIgX191c2VyICopIGttc2ctPm1zZ19jb250cm9sOworCWludCBmZG1heCA9IChrbXNnLT5tc2dfY29udHJvbGxlbiAtIHNpemVvZihzdHJ1Y3QgY29tcGF0X2Ntc2doZHIpKSAvIHNpemVvZihpbnQpOworCWludCBmZG51bSA9IHNjbS0+ZnAtPmNvdW50OworCXN0cnVjdCBmaWxlICoqZnAgPSBzY20tPmZwLT5mcDsKKwlpbnQgX191c2VyICpjbWZwdHI7CisJaW50IGVyciA9IDAsIGk7CisKKwlpZiAoZmRudW0gPCBmZG1heCkKKwkJZmRtYXggPSBmZG51bTsKKworCWZvciAoaSA9IDAsIGNtZnB0ciA9IChpbnQgX191c2VyICopIENNU0dfQ09NUEFUX0RBVEEoY20pOyBpIDwgZmRtYXg7IGkrKywgY21mcHRyKyspIHsKKwkJaW50IG5ld19mZDsKKwkJZXJyID0gc2VjdXJ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gorICovCit2b2lkIGRldl9yZW1vdmVfcGFjayhzdHJ1Y3QgcGFja2V0X3R5cGUgKnB0KQoreworCV9fZGV2X3JlbW92ZV9wYWNrKHB0KTsKKwkKKwlzeW5jaHJvbml6ZV9uZXQoKTsKK30KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorCisJCSAgICAgIERldmljZSBCb290LXRpbWUgU2V0dGluZ3MgUm91dGluZXMKKworKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKworLyogQm9vdCB0aW1lIGNvbmZpZ3VyYXRpb24gdGFibGUgKi8KK3N0YXRpYyBzdHJ1Y3QgbmV0ZGV2X2Jvb3Rfc2V0dXAgZGV2X2Jvb3Rfc2V0dXBbTkVUREVWX0JPT1RfU0VUVVBfTUFYXTsKKworLyoqCisgKgluZXRkZXZfYm9vdF9zZXR1cF9hZGQJLSBhZGQgbmV3IHNldHVwIGVudHJ5CisgKglAbmFtZTogbmFtZSBvZiB0aGUgZGV2aWNlCisgKglAbWFwOiBjb25maWd1cmVkIHNldHRpbmdzIGZvciB0aGUgZGV2aWNlCisgKgorICoJQWRkcyBuZXcgc2V0dXAgZW50cnkgdG8gdGhlIGRldl9ib290X3NldHVwIGxpc3QuICBUaGUgZnVuY3Rpb24KKyAqCXJldHVybnMgMCBvbiBlcnJvciBhbmQgMSBvbiBzdWNjZXNzLiAgVGhpcyBpcyBhIGdlbmVyaWMgcm91dGluZSB0bworICoJYWxsIG5ldGRldmljZXMuCisgKi8KK3N0YXRpYyBpbnQgbmV0ZGV2X2Jvb3Rfc2V0dXBfYWRkKGNoYXIgKm5hbWUsIHN0cnVjdCBpZm1hcCAqbWFwKQoreworCXN0cnVjdCBuZXRkZXZfYm9vdF9zZXR1cCAqczsKKwlpbnQgaTsKKworCXMgPSBkZXZfYm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NldHVwKTsKKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKworCQkJICAgIERldmljZSBJbnRlcmZhY2UgU3Vicm91dGluZXMKKworKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKworLyoqCisgKglfX2Rldl9nZXRfYnlfbmFtZQktIGZpbmQgYSBkZXZpY2UgYnkgaXRzIG5hbWUKKyAqCUBuYW1lOiBuYW1lIHRvIGZpbmQKKyAqCisgKglGaW5kIGFuIGludGVyZmFjZSBieSBuYW1lLiBNdXN0IGJlIGNhbGxlZCB1bmRlciBSVE5MIHNlbWFwaG9yZQorICoJb3IgQGRldl9iYXNlX2xvY2suIElmIHRoZSBuYW1lIGlzIGZvdW5kIGEgcG9pbnRlciB0byB0aGUgZGV2aWNlCisgKglpcyByZXR1cm5lZC4gSWYgdGhlIG5hbWUgaXMgbm90IGZvdW5kIHRoZW4gJU5VTEwgaXMgcmV0dXJuZWQuIFRoZQorICoJcmVmZXJlbmNlIGNvdW50ZXJzIGFyZSBub3QgaW5jcmVtZW50ZWQgc28gdGhlIGNhbGxlciBtdXN0IGJlCisgKgljYXJlZnVsIHdpdGggbG9ja3MuCisgKi8KKworc3RydWN0IG5ldF9kZXZpY2UgKl9fZGV2X2dldF9ieV9uYW1lKGNvbnN0IGNoYXIgKm5hbWUpCit7CisJc3RydWN0IGhsaXN0X25vZGUgKnA7CisKKwlobGlzdF9mb3JfZWFjaChwLCBkZXZfbmFtZV9oYXNoKG5hbWUpKSB7CisJCXN0cnVjdCBuZXRfZGV2aWNlICpkZXYKKwkJCT0gaGxpc3RfZW50cnkocCwgc3RydWN0IG5ldF9kZXZpY2UsIG5hbWVfaGxpc3QpOworCQlpZiAoIXN0cm5jbXAoZGV2LT5uYW1lLCBuYW1lLCBJRk5BTVNJWikpCisJCQ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aWYgKG5ldGRldl9uaXQpCisJCQkJCWRldl9xdWV1ZV94bWl0X25pdChza2IsIGRldik7CisKKwkJCQlyYyA9IDA7CisJCQkJaWYgKCFkZXYtPmhhcmRfc3RhcnRfeG1pdChza2IsIGRldikpIHsKKwkJCQkJSEFSRF9UWF9VTkxPQ0soZGV2KTsKKwkJCQkJZ290byBvdXQ7CisJCQkJfQorCQkJfQorCQkJSEFSRF9UWF9VTkxPQ0soZGV2KTsKKwkJCWlmIChuZXRfcmF0ZWxpbWl0KCkpCisJCQkJcHJpbnRrKEtFUk5fQ1JJVCAiVmlydHVhbCBkZXZpY2UgJXMgYXNrcyB0byAiCisJCQkJICAgICAgICJxdWV1ZSBwYWNrZXQhXG4iLCBkZXYtPm5hbWUpOworCQl9IGVsc2UgeworCQkJLyogUmVjdXJzaW9uIGlzIGRldGVjdGVkISBJdCBpcyBwb3NzaWJsZSwKKwkJCSAqIHVuZm9ydHVuYXRlbHkgKi8KKwkJCWlmIChuZXRfcmF0ZWxpbWl0KCkpCisJCQkJcHJpbnRrKEtFUk5fQ1JJVCAiRGVhZCBsb29wIG9uIHZpcnR1YWwgZGV2aWNlICIKKwkJCQkgICAgICAgIiVzLCBmaXggaXQgdXJnZW50bHkhXG4iLCBkZXYtPm5hbWUpOworCQl9CisJfQorCisJcmMgPSAtRU5FVERPV047CisJbG9jYWxfYmhfZW5hYmxlKCk7CisKK291dF9rZnJlZV9za2I6CisJa2ZyZWVfc2tiKHNrYik7CisJcmV0dXJuIHJjOworb3V0OgorCWxvY2FsX2JoX2VuYWJsZSgpOworCXJldHVybiByYzsKK30KKworCisvKj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisJCQlSZWNlaXZlciByb3V0aW5lcworICA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PSovCisKK2ludCBuZXRkZXZfbWF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Kz0gKEEgPT0gZmVudHJ5LT5rKSA/IGZlbnRyeS0+anQgOiBmZW50cnktPmpmOworCQkJY29udGludWU7CisJCWNhc2UgQlBGX0pNUHxCUEZfSlNFVHxCUEZfSzoKKwkJCXBjICs9IChBICYgZmVudHJ5LT5rKSA/IGZlbnRyeS0+anQgOiBmZW50cnktPmpmOworCQkJY29udGludWU7CisJCWNhc2UgQlBGX0pNUHxCUEZfSkdUfEJQRl9YOgorCQkJcGMgKz0gKEEgPiBYKSA/IGZlbnRyeS0+anQgOiBmZW50cnktPmpmOworCQkJY29udGludWU7CisJCWNhc2UgQlBGX0pNUHxCUEZfSkdFfEJQRl9YOgorCQkJcGMgKz0gKEEgPj0gWCkgPyBmZW50cnktPmp0IDogZmVudHJ5LT5qZjsKKwkJCWNvbnRpbnVlOworCQljYXNlIEJQRl9KTVB8QlBGX0pFUXxCUEZfWDoKKwkJCXBjICs9IChBID09IFgpID8gZmVudHJ5LT5qdCA6IGZlbnRyeS0+amY7CisJCQljb250aW51ZTsKKwkJY2FzZSBCUEZfSk1QfEJQRl9KU0VUfEJQRl9YOgorCQkJcGMgKz0gKEEgJiBYKSA/IGZlbnRyeS0+anQgOiBmZW50cnktPmpmOworCQkJY29udGludWU7CisJCWNhc2UgQlBGX0xEfEJQRl9XfEJQRl9BQlM6CisJCQlrID0gZmVudHJ5LT5rOworIGxvYWRfdzoKKwkJCWlmIChrID49IDAgJiYgKHVuc2lnbmVkIGludCkoaytzaXplb2YodTMyKSkgPD0gbGVuKSB7CisJCQkJQSA9IG50b2hsKCoodTMyKikmZGF0YVtrXSk7CisJCQkJY29udGludWU7CisJCQl9CisJCQlpZiAoayA8IDApIHsKKwkJCQl1OCAqcHRyOworCisJCQkJaWYgKGsgPj0gU0tGX0FEX09GRikKKwkJCQkJYnJlYWs7CisJCQkJcHRyID0gbG9hZF9wb2ludGVyKHNrYiwgayk7CisJCQkJaWYgKHB0cikgeworCQkJCQlBID0gbnRvaGwoKih1MzIqKXB0cik7CisJ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SU1NOgorCQkJWCA9IGZlbnRyeS0+azsKKwkJCWNvbnRpbnVlOworCQljYXNlIEJQRl9MRHxCUEZfTUVNOgorCQkJQSA9IG1lbVtmZW50cnktPmtdOworCQkJY29udGludWU7CisJCWNhc2UgQlBGX0xEWHxCUEZfTUVNOgorCQkJWCA9IG1lbVtmZW50cnktPmtdOworCQkJY29udGludWU7CisJCWNhc2UgQlBGX01JU0N8QlBGX1RBWDoKKwkJCVggPSBBOworCQkJY29udGludWU7CisJCWNhc2UgQlBGX01JU0N8QlBGX1RYQToKKwkJCUEgPSBYOworCQkJY29udGludWU7CisJCWNhc2UgQlBGX1JFVHxCUEZfSzoKKwkJCXJldHVybiAoKHVuc2lnbmVkIGludClmZW50cnktPmspOworCQljYXNlIEJQRl9SRVR8QlBGX0E6CisJCQlyZXR1cm4gKCh1bnNpZ25lZCBpbnQpQSk7CisJCWNhc2UgQlBGX1NUOgorCQkJbWVtW2ZlbnRyeS0+a10gPSBBOworCQkJY29udGludWU7CisJCWNhc2UgQlBGX1NUWDoKKwkJCW1lbVtmZW50cnktPmtdID0gWDsKKwkJCWNvbnRpbnVlOworCQlkZWZhdWx0OgorCQkJLyogSW52YWxpZCBpbnN0cnVjdGlvbiBjb3VudHMgYXMgUkVUICovCisJCQlyZXR1cm4gMDsKKwkJfQorCisJCS8qCisJCSAqIEhhbmRsZSBhbmNpbGxhcnkgZGF0YSwgd2hpY2ggYXJlIGltcG9zc2libGUKKwkJICogKG9yIHZlcnkgZGlmZmljdWx0KSB0byBnZXQgcGFyc2luZyBwYWNrZXQgY29udGVudHMuCisJCSAqLworCQlzd2l0Y2ggKGstU0tGX0FEX09GRikgeworCQljYXNlIFNLRl9BRF9QUk9UT0NPTDoKKwkJCUEgPSBodG9ucyhza2ItPnByb3RvY29sKTsKKwkJCWNvbnRpbnVlOworCQljYXNlIFNLRl9BRF9QS1RUWVBFOgorCQkJQSA9IHNrYi0+cGt0X3R5cGU7CisJCQljb250aW51ZTsKKwkJY2FzZS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lZCA9IG5vdyAtIG4tPmNvbmZpcm1lZDsKKwljaS5uZG1fdXBkYXRlZAkgPSBub3cgLSBuLT51cGRhdGVkOworCWNpLm5kbV9yZWZjbnQJID0gYXRvbWljX3JlYWQoJm4tPnJlZmNudCkgLSAxOworCXByb2JlcyA9IGF0b21pY19yZWFkKCZuLT5wcm9iZXMpOworCXJlYWRfdW5sb2NrX2JoKCZuLT5sb2NrKTsKKwlsb2NrZWQJCSA9IDA7CisJUlRBX1BVVChza2IsIE5EQV9DQUNIRUlORk8sIHNpemVvZihjaSksICZjaSk7CisJUlRBX1BVVChza2IsIE5EQV9QUk9CRVMsIHNpemVvZihwcm9iZXMpLCAmcHJvYmVzKTsKKwlubGgtPm5sbXNnX2xlbgkgPSBza2ItPnRhaWwgLSBiOworCXJldHVybiBza2ItPmxlbjsKKworbmxtc2dfZmFpbHVyZToKK3J0YXR0cl9mYWlsdXJlOgorCWlmIChsb2NrZWQpCisJCXJlYWRfdW5sb2NrX2JoKCZuLT5sb2NrKTsKKwlza2JfdHJpbShza2IsIGIgLSBza2ItPmRhdGEpOworCXJldHVybiAtMTsKK30KKworCitzdGF0aWMgaW50IG5laWdoX2R1bXBfdGFibGUoc3RydWN0IG5laWdoX3RhYmxlICp0YmwsIHN0cnVjdCBza19idWZmICpza2IsCisJCQkgICAgc3RydWN0IG5ldGxpbmtfY2FsbGJhY2sgKmNiKQoreworCXN0cnVjdCBuZWlnaGJvdXIgKm47CisJaW50IHJjLCBoLCBzX2ggPSBjYi0+YXJnc1sxXTsKKwlpbnQgaWR4LCBzX2lkeCA9IGlkeCA9IGNiLT5hcmdzWzJdOworCisJZm9yIChoID0gMDsgaCA8PSB0YmwtPmhhc2hfbWFzazsgaCsrKSB7CisJCWlmIChoIDwgc19oKQorCQkJY29udGludWU7CisJCWlmIChoID4gc19oKQorCQkJc19pZHggPSAwOworCQlyZWFkX2xvY2tfYmgoJnRibC0+bG9jayk7CisJCWZvciAobiA9IHRibC0+aGFzaF9idWNrZX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2UgJiYgKGNvdW50ID09IDEwMDAwMDApKSB7CisJCQlwcmludGsoIm91dCBvZiBuZXRwb2xsIHNrYnMhXG4iKTsKKwkJCW9uY2UgPSAwOworCQl9CisJCW5ldHBvbGxfcG9sbChucCk7CisJCWdvdG8gcmVwZWF0OworCX0KKworCWF0b21pY19zZXQoJnNrYi0+dXNlcnMsIDEpOworCXNrYl9yZXNlcnZlKHNrYiwgcmVzZXJ2ZSk7CisJcmV0dXJuIHNrYjsKK30KKworc3RhdGljIHZvaWQgbmV0cG9sbF9zZW5kX3NrYihzdHJ1Y3QgbmV0cG9sbCAqbnAsIHN0cnVjdCBza19idWZmICpza2IpCit7CisJaW50IHN0YXR1czsKKworcmVwZWF0OgorCWlmKCFucCB8fCAhbnAtPmRldiB8fCAhbmV0aWZfcnVubmluZyhucC0+ZGV2KSkgeworCQlfX2tmcmVlX3NrYihza2IpOworCQlyZXR1cm47CisJfQorCisJLyogYXZvaWQgcmVjdXJzaW9uICovCisJaWYobnAtPnBvbGxfb3duZXIgPT0gc21wX3Byb2Nlc3Nvcl9pZCgpIHx8CisJICAgbnAtPmRldi0+eG1pdF9sb2NrX293bmVyID09IHNtcF9wcm9jZXNzb3JfaWQoKSkgeworCQlpZiAobnAtPmRyb3ApCisJCQlucC0+ZHJvcChza2IpOworCQllbHNlCisJCQlfX2tmcmVlX3NrYihza2IpOworCQlyZXR1cm47CisJfQorCisJc3Bpbl9sb2NrKCZucC0+ZGV2LT54bWl0X2xvY2spOworCW5wLT5kZXYtPnhtaXRfbG9ja19vd25lciA9IHNtcF9wcm9jZXNzb3JfaWQoKTsKKworCS8qCisJICogbmV0d29yayBkcml2ZXJzIGRvIG5vdCBleHBlY3QgdG8gYmUgY2FsbGVkIGlmIHRoZSBxdWV1ZSBpcworCSAqIHN0b3BwZWQuCisJICovCisJaWYgKG5ldGlmX3F1ZXVlX3N0b3BwZWQobnAtPmRldikpIHsKKwkJbnAtPmRldi0+eG1pdF9sb2NrX293bmVyID0gLTE7C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AgICAKKyAgICAgICAgLyogSWYgbWluICE9IG1heCwgdGhlbiB3ZSB3aWxsIGVpdGhlciBkbyBhIGxpbmVhciBpdGVyYXRpb24sIG9yCisgICAgICAgICAqIHdlIHdpbGwgZG8gYSByYW5kb20gc2VsZWN0aW9uIGZyb20gd2l0aGluIHRoZSByYW5nZS4KKyAgICAgICAgICovCisgICAgICAgIF9fdTMyIGZsYWdzOyAgICAgCisKKyAgICAgICAgaW50IG1pbl9wa3Rfc2l6ZTsgICAgLyogPSBFVEhfWkxFTjsgKi8KKyAgICAgICAgaW50IG1heF9wa3Rfc2l6ZTsgICAgLyogPSBFVEhfWkxFTjsgKi8KKyAgICAgICAgaW50IG5mcmFnczsKKyAgICAgICAgX191MzIgZGVsYXlfdXM7ICAgIC8qIERlZmF1bHQgZGVsYXkgKi8KKyAgICAgICAgX191MzIgZGVsYXlfbnM7CisgICAgICAgIF9fdTY0IGNvdW50OyAgLyogRGVmYXVsdCBObyBwYWNrZXRzIHRvIHNlbmQgKi8KKyAgICAgICAgX191NjQgc29mYXI7ICAvKiBIb3cgbWFueSBwa3RzIHdlJ3ZlIHNlbnQgc28gZmFyICovCisgICAgICAgIF9fdTY0IHR4X2J5dGVzOyAvKiBIb3cgbWFueSBieXRlcyB3ZSd2ZSB0cmFuc21pdHRlZCAqLworICAgICAgICBfX3U2NCBlcnJvcnM7ICAgIC8qIEVycm9ycyB3aGVuIHRyeWluZyB0byB0cmFuc21pdCwgcGt0cyB3aWxsIGJlIHJlLXNlbnQgKi8KKworICAgICAgICAvKiBydW50aW1lIGNvdW50ZXJzIHJlbGF0aW5nIHRvIGNsb25lX3NrYiAqLworICAgICAgICBfX3U2NCBuZXh0X3R4X3VzOyAgICAgICAgICAvKiB0aW1lc3RhbXAgb2Ygd2hlbiB0byB0eCBuZXh0ICovCisgICAgICAgIF9fdTMyIG5leHRfdHhfbnM7CisgICAgICAgIAorICAgICAgICBfX3U2NCBhbGxvY2F0ZWRfc2ticzsKKyAgICAgICAgX191MzIgY2xvbmVfY291bnQ7CisJaW50IGxhc3Rfb2s7ICAgICAgICAgICAvKiBXYXMgbGFzdCBza2Igc2VudD8gCisJICAgICAgICAgICAgICAgICAgICAgICAgKiBPciBhIGZhaWxlZCB0cmFuc21pdCBvZiBzb21lIHNvcnQ/ICBUaGlzIHdpbGwga2VlcAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqIHNlcXVlbmNlIG51bWJlcnMgaW4gb3JkZXIsIGZvciBleGFtcGxlLgorCQkJCSovCisgICAgICAgIF9fdTY0IHN0YXJ0ZWRfYXQ7IC8qIG1pY3JvLXNlY29uZHMgKi8KKyAgICAgICAgX191NjQgc3RvcHBlZF9hdDsgLyogbWljcm8tc2Vjb25kcyAqLworICAgICAgICBfX3U2NCBpZGxlX2FjYzsgLyogbWljcm8tc2Vjb25kcyAqLworICAgICAgICBfX3UzMiBzZXFfbnVtOworICAgICAgICAKKyAgICAgICAgaW50IGNsb25lX3NrYjsgLyogVXNlIG11bHRpcGxlIFNLQnMgZHVyaW5nIHBhY2tldCBnZW4uICBJZiB0aGlzIG51bWJlcgorICAgICAgICAgICAgICAgICAgICAgICAgICAqIGlzIGdyZWF0ZXIgdGhhbiAxLCB0aGVuIHRoYXQgbWFueSBjb3BwaWVzIG9mIHRoZSBzYW1lCisgICAgICAgICAgICAgICAgICAgICAgICAgICogcGFja2V0IHdpbGwgYmUgc2VudCBiZWZvcmUgYSBuZXcgcGFja2V0IGlzIGFsbG9jYXRlZC4KKyAgICAgICAgICAgICAgICAgICAgICAgICAgKiBGb3IgaW5zdGFuY2UsIGlmIHlvdSB3YW50IHRvIHNlbmQgMTAyNCBpZGVudGljYWwgcGFja2V0cworICAgICAgICAgICAgICAgICAgICAgICAgICAqIGJlZm9yZSBjcmVhdGluZyBhIG5ldyBwYWNrZXQsIHNldCBjbG9uZV9za2IgdG8gMTAyNC4KKyAgICAgICAgICAgICAgICAgICAgICAgICAgKi8KKyAgICAgICAgCisgICAgICAgIGNoYXI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IGV4Y2x1c2l2ZSwgZGVzdCBJUCBhZGRyZXNzICovCisKKyAgICAgICAgX191MTYgdWRwX3NyY19taW47IC8qIGluY2x1c2l2ZSwgc291cmNlIFVEUCBwb3J0ICovCisgICAgICAgIF9fdTE2IHVkcF9zcmNfbWF4OyAvKiBleGNsdXNpdmUsIHNvdXJjZSBVRFAgcG9ydCAqLworICAgICAgICBfX3UxNiB1ZHBfZHN0X21pbjsgLyogaW5jbHVzaXZlLCBkZXN0IFVEUCBwb3J0ICovCisgICAgICAgIF9fdTE2IHVkcF9kc3RfbWF4OyAvKiBleGNsdXNpdmUsIGRlc3QgVURQIHBvcnQgKi8KKworICAgICAgICBfX3UzMiBzcmNfbWFjX2NvdW50OyAvKiBIb3cgbWFueSBNQUNzIHRvIGl0ZXJhdGUgdGhyb3VnaCAqLworICAgICAgICBfX3UzMiBkc3RfbWFjX2NvdW50OyAvKiBIb3cgbWFueSBNQUNzIHRvIGl0ZXJhdGUgdGhyb3VnaCAqLworICAgICAgICAKKyAgICAgICAgdW5zaWduZWQgY2hhciBkc3RfbWFjWzZdOworICAgICAgICB1bnNpZ25lZCBjaGFyIHNyY19tYWNbNl07CisgICAgICAgIAorICAgICAgICBfX3UzMiBjdXJfZHN0X21hY19vZmZzZXQ7CisgICAgICAgIF9fdTMyIGN1cl9zcmNfbWFjX29mZnNldDsKKyAgICAgICAgX191MzIgY3VyX3NhZGRyOworICAgICAgICBfX3UzMiBjdXJfZGFkZHI7CisgICAgICAgIF9fdTE2IGN1cl91ZHBfZHN0OworICAgICAgICBfX3UxNiBjdXJfdWRwX3NyYzsKKyAgICAgICAgX191MzIgY3VyX3BrdF9zaXplOworICAgICAgICAKKyAgICAgICAgX191OCBoaFsxNF07CisgICAgICAgIC8qID0geyAKKyAgICAgICAgICAgMHgwMCwgMHg4MCwgMHhDOCwgMHg3OSwgMHhCMywgMHhDQiwgCisgICAgICAgICAgIAorICAgICAgICAgICBXZSBmaWxsIGluIFNSQyBhZGRyZXNzIGxhdGVyCisgICAgICAgICAgIDB4MDAsIDB4MDAsIDB4MDAsIDB4MDAsIDB4MDAsIDB4MDAsCisgICAgICAgICAgIDB4MDgsIDB4MDAKKyAgICAgICAgICAgfTsKKyAgICAgICAgKi8KKyAgICAgICAgX191MTYgcGFkOyAvKiBwYWQgb3V0IHRoZSBoaCBzdHJ1Y3QgdG8gYW4gZXZlbiAxNiBieXRlcyAqLworCisgICAgICAgIHN0cnVjdCBza19idWZmKiBza2I7IC8qIHNrYiB3ZSBhcmUgdG8gdHJhbnNtaXQgbmV4dCwgbWFpbmx5IHVzZWQgZm9yIHdoZW4gd2UKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICogYXJlIHRyYW5zbWl0dGluZyB0aGUgc2FtZSBvbmUgbXVsdGlwbGUgdGltZXMKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICovCisgICAgICAgIHN0cnVjdCBuZXRfZGV2aWNlKiBvZGV2OyAvKiBUaGUgb3V0LWdvaW5nIGRldmljZS4gIE5vdGUgdGhhdCB0aGUgZGV2aWNlIHNob3VsZAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICogaGF2ZSBpdCdzIHBnX2luZm8gcG9pbnRlciBwb2ludGluZyBiYWNrIHRvIHRoaXMKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqIGRldmljZS4gIFRoaXMgd2lsbCBiZSBzZXQgd2hlbiB0aGUgdXNlciBzcGVjaWZpZXMKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqIHRoZSBvdXQtZ29pbmcgZGV2aWNlIG5hbWUgKG5vdCB3aGVuIHRoZSBpbmplY3QgaXMKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqIHN0YXJ0ZWQgYXMgaXQgdXNlZCB0byBkby4pCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKi8KKwlzdHJ1Y3QgZmxvd19zdGF0ZSAqZmxvd3M7CisJdW5zaWduZWQgY2Zsb3dzOyAgICAgICAgIC8qIENvbmN1cnJlbnQgZmxvd3MgKGNvbmZpZykgKi8KKwl1bnNpZ25lZCBsZmxvdzsgICAgICAgICAgLyogRmxvdyBsZW5ndGggIChjb25maWcpICovCisJdW5zaWduZWQgbmZsb3dzOyAgICAgICAgIC8qIGFjY3VtdWxhdGVkIGZsb3dzIChzdGF0cykgKi8KK307CisKK3N0cnVjdCBwa3RnZW5faGRyIHsKKyAgICAgICAgX191MzIgcGdoX21hZ2ljOworICAgICAgICBfX3UzMiBzZXFfbnVtOworCV9fdTMyIHR2X3NlYzsKKwlfX3UzMiB0dl91c2VjOworfTsKKworc3RydWN0IHBrdGdlbl90aHJlYWQgeworICAgICAgICBzcGlubG9ja190IGlmX2xvY2s7CisgICAgICAgIHN0cnVjdCBwa3RnZW5fZGV2ICppZl9saXN0OyAgICAgICAgICAgLyogQWxsIGRldmljZSBoZXJlICovCisgICAgICAgIHN0cnVjdCBwa3RnZW5fdGhyZWFkKiBuZXh0OworICAgICAgICBjaGFyIG5hbWVbMzJdOworICAgICAgICBjaGFyIGZuYW1lWzEyOF07IC8qIG5hbWUgb2YgcHJvYyBmaWxlICovCisgICAgICAgIHN0cnVjdCBwcm9jX2Rpcl9lbnRyeSAqcHJvY19lbnQ7CisgICAgICAgIGNoYXIgcmVzdWx0WzUxMl07CisgICAgICAgIHUzMiBtYXhfYmVmb3JlX3NvZnRpcnE7IC8qIFdlJ2xsIGNhbGwgZG9fc29mdGlycSB0byBwcmV2ZW50IHN0YXJ2YXRpb24uICovCisgICAgICAgIAorCS8qIEZpZWxkIGZvciB0aHJlYWQgdG8gcmVjZWl2ZSAicG9zdGVkIiBldmVudHMgdGVybWluYXRlLCBzdG9wIGlmcyBldGMuKi8KKworICAgICAgICB1MzIgY29udHJvbDsKKwlpbnQgcGlkOworCWludCBjcHU7CisKKyAgICAgICAgd2FpdF9xdWV1ZV9oZWFkX3QgcXVldWU7Cit9OworCisjZGVmaW5lIFJFTU9WRSAxCisjZGVmaW5lIEZJTkQgICAwCisKKy8qICBUaGlzIGNvZGUgd29ya3MgYXJvdW5kIHRoZSBmYWN0IHRoYXQgZG9fZGl2IGNhbm5vdCBoYW5kbGUgdHdvIDY0LWJpdAorICAgIG51bWJlcnMsIGFuZCByZWd1bGFyIDY0LWJpdCBkaXZpc2lvbiBkb2Vzbid0IHdvcmsgb24geDg2IGtlcm5lbHMuCisgICAgLS1CZW4KKyovCisKKyNkZWZpbmUgUEdfRElWIDAKKworLyogVGhpcyB3YXMgZW1haWxlZCB0byBMTUtMIGJ5OiBDaHJpcyBDYXB1dG8gPGNjYXB1dG9AYWx0Lm5ldD4KKyAqIEZ1bmN0aW9uIGNvcGllZC9hZGFwdGVkL29wdGltaXplZCBmcm9tOgorICoKKyAqICBuZW1lc2lzLnNvdXJjZWZvcmdlLm5ldC9icm93c2UvbGliL3N0YXRpYy9pbnRtYXRoL2l4ODYvaW50bWF0aC5jLmh0bWwKKyAqCisgKiBDb3B5cmlnaHQgMTk5NCwgVW5pdmVyc2l0eSBvZiBDYW1icmlkZ2UgQ29tcHV0ZXIgTGFib3JhdG9yeQorICogQWxsIFJpZ2h0cyBSZXNlcnZlZC4KKyAqCisgKi8KK2lubGluZSBzdGF0aWMgczY0IGRpdnJlbWRpMyhzNjQgeCwgczY0IHksIGludCB0eXBlKSAKK3sKKyAgICAgICAgdTY0IGEgPSAoeCA8IDApID8gLXggOiB4OworICAgICAgICB1NjQgYiA9ICh5IDwgMCkgPyAteSA6IHk7CisgICAgICAgIHU2NCByZXMgPSAwLCBkID0gMTsKKworICAgICAgICBpZiAoYiA+IDApIHsKKyAgICAgICAgICAgICAgICB3aGlsZSAoYiA8IGEpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIGIgPDw9IDE7CisgICAgICAgICAgICAgICAgICAgICAgICBkIDw8PSAxOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgfQorICAgICAgICAKKyAgICAgICAgZG8geworICAgICAgICAgICAgICAgIGlmICggYSA+PSBiICkgeworICAgICAgICAgICAgICAgICAgICAgICAgYSAtPSBiOworICAgICAgICAgICAgICAgICAgICAgICAgcmVzICs9IGQ7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIGIgPj49IDE7CisgICAgICAgICAgICAgICAgZCA+Pj0gMTsKKyAgICAgICAgfQorICAgICAgICB3aGlsZSAoZCk7CisKKyAgICAgICAgaWYgKFBHX0RJViA9PSB0eXBlKSB7CisgICAgICAgICAgICAgICAgcmV0dXJuICgoKHggXiB5KSAmICgxbGw8PDYzKSkgPT0gMCkgPyByZXMgOiAtKHM2NClyZXM7CisgICAgICAgIH0KKyAgICAgICAgZWxzZSB7CisgICAgICAgICAgICAgICAgcmV0dXJuICgoeCAmICgxbGw8PDYzKSkgPT0gMCkgPyBhIDogLShzNjQpYTsKKyAgICAgICAgfQorfQorCisvKiBFbmQgb2YgaGFja3MgdG8gZGVhbCB3aXRoIDY0LWJpdCBtYXRoIG9uIHg4NiAqLworCisvKiogQ29udmVydCB0byBtaWxpc2Vjb25kcyAqLworc3RhdGljIGlubGluZSBfX3U2NCB0dl90b19tcyhjb25zdCBzdHJ1Y3QgdGltZXZhbCogdHYpIAoreworICAgICAgICBfX3U2NCBtcyA9IHR2LT50dl91c2VjIC8gMTAwMDsKKyAgICAgICAgbXMgKz0gKF9fdTY0KXR2LT50dl9zZWMgKiAoX191NjQpMTAwMDsKKyAgICAgICAgcmV0dXJuIG1zOworfQorCisKKy8qKiBDb252ZXJ0IHRvIG1pY3JvLXNlY29uZHMgKi8KK3N0YXRpYyBpbmxpbmUgX191NjQgdHZfdG9fdXMoY29uc3Qgc3RydWN0IHRpbWV2YWwqIHR2KSAKK3sKKyAgICAgICAgX191NjQgdXMgPSB0di0+dHZfdXNlYzsKKyAgICAgICAgdXMgKz0gKF9fdTY0KXR2LT50dl9zZWMgKiAoX191NjQpMTAwMDAwMDsKKyAgICAgICAgcmV0dXJuIHVzOworfQorCitzdGF0aWMgaW5saW5lIF9fd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CisJcmV0dXJuIGxlbjsKK30KKworc3RhdGljIHNzaXplX3QgcHJvY19wZ2N0cmxfd3JpdGUoc3RydWN0IGZpbGUqIGZpbGUsY29uc3QgY2hhciBfX3VzZXIgKiBidWYsCisJCQkJIHNpemVfdCBjb3VudCwgbG9mZl90ICpwcG9zKQoreworCWNoYXIgKmRhdGEgPSBOVUxMOworCWludCBlcnIgPSAwOworCisgICAgICAgIGlmICghY2FwYWJsZShDQVBfTkVUX0FETUlOKSl7CisgICAgICAgICAgICAgICAgZXJyID0gLUVQRVJNOworCQlnb3RvIG91dDsKKyAgICAgICAgfQorCisJZGF0YSA9ICh2b2lkKil2bWFsbG9jICgodW5zaWduZWQgaW50KWNvdW50KTsKKworCWlmKCFkYXRhKSB7CisJCWVyciA9IC1FTk9NRU07CisJCWdvdG8gb3V0OworCX0KKwlpZiAoY29weV9mcm9tX3VzZXIoZGF0YSwgYnVmLCBjb3VudCkpIHsKKwkJZXJyID0tRUZBVUxUOworCQlnb3RvIG91dF9mcmVlOworCX0gIAorCWRhdGFbY291bnQtMV0gPSAwOyAvKiBNYWtlIHN0cmluZyAqLworCisJaWYgKCFzdHJjbXAoZGF0YSwgInN0b3AiKSkgCisJCXBrdGdlbl9zdG9wX2FsbF90aHJlYWRzX2lmcygpOworCisgICAgICAgIGVsc2UgaWYgKCFzdHJjbXAoZGF0YSwgInN0YXJ0IikpIAorCQlwa3RnZW5fcnVuX2FsbF90aHJlYWRzKCk7CisKKwllbHNlIAorCQlwcmludGsoInBrdGdlbjogVW5rbm93biBjb21tYW5kOiAlc1xuIiwgZGF0YSk7CisKKwllcnIgPSBjb3VudDsKKworIG91dF9mcmVlOgorCXZmcmVlIChkYXRhKTsKKyBvdXQ6CisgICAgICAgIHJldHVybiBlcnI7Cit9CisKK3N0YXRpYyBpbnQgcHJvY19pZl9yZWFkKGNoYXIgKmJ1ZiAsIGNoYXIgKipzdGFydCwgb2ZmX3Qgb2Zmc2V0LAorICAgICAgICAgICAgICAgICAgICA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ICAiKTsKKworICAgICAgICBpZiAocGt0X2Rldi0+ZmxhZ3MgJiAgRl9JUFNSQ19STkQpIAorICAgICAgICAgICAgICAgIHAgKz0gc3ByaW50ZihwLCAiSVBTUkNfUk5EICAiKTsKKworICAgICAgICBpZiAocGt0X2Rldi0+ZmxhZ3MgJiBGX0lQRFNUX1JORCkgCisgICAgICAgICAgICAgICAgcCArPSBzcHJpbnRmKHAsICJJUERTVF9STkQgICIpOworICAgICAgICAKKyAgICAgICAgaWYgKHBrdF9kZXYtPmZsYWdzICYgRl9UWFNJWkVfUk5EKSAKKyAgICAgICAgICAgICAgICBwICs9IHNwcmludGYocCwgIlRYU0laRV9STkQgICIpOworICAgICAgICAKKyAgICAgICAgaWYgKHBrdF9kZXYtPmZsYWdzICYgRl9VRFBTUkNfUk5EKSAKKyAgICAgICAgICAgICAgICBwICs9IHNwcmludGYocCwgIlVEUFNSQ19STkQgICIpOworICAgICAgICAKKyAgICAgICAgaWYgKHBrdF9kZXYtPmZsYWdzICYgRl9VRFBEU1RfUk5EKSAKKyAgICAgICAgICAgICAgICBwICs9IHNwcmludGYocCwgIlVEUERTVF9STkQgICIpOworICAgICAgICAKKyAgICAgICAgaWYgKHBrdF9kZXYtPmZsYWdzICYgRl9NQUNTUkNfUk5EKSAKKyAgICAgICAgICAgICAgICBwICs9IHNwcmludGYocCwgIk1BQ1NSQ19STkQgICIpOworICAgICAgICAKKyAgICAgICAgaWYgKHBrdF9kZXYtPmZsYWdzICYgRl9NQUNEU1RfUk5EKSAKKyAgICAgICAgICAgICAgICBwICs9IHNwcmludGYocCwgIk1BQ0RTVF9STkQgICIpOworCisgICAgICAgIAorICAgICAgICBwICs9IHNwcmludGYocCwgIlxuIik7CisgICAgICAgIAorICAgICAgICBzYSA9IHBrdF9kZXYtPnN0YXJ0ZWRfYXQ7CisgICAgICAgIHN0b3BwZWQgPSBwa3RfZGV2LT5zdG9wcGVkX2F0OworICAgICAgICBpZiAocGt0X2Rldi0+cnVubmluZykgCis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XNcbiIsIGIyLCBiMSk7CisJfSAKKwllbHNlIAorCQlwICs9IHNwcmludGYocCwgIiAgICAgY3VyX3NhZGRyOiAweCV4ICBjdXJfZGFkZHI6IDB4JXhcbiIsCisgICAgICAgICAgICAgICAgICAgICBwa3RfZGV2LT5jdXJfc2FkZHIsIHBrdF9kZXYtPmN1cl9kYWRkcik7CisKKworCXAgKz0gc3ByaW50ZihwLCAiICAgICBjdXJfdWRwX2RzdDogJWQgIGN1cl91ZHBfc3JjOiAlZFxuIiwKKyAgICAgICAgICAgICAgICAgICAgIHBrdF9kZXYtPmN1cl91ZHBfZHN0LCBwa3RfZGV2LT5jdXJfdWRwX3NyYyk7CisKKwlwICs9IHNwcmludGYocCwgIiAgICAgZmxvd3M6ICV1XG4iLCBwa3RfZGV2LT5uZmxvd3MpOworCisJaWYgKHBrdF9kZXYtPnJlc3VsdFswXSkKKwkJcCArPSBzcHJpbnRmKHAsICJSZXN1bHQ6ICVzXG4iLCBwa3RfZGV2LT5yZXN1bHQpOworCWVsc2UKKwkJcCArPSBzcHJpbnRmKHAsICJSZXN1bHQ6IElkbGVcbiIpOworCSplb2YgPSAxOworCisJcmV0dXJuIHAgLSBidWY7Cit9CisKKworc3RhdGljIGludCBjb3VudF90cmFpbF9jaGFycyhjb25zdCBjaGFyIF9fdXNlciAqdXNlcl9idWZmZXIsIHVuc2lnbmVkIGludCBtYXhsZW4pCit7CisJaW50IGk7CisKKwlmb3IgKGkgPSAwOyBpIDwgbWF4bGVuOyBpKyspIHsKKyAgICAgICAgICAgICAgICBjaGFyIGM7CisgICAgICAgICAgICAgICAgaWYgKGdldF91c2VyKGMsICZ1c2VyX2J1ZmZlcltpXSkpCisgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gLUVGQVVMVDsKKyAgICAgICAgICAgICAgICBzd2l0Y2ggKGMpIHsKKwkJY2FzZSAnXCInOgorCQljYXNlICdcbic6CisJCWNhc2UgJ1xyJzoKKwkJY2FzZSAnXHQnOgorCQljYXNlICcgJzoKKwkJY2FzZSAnPSc6CisJCQlicmVhazsKKwkJZGVmYXVsdDoKKwkJCWdvdG8gZG9uZTsKKwkJfTsKKwl9Citkb25lOgorCXJldHVybiBpOworfQorCitzdGF0aWMgdW5zaWduZWQgbG9uZyBudW1fYXJnKGNvbnN0IGNoYXIgX191c2VyICp1c2VyX2J1ZmZlciwgdW5zaWduZWQgbG9uZyBtYXhsZW4sIAorCQkJICAgICB1bnNpZ25lZCBsb25nICpudW0pCit7CisJaW50IGkgPSAwOworCSpudW0gPSAwOworICAKKwlmb3IoOyBpIDwgbWF4bGVuOyBpKyspIHsKKyAgICAgICAgICAgICAgICBjaGFyIGM7CisgICAgICAgICAgICAgICAgaWYgKGdldF91c2VyKGMsICZ1c2VyX2J1ZmZlcltpXSkpCisgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gLUVGQVVMVDsKKyAgICAgICAgICAgICAgICBpZiAoKGMgPj0gJzAnKSAmJiAoYyA8PSAnOScpKSB7CisJCQkqbnVtICo9IDEwOworCQkJKm51bSArPSBjIC0nMCc7CisJCX0gZWxzZQorCQkJYnJlYWs7CisJfQorCXJldHVybiBpOworfQorCitzdGF0aWMgaW50IHN0cm5fbGVuKGNvbnN0IGNoYXIgX191c2VyICp1c2VyX2J1ZmZlciwgdW5zaWduZWQgaW50IG1heGxlbikKK3sKKwlpbnQgaSA9IDA7CisKKwlmb3IoOyBpIDwgbWF4bGVuOyBpKyspIHsKKyAgICAgICAgICAgICAgICBjaGFyIGM7CisgICAgICAgICAgICAgICAgaWYgKGdldF91c2VyKGMsICZ1c2VyX2J1ZmZlcltpXSkpCisgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gLUVGQVVMVDsKKyAgICAgICAgICAgICAgICBzd2l0Y2ggKGMpIHsKKwkJY2FzZSAnXCInOgorCQljYXNlICdcbic6CisJCWNhc2UgJ1xyJzoKKwkJY2FzZSAnXHQnOgorCQljYXNlICcgJzoKKwkJCWdvdG8gZG9uZV9zdHI7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hbHVlOworICAgICAgICAgICAgICAgICAgICAgICAgcGt0X2Rldi0+Y3VyX3BrdF9zaXplID0gdmFsdWU7CisgICAgICAgICAgICAgICAgfQorCQlzcHJpbnRmKHBnX3Jlc3VsdCwgIk9LOiBtaW5fcGt0X3NpemU9JXUiLCBwa3RfZGV2LT5taW5fcGt0X3NpemUpOworCQlyZXR1cm4gY291bnQ7CisJfQorCisgICAgICAgIGlmICghc3RyY21wKG5hbWUsICJtYXhfcGt0X3NpemUiKSkgeworCQlsZW4gPSBudW1fYXJnKCZ1c2VyX2J1ZmZlcltpXSwgMTAsICZ2YWx1ZSk7CisgICAgICAgICAgICAgICAgaWYgKGxlbiA8IDApIHsgcmV0dXJuIGxlbjsgfQorCQlpICs9IGxlbjsKKwkJaWYgKHZhbHVlIDwgMTQrMjArOCkKKwkJCXZhbHVlID0gMTQrMjArODsKKyAgICAgICAgICAgICAgICBpZiAodmFsdWUgIT0gcGt0X2Rldi0+bWF4X3BrdF9zaXplKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBwa3RfZGV2LT5tYXhfcGt0X3NpemUgPSB2YWx1ZTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHBrdF9kZXYtPmN1cl9wa3Rfc2l6ZSA9IHZhbHVlOworICAgICAgICAgICAgICAgIH0KKwkJc3ByaW50ZihwZ19yZXN1bHQsICJPSzogbWF4X3BrdF9zaXplPSV1IiwgcGt0X2Rldi0+bWF4X3BrdF9zaXplKTsKKwkJcmV0dXJuIGNvdW50OworCX0KKworICAgICAgICAvKiBTaG9ydGN1dCBmb3IgbWluID0gbWF4ICovCisKKwlpZiAoIXN0cmNtcChuYW1lLCAicGt0X3NpemUiKSkgeworCQlsZW4gPSBudW1fYXJnKCZ1c2VyX2J1ZmZlcltpXSwgMTAsICZ2YWx1ZSk7CisgICAgICAgICAgICAgICAgaWYgKGxlbiA8IDApIHsgcmV0dXJuIGxlbjsgfQorCQlpICs9IGxlbjsKKwkJaWYgKHZhbHVlIDwgMTQrMjArOCkKKwkJCXZhbHVlID0gMTQrMjArODsKKyAgICAgICAgICAgICAgICBpZiAodmFsdWUgIT0gcGt0X2Rldi0+bWluX3BrdF9zaXplKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBwa3RfZGV2LT5taW5fcGt0X3NpemUgPSB2YWx1ZTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHBrdF9kZXYtPm1heF9wa3Rfc2l6ZSA9IHZhbHVlOworICAgICAgICAgICAgICAgICAgICAgICAgcGt0X2Rldi0+Y3VyX3BrdF9zaXplID0gdmFsdWU7CisgICAgICAgICAgICAgICAgfQorCQlzcHJpbnRmKHBnX3Jlc3VsdCwgIk9LOiBwa3Rfc2l6ZT0ldSIsIHBrdF9kZXYtPm1pbl9wa3Rfc2l6ZSk7CisJCXJldHVybiBjb3VudDsKKwl9CisKKyAgICAgICAgaWYgKCFzdHJjbXAobmFtZSwgImRlYnVnIikpIHsKKwkJbGVuID0gbnVtX2FyZygmdXNlcl9idWZmZXJbaV0sIDEwLCAmdmFsdWUpOworICAgICAgICAgICAgICAgIGlmIChsZW4gPCAwKSB7IHJldHVybiBsZW47IH0KKwkJaSArPSBsZW47CisgICAgICAgICAgICAgICAgZGVidWcgPSB2YWx1ZTsKKwkJc3ByaW50ZihwZ19yZXN1bHQsICJPSzogZGVidWc9JXUiLCBkZWJ1Zyk7CisJCXJldHVybiBjb3VudDsKKwl9CisKKyAgICAgICAgaWYgKCFzdHJjbXAobmFtZSwgImZyYWdzIikpIHsKKwkJbGVuID0gbnVtX2FyZygmdXNlcl9idWZmZXJbaV0sIDEwLCAmdmFsdWUpOworICAgICAgICAgICAgICAgIGlmIChsZW4gPCAwKSB7IHJldHVybiBsZW47IH0KKwkJaSArPSBsZW47CisJCXBrdF9kZXYtPm5mcmFncyA9IHZhbHVlOworCQlzcHJpbnRmKHBnX3Jlc3VsdCwgIk9LOiBmcmFncz0ldSIsIHBrdF9kZXYtPm5mcmFncyk7CisJCXJldHVybiBjb3VudDsKKwl9CisJaWYgKCFzdHJjbXAobmFtZSwgImRlbGF5IikpIHsKKwkJbGVuID0gbnVtX2FyZygmdXNlcl9idWZmZXJbaV0sIDEwLCAmdmFsdWUpOworICAgICAgICAgICAgICAgIGlmIChsZW4gPCAwKSB7IHJldHVybiBsZW47IH0KKwkJaSArPSBsZW47CisJCWlmICh2YWx1ZSA9PSAweDdGRkZGRkZGKSB7CisJCQlwa3RfZGV2LT5kZWxheV91cyA9IDB4N0ZGRkZGRkY7CisJCQlwa3RfZGV2LT5kZWxheV9ucyA9IDA7CisJCX0gZWxzZSB7CisJCQlwa3RfZGV2LT5kZWxheV91cyA9IHZhbHVlIC8gMTAwMDsKKwkJCXBrdF9kZXYtPmRlbGF5X25zID0gdmFsdWUgJSAxMDAwOworCQl9CisJCXNwcmludGYocGdfcmVzdWx0LCAiT0s6IGRlbGF5PSV1IiwgMTAwMCpwa3RfZGV2LT5kZWxheV91cytwa3RfZGV2LT5kZWxheV9ucyk7CisJCXJldHVybiBjb3VudDsKKwl9CisgCWlmICghc3RyY21wKG5hbWUsICJ1ZHBfc3JjX21pbiIpKSB7CisJCWxlbiA9IG51bV9hcmcoJnVzZXJfYnVmZmVyW2ldLCAxMCwgJnZhbHVlKTsKKyAgICAgICAgICAgICAgICBpZiAobGVuIDwgMCkgeyByZXR1cm4gbGVuOyB9CisJCWkgKz0gbGVuOworICAgICAgICAgICAgICAgIGlmICh2YWx1ZSAhPSBwa3RfZGV2LT51ZHBfc3JjX21pbikgeworICAgICAgICAgICAgICAgICAgICAgICAgcGt0X2Rldi0+dWRwX3NyY19taW4gPSB2YWx1ZTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHBrdF9kZXYtPmN1cl91ZHBfc3JjID0gdmFsdWU7CisgICAgICAgICAgICAgICAgfSAgICAgICAKKwkJc3ByaW50ZihwZ19yZXN1bHQsICJPSzogdWRwX3NyY19taW49JXUiLCBwa3RfZGV2LT51ZHBfc3JjX21pbik7CisJCXJldHVybiBjb3VudDsKKwl9CisgCWlmICghc3RyY21wKG5hbWUsICJ1ZHBfZHN0X21pbiIpKSB7CisJCWxlbiA9IG51bV9hcmcoJnVzZXJfYnVmZmVyW2ldLCAxMCwgJnZhbHVlKTsKKyAgICAgICAgICAgICAgICBpZiAobGVuIDwgMCkgeyByZXR1cm4gbGVuOyB9CisJCWkgKz0gbGVuOworICAgICAgICAgICAgICAgIGlmICh2YWx1ZSAhPSBwa3RfZGV2LT51ZHBfZHN0X21pbikgeworICAgICAgICAgICAgICAgICAgICAgICAgcGt0X2Rldi0+dWRwX2RzdF9taW4gPSB2YWx1ZTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHBrdF9kZXYtPmN1cl91ZHBfZHN0ID0gdmFsdWU7CisgICAgICAgICAgICAgICAgfQorCQlzcHJpbnRmKHBnX3Jlc3VsdCwgIk9LOiB1ZHBfZHN0X21pbj0ldSIsIHBrdF9kZXYtPnVkcF9kc3RfbWluKTsKKwkJcmV0dXJuIGNvdW50OworCX0KKyAJaWYgKCFzdHJjbXAobmFtZSwgInVkcF9zcmNfbWF4IikpIHsKKwkJbGVuID0gbnVtX2FyZygmdXNlcl9idWZmZXJbaV0sIDEwLCAmdmFsdWUpOworICAgICAgICAgICAgICAgIGlmIChsZW4gPCAwKSB7IHJldHVybiBsZW47IH0KKwkJaSArPSBsZW47CisgICAgICAgICAgICAgICAgaWYgKHZhbHVlICE9IHBrdF9kZXYtPnVkcF9zcmNfbWF4KSB7CisgICAgICAgICAgICAgICAgICAgICAgICBwa3RfZGV2LT51ZHBfc3JjX21heCA9IHZhbHVlOworICAgICAgICAgICAgICAgICAgICAgICAgcGt0X2Rldi0+Y3VyX3VkcF9zcmMgPSB2YWx1ZTsKKyAgICAgICAgICAgICAgICB9CisJCXNwcmludGYocGdfcmVzdWx0LCAiT0s6IHVkcF9zcmNfbWF4PSV1IiwgcGt0X2Rldi0+dWRwX3NyY19tYXgpOworCQlyZXR1cm4gY291bnQ7CisJfQorIAlpZiAoIXN0cmNtcChuY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HJpbnRmKHBnX3Jlc3VsdCwgIk9LOiBjb3VudD0lbGx1IiwKKwkJCSh1bnNpZ25lZCBsb25nIGxvbmcpIHBrdF9kZXYtPmNvdW50KTsKKwkJcmV0dXJuIGNvdW50OworCX0KKwlpZiAoIXN0cmNtcChuYW1lLCAic3JjX21hY19jb3VudCIpKSB7CisJCWxlbiA9IG51bV9hcmcoJnVzZXJfYnVmZmVyW2ldLCAxMCwgJnZhbHVlKTsKKyAgICAgICAgICAgICAgICBpZiAobGVuIDwgMCkgeyByZXR1cm4gbGVuOyB9CisJCWkgKz0gbGVuOworCQlpZiAocGt0X2Rldi0+c3JjX21hY19jb3VudCAhPSB2YWx1ZSkgeworICAgICAgICAgICAgICAgICAgICAgICAgcGt0X2Rldi0+c3JjX21hY19jb3VudCA9IHZhbHVlOworICAgICAgICAgICAgICAgICAgICAgICAgcGt0X2Rldi0+Y3VyX3NyY19tYWNfb2Zmc2V0ID0gMDsKKyAgICAgICAgICAgICAgICB9CisJCXNwcmludGYocGdfcmVzdWx0LCAiT0s6IHNyY19tYWNfY291bnQ9JWQiLCBwa3RfZGV2LT5zcmNfbWFjX2NvdW50KTsKKwkJcmV0dXJuIGNvdW50OworCX0KKwlpZiAoIXN0cmNtcChuYW1lLCAiZHN0X21hY19jb3VudCIpKSB7CisJCWxlbiA9IG51bV9hcmcoJnVzZXJfYnVmZmVyW2ldLCAxMCwgJnZhbHVlKTsKKyAgICAgICAgICAgICAgICBpZiAobGVuIDwgMCkgeyByZXR1cm4gbGVuOyB9CisJCWkgKz0gbGVuOworCQlpZiAocGt0X2Rldi0+ZHN0X21hY19jb3VudCAhPSB2YWx1ZSkgeworICAgICAgICAgICAgICAgICAgICAgICAgcGt0X2Rldi0+ZHN0X21hY19jb3VudCA9IHZhbHVlOworICAgICAgICAgICAgICAgICAgICAgICAgcGt0X2Rldi0+Y3VyX2RzdF9tYWNfb2Zmc2V0ID0gMDsKKyAgICAgICAgICAgICAgICB9CisJCXNwcmludGYocGdfcmVzdWx0LCAiT0s6IGRzdF9tYWNfY291bnQ9JWQiLCBwa3RfZGV2LT5kc3RfbWFjX2NvdW50KTsKKwkJcmV0dXJuIGNvdW50OworCX0KKwlpZiAoIXN0cmNtcChuYW1lLCAiZmxhZyIpKSB7CisgICAgICAgICAgICAgICAgY2hhciBmWzMyXTsKKyAgICAgICAgICAgICAgICBtZW1zZXQoZiwgMCwgMzIpOworCQlsZW4gPSBzdHJuX2xlbigmdXNlcl9idWZmZXJbaV0sIHNpemVvZihmKSAtIDEpOworICAgICAgICAgICAgICAgIGlmIChsZW4gPCAwKSB7IHJldHVybiBsZW47IH0KKwkJaWYgKGNvcHlfZnJvbV91c2VyKGYsICZ1c2VyX2J1ZmZlcltpXSwgbGVuKSkKKwkJCXJldHVybiAtRUZBVUxUOworCQlpICs9IGxlbjsKKyAgICAgICAgICAgICAgICBpZiAoc3RyY21wKGYsICJJUFNSQ19STkQiKSA9PSAwKSAKKyAgICAgICAgICAgICAgICAgICAgICAgIHBrdF9kZXYtPmZsYWdzIHw9IEZfSVBTUkNfUk5EOworICAgICAgICAgICAgICAgIAorICAgICAgICAgICAgICAgIGVsc2UgaWYgKHN0cmNtcChmLCAiIUlQU1JDX1JORCIpID09IDApIAorICAgICAgICAgICAgICAgICAgICAgICAgcGt0X2Rldi0+ZmxhZ3MgJj0gfkZfSVBTUkNfUk5EOworICAgICAgICAgICAgICAgIAorICAgICAgICAgICAgICAgIGVsc2UgaWYgKHN0cmNtcChmLCAiVFhTSVpFX1JORCIpID09IDApIAorICAgICAgICAgICAgICAgICAgICAgICAgcGt0X2Rldi0+ZmxhZ3MgfD0gRl9UWFNJWkVfUk5EOworICAgICAgICAgICAgICAgIAorICAgICAgICAgICAgICAgIGVsc2UgaWYgKHN0cmNtcChmLCAiIVRYU0laRV9STkQiKSA9PSAwKSAKKyAgICAgICAgICAgICAgICAgICAgICAgIHBrdF9kZXYtPmZsYWdzICY9IH5GX1RYU0laRV9STkQ7CisgICAgICAgICAgICAgICAgCisgICAgICAgICAgICAgICAgZWxzZSBpZiAoc3RyY21wKGYsICJJUERTVF9STkQiKSA9PSAwKSAKKyAgICAgICAgICAgICAgICAgICAgICAgIHBrdF9kZXYtPmZsYWdzIHw9IEZfSVBEU1RfUk5EOworICAgICAgICAgICAgICAgIAorICAgICAgICAgICAgICAgIGVsc2UgaWYgKHN0cmNtcChmLCAiIUlQRFNUX1JORCIpID09IDApIAorICAgICAgICAgICAgICAgICAgICAgICAgcGt0X2Rldi0+ZmxhZ3MgJj0gfkZfSVBEU1RfUk5EOworICAgICAgICAgICAgICAgIAorICAgICAgICAgICAgICAgIGVsc2UgaWYgKHN0cmNtcChmLCAiVURQU1JDX1JORCIpID09IDApIAorICAgICAgICAgICAgICAgICAgICAgICAgcGt0X2Rldi0+ZmxhZ3MgfD0gRl9VRFBTUkNfUk5EOworICAgICAgICAgICAgICAgIAorICAgICAgICAgICAgICAgIGVsc2UgaWYgKHN0cmNtcChmLCAiIVVEUFNSQ19STkQiKSA9PSAwKSAKKyAgICAgICAgICAgICAgICAgICAgICAgIHBrdF9kZXYtPmZsYWdzICY9IH5GX1VEUFNSQ19STkQ7CisgICAgICAgICAgICAgICAgCisgICAgICAgICAgICAgICAgZWxzZSBpZiAoc3RyY21wKGYsICJVRFBEU1RfUk5EIikgPT0gMCkgCisgICAgICAgICAgICAgICAgICAgICAgICBwa3RfZGV2LT5mbGFncyB8PSBGX1VEUERTVF9STkQ7CisgICAgICAgICAgICAgICAgCisgICAgICAgICAgICAgICAgZWxzZSBpZiAoc3RyY21wKGYsICIhVURQRFNUX1JORCIpID09IDApIAorICAgICAgICAgICAgICAgICAgICAgICAgcGt0X2Rldi0+ZmxhZ3MgJj0gfkZfVURQRFNUX1JORDsKKyAgICAgICAgICAgICAgICAKKyAgICAgICAgICAgICAgICBlbHNlIGlmIChzdHJjbXAoZiwgIk1BQ1NSQ19STkQiKSA9PSAwKSAKKyAgICAgICAgICAgICAgICAgICAgICAgIHBrdF9kZXYtPmZsYWdzIHw9IEZfTUFDU1JDX1JORDsKKyAgICAgICAgICAgICAgICAKKyAgICAgICAgICAgICAgICBlbHNlIGlmIChzdHJjbXAoZiwgIiFNQUNTUkNfUk5EIikgPT0gMCkgCisgICAgICAgICAgICAgICAgICAgICAgICBwa3RfZGV2LT5mbGFncyAmPSB+Rl9NQUNTUkNfUk5EOworICAgICAgICAgICAgICAgIAorICAgICAgICAgICAgICAgIGVsc2UgaWYgKHN0cmNtcChmLCAiTUFDRFNUX1JORCIpID09IDApIAorICAgICAgICAgICAgICAgICAgICAgICAgcGt0X2Rldi0+ZmxhZ3MgfD0gRl9NQUNEU1RfUk5EOworICAgICAgICAgICAgICAgIAorICAgICAgICAgICAgICAgIGVsc2UgaWYgKHN0cmNtcChmLCAiIU1BQ0RTVF9STkQiKSA9PSAwKSAKKyAgICAgICAgICAgICAgICAgICAgICAgIHBrdF9kZXYtPmZsYWdzICY9IH5GX01BQ0RTVF9STkQ7CisgICAgICAgICAgICAgICAgCisgICAgICAgICAgICAgICAgZWxzZSB7CisgICAgICAgICAgICAgICAgICAgICAgICBzcHJpbnRmKHBnX3Jlc3VsdCwgIkZsYWcgLTolczotIHVua25vd25cbkF2YWlsYWJsZSBmbGFncywgKHByZXBlbmQgISB0byB1bi1zZXQgZmxhZyk6XG4lcyIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGYsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICJJUFNSQ19STkQsIElQRFNUX1JORCwgVFhTSVpFX1JORCwgVURQU1JDX1JORCwgVURQRFNUX1JORCwgTUFDU1JDX1JORCwgTUFDRFNUX1JORFxuIik7CisgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY291bnQ7CisgICAgICAgICAgICAgICAgfQorCQlzcHJpbnRmKHBnX3Jlc3VsdCwgIk9LOiBmbGFncz0weCV4IiwgcGt0X2Rldi0+ZmxhZ3MpOworCQlyZXR1cm4gY291bnQ7CisJfQorCWlmICghc3RyY21wKG5hbWUsICJkc3RfbWluIikgfHwgIXN0cmNtcChuYW1lLCAiZHN0IikpIHsKKwkJbGVuID0gc3Rybl9sZW4oJnVzZXJfYnVmZmVyW2ldLCBzaXplb2YocGt0X2Rldi0+ZHN0X21pbikgLSAxKTsKKyAgICAgICAgICAgICAgICBpZiAobGVuIDwgMCkgeyByZXR1cm4gbGVuOyB9CisKKyAgICAgICAgICAgICAgICBpZiAoY29weV9mcm9tX3VzZXIoYnVmLCAmdXNlcl9idWZmZXJbaV0sIGxlbikpCisJCQlyZXR1cm4gLUVGQVVMVDsKKyAgICAgICAgICAgICAgICBidWZbbGVuXSA9IDA7CisgICAgICAgICAgICAgICAgaWYgKHN0cmNtcChidWYsIHBrdF9kZXYtPmRzdF9taW4pICE9IDApIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIG1lbXNldChwa3RfZGV2LT5kc3RfbWluLCAwLCBzaXplb2YocGt0X2Rldi0+ZHN0X21pbikpOworICAgICAgICAgICAgICAgICAgICAgICAgc3RybmNweShwa3RfZGV2LT5kc3RfbWluLCBidWYsIGxlbik7CisgICAgICAgICAgICAgICAgICAgICAgICBwa3RfZGV2LT5kYWRkcl9taW4gPSBpbl9hdG9uKHBrdF9kZXYtPmRzdF9taW4pOworICAgICAgICAgICAgICAgICAgICAgICAgcGt0X2Rldi0+Y3VyX2RhZGRyID0gcGt0X2Rldi0+ZGFkZHJfbWluOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBpZihkZWJ1ZykKKyAgICAgICAgICAgICAgICAgICAgICAgIHByaW50aygicGt0Z2VuOiBkc3RfbWluIHNldCB0bzogJXNcbiIsIHBrdF9kZXYtPmRzdF9taW4pOworICAgICAgICAgICAgICAgIGkgKz0gbGVuOworCQlzcHJpbnRmKHBnX3Jlc3VsdCwgIk9LOiBkc3RfbWluPSVzIiwgcGt0X2Rldi0+ZHN0X21pbik7CisJCXJldHVybiBjb3VudDsKKwl9CisJaWYgKCFzdHJjbXAobmFtZSwgImRzdF9tYXgiKSkgeworCQlsZW4gPSBzdHJuX2xlbigmdXNlcl9idWZmZXJbaV0sIHNpemVvZihwa3RfZGV2LT5kc3RfbWF4KSAtIDEpOworICAgICAgICAgICAgICAgIGlmIChsZW4gPCAwKSB7IHJldHVybiBsZW47IH0KKworICAgICAgICAgICAgICAgIGlmIChjb3B5X2Zyb21fdXNlcihidWYsICZ1c2VyX2J1ZmZlcltpXSwgbGVuKSkKKwkJCXJldHVybiAtRUZBVUxUOworCisgICAgICAgICAgICAgICAgYnVmW2xlbl0gPSAwOworICAgICAgICAgICAgICAgIGlmIChzdHJjbXAoYnVmLCBwa3RfZGV2LT5kc3RfbWF4KSAhPSAwKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBtZW1zZXQocGt0X2Rldi0+ZHN0X21heCwgMCwgc2l6ZW9mKHBrdF9kZXYtPmRzdF9tYXgpKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHN0cm5jcHkocGt0X2Rldi0+ZHN0X21heCwgYnVmLCBsZW4pOworICAgICAgICAgICAgICAgICAgICAgICAgcGt0X2Rldi0+ZGFkZHJfbWF4ID0gaW5fYXRvbihwa3RfZGV2LT5kc3RfbWF4KTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHBrdF9kZXYtPmN1cl9kYWRkciA9IHBrdF9kZXYtPmRhZGRyX21heDsKKyAgICAgICAgICAgICAgICB9CisJCWlmKGRlYnVnKQorCQkJcHJpbnRrKCJwa3RnZW46IGRzdF9tYXggc2V0IHRvOiAlc1xuIiwgcGt0X2Rldi0+ZHN0X21heCk7CisJCWkgKz0gbGVuOworCQlzcHJpbnRmKHBnX3Jlc3VsdCwgIk9LOiBkc3RfbWF4PSVzIiwgcGt0X2Rldi0+ZHN0X21heCk7CisJCXJldHVybiBjb3VudDsKKwl9CisJaWYgKCFzdHJjbXAobmFtZSwgImRzdDYiKSkgeworCQlsZW4gPSBzdHJuX2xlbigmdXNlcl9idWZmZXJbaV0sIHNpemVvZihidWYpIC0gMSk7CisgICAgICAgICAgICAgICAgaWYgKGxlbiA8IDApIHJldHVybiBsZW47IAorCisJCXBrdF9kZXYtPmZsYWdzIHw9IEZfSVBWNjsKKworICAgICAgICAgICAgICAgIGlmIChjb3B5X2Zyb21fdXNlcihidWYsICZ1c2VyX2J1ZmZlcltpXSwgbGVuKSkKKwkJCXJldHVybiAtRUZBVUxUOworICAgICAgICAgICAgICAgIGJ1ZltsZW5dID0gMDsKKworCQlzY2FuX2lwNihidWYsIHBrdF9kZXYtPmluNl9kYWRkci5zNl9hZGRyKTsKKwkJZm10X2lwNihidWYsICBwa3RfZGV2LT5pbjZfZGFkZHIuczZfYWRkcik7CisKKwkJaXB2Nl9hZGRyX2NvcHkoJnBrdF9kZXYtPmN1cl9pbjZfZGFkZHIsICZwa3RfZGV2LT5pbjZfZGFkZHIpOworCisgICAgICAgICAgICAgICAgaWYoZGVidWcpIAorCQkJcHJpbnRrKCJwa3RnZW46IGRzdDYgc2V0IHRvOiAlc1xuIiwgYnVmKTsKKworICAgICAgICAgICAgICAgIGkgKz0gbGVuOworCQlzcHJpbnRmKHBnX3Jlc3VsdCwgIk9LOiBkc3Q2PSVzIiwgYnVmKTsKKwkJcmV0dXJuIGNvdW50OworCX0KKwlpZiAoIXN0cmNtcChuYW1lLCAiZHN0Nl9taW4iKSkgeworCQlsZW4gPSBzdHJuX2xlbigmdXNlcl9idWZmZXJbaV0sIHNpemVvZihidWYpIC0gMSk7CisgICAgICAgICAgICAgICAgaWYgKGxlbiA8IDApIHJldHVybiBsZW47IAorCisJCXBrdF9kZXYtPmZsYWdzIHw9IEZfSVBWNjsKKworICAgICAgICAgICAgICAgIGlmIChjb3B5X2Zyb21fdXNlcihidWYsICZ1c2VyX2J1ZmZlcltpXSwgbGVuKSkKKwkJCXJldHVybiAtRUZBVUxUOworICAgICAgICAgICAgICAgIGJ1ZltsZW5dID0gMDsKKworCQlzY2FuX2lwNihidWYsIHBrdF9kZXYtPm1pbl9pbjZfZGFkZHIuczZfYWRkcik7CisJCWZtdF9pcDYoYnVmLCAgcGt0X2Rldi0+bWluX2luNl9kYWRkci5zNl9hZGRyKTsKKworCQlpcHY2X2FkZHJfY29weSgmcGt0X2Rldi0+Y3VyX2luNl9kYWRkciwgJnBrdF9kZXYtPm1pbl9pbjZfZGFkZHIpOworICAgICAgICAgICAgICAgIGlmKGRlYnVnKSAKKwkJCXByaW50aygicGt0Z2VuOiBkc3Q2X21pbiBzZXQgdG86ICVzXG4iLCBidWYpOworCisgICAgICAgICAgICAgICAgaSArPSBsZW47CisJCXNwcmludGYocGdfcmVzdWx0LCAiT0s6IGRzdDZfbWluPSVzIiwgYnVmKTsKKwkJcmV0dXJuIGNvdW50OworCX0KKwlpZiAoIXN0cmNtcChuYW1lLCAiZHN0Nl9tYXgiKSkgeworCQlsZW4gPSBzdHJuX2xlbigmdXNlcl9idWZmZXJbaV0sIHNpemVvZihidWYpIC0gMSk7CisgICAgICAgICAgICAgICAgaWYgKGxlbiA8IDApIHJldHVybiBsZW47IAorCisJCXBrdF9kZXYtPmZsYWdzIHw9IEZfSVBWNjsKKworICAgICAgICAgICAgICAgIGlmIChjb3B5X2Zyb21fdXNlcihidWYsICZ1c2VyX2J1ZmZlcltpXSwgbGVuKSkKKwkJCXJldHVybiAtRUZBVUxUOworICAgICAgICAgICAgICAgIGJ1ZltsZW5dID0gMDsKKworCQlzY2FuX2lwNihidWYsIHBrdF9kZXYtPm1heF9pbjZfZGFkZHIuczZfYWRkcik7CisJCWZtdF9pcDYoYnVmLCAgcGt0X2Rldi0+bWF4X2luNl9kYWRkci5zNl9hZGRyKTsKKworICAgICAgICAgICAgICAgIGlmKGRlYnVnKSAKKwkJCXByaW50aygicGt0Z2VuOiBkc3Q2X21heCBzZXQgdG86ICVzXG4iLCBidWYpOworCisgICAgICAgICAgICAgICAgaSArPSBsZW47CisJCXNwcmludGYocGdfcmVzdWx0LCAiT0s6IGRzdDZfbWF4PSVzIiwgYnVmKTsKKwkJcmV0dXJuIGNvdW50OworCX0K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sKKyAgICAgICAgICAgICAgICBidWZbbGVuXSA9IDA7CisgICAgICAgICAgICAgICAgaWYgKHN0cmNtcChidWYsIHBrdF9kZXYtPnNyY19taW4pICE9IDApIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIG1lbXNldChwa3RfZGV2LT5zcmNfbWluLCAwLCBzaXplb2YocGt0X2Rldi0+c3JjX21pbikpOworICAgICAgICAgICAgICAgICAgICAgICAgc3RybmNweShwa3RfZGV2LT5zcmNfbWluLCBidWYsIGxlbik7CisgICAgICAgICAgICAgICAgICAgICAgICBwa3RfZGV2LT5zYWRkcl9taW4gPSBpbl9hdG9uKHBrdF9kZXYtPnNyY19taW4pOworICAgICAgICAgICAgICAgICAgICAgICAgcGt0X2Rldi0+Y3VyX3NhZGRyID0gcGt0X2Rldi0+c2FkZHJfbWluOworICAgICAgICAgICAgICAgIH0KKwkJaWYoZGVidWcpCisJCQlwcmludGsoInBrdGdlbjogc3JjX21pbiBzZXQgdG86ICVzXG4iLCBwa3RfZGV2LT5zcmNfbWluKTsKKwkJaSArPSBsZW47CisJCXNwcmludGYocGdfcmVzdWx0LCAiT0s6IHNyY19taW49JXMiLCBwa3RfZGV2LT5zcmNfbWluKTsKKwkJcmV0dXJuIGNvdW50OworCX0KKwlpZiAoIXN0cmNtcChuYW1lLCAic3JjX21heCIpKSB7CisJCWxlbiA9IHN0cm5fbGVuKCZ1c2VyX2J1ZmZlcltpXSwgc2l6ZW9mKHBrdF9kZXYtPnNyY19tYXgpIC0gMSk7CisgICAgICAgICAgICAgICAgaWYgKGxlbiA8IDApIHsgcmV0dXJuIGxlbjsgfQorICAgICAgICAgICAgICAgIGlmIChjb3B5X2Zyb21fdXNlcihidWYsICZ1c2VyX2J1ZmZlcltpXSwgbGVuKSkKKwkJCXJldHVybiAtRUZBVUxUOworICAgICAgICAgICAgICAgIGJ1ZltsZW5dID0gMDsKKyAgICAgICAgICAgICAgICBpZiAoc3RyY21wKGJ1ZiwgcGt0X2Rldi0+c3JjX21heCkgIT0gMCkgeworICAgICAgICAgICAgICAgICAgICAgICAgbWVtc2V0KHBrdF9kZXYtPnNyY19tYXgsIDAsIHNpemVvZihwa3RfZGV2LT5zcmNfbWF4KSk7CisgICAgICAgICAgICAgICAgICAgICAgICBzdHJuY3B5KHBrdF9kZXYtPnNyY19tYXgsIGJ1ZiwgbGVuKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHBrdF9kZXYtPnNhZGRyX21heCA9IGluX2F0b24ocGt0X2Rldi0+c3JjX21heCk7CisgICAgICAgICAgICAgICAgICAgICAgICBwa3RfZGV2LT5jdXJfc2FkZHIgPSBwa3RfZGV2LT5zYWRkcl9tYXg7CisgICAgICAgICAgICAgICAgfQorCQlpZihkZWJ1ZykKKwkJCXByaW50aygicGt0Z2VuOiBzcmNfbWF4IHNldCB0bzogJXNcbiIsIHBrdF9kZXYtPnNyY19tYXgpOworCQlpICs9IGxlbjsKKwkJc3ByaW50ZihwZ19yZXN1bHQsICJPSzogc3JjX21heD0lcyIsIHBrdF9kZXYtPnNyY19tYXgpOworCQlyZXR1cm4gY291bnQ7CisJfQorCWlmICghc3RyY21wKG5hbWUsICJkc3RfbWFjIikpIHsKKwkJY2hhciAqdiA9IHZhbHN0cjsKKyAgICAgICAgICAgICAgICB1bnNpZ25lZCBjaGFyIG9sZF9kbWFjWzZdOworCQl1bnNpZ25lZCBjaGFyICptID0gcGt0X2Rldi0+ZHN0X21hYzsKKyAgICAgICAgICAgICAgICBtZW1jcHkob2xkX2RtYWMsIHBrdF9kZXYtPmRzdF9tYWMsIDYpOworICAgICAgICAgICAgICAgIAorCQlsZW4gPSBzdHJuX2xlbigmdXNlcl9idWZmZXJbaV0sIHNpemVvZih2YWxzdHIpIC0gMSk7CisgICAgICAgICAgICAgICAgaWYgKGxlbiA8IDApIHsgcmV0dXJuIGxlbjsgfQorCQltZW1zZXQodmFsc3RyLCAwLCBzaXplb2YodmFsc3RyKSk7CisJCWlmKCBjb3B5X2Zyb21fdXNlcih2YWxzdHIsICZ1c2VyX2J1ZmZlcltpXSwgbGVuKSkKKwkJCXJldHVybiAtRUZBVUxUOworCQlpICs9IGxlbjsKKworCQlmb3IoKm0gPSAwOyp2ICYmIG0gPCBwa3RfZGV2LT5kc3RfbWFjICsgNjsgdisrKSB7CisJCQlpZiAoKnYgPj0gJzAnICYmICp2IDw9ICc5JykgeworCQkJCSptICo9IDE2OworCQkJCSptICs9ICp2IC0gJzAnOworCQkJfQorCQkJaWYgKCp2ID49ICdBJyAmJiAqdiA8PSAnRicpIHsKKwkJCQkqbSAqPSAxNjsKKwkJCQkqbSArPSAqdiAtICdBJyArIDEwOworCQkJfQorCQkJaWYgKCp2ID49ICdhJyAmJiAqdiA8PSAnZicpIHsKKwkJCQkqbSAqPSAxNjsKKwkJCQkqbSArPSAqdiAtICdhJyArIDEwOworCQkJfQorCQkJaWYgKCp2ID09ICc6JykgeworCQkJCW0rKzsKKwkJCQkqbSA9IDA7CisJCQl9CisJCX0KKworCQkvKiBTZXQgdXAgRGVzdCBNQUMgKi8KKyAgICAgICAgICAgICAgICBpZiAobWVtY21wKG9sZF9kbWFjLCBwa3RfZGV2LT5kc3RfbWFjLCA2KSAhPSAwKSAKKyAgICAgICAgICAgICAgICAgICAgICAgIG1lbWNweSgmKHBrdF9kZXYtPmhoWzBdKSwgcGt0X2Rldi0+ZHN0X21hYywgNik7CisgICAgICAgICAgICAgICAgCisJCXNwcmludGYocGdfcmVzdWx0LCAiT0s6IGRzdG1hYyIpOworCQlyZXR1cm4gY291bnQ7CisJfQorCWlmICghc3RyY21wKG5hbWUsICJzcmNfbWFjIikpIHsKKwkJY2hhciAqdiA9IHZhbHN0cjsKKwkJdW5zaWduZWQgY2hhciAqbSA9IHBrdF9kZXYtPnNyY19tYWM7CisKKwkJbGVuID0gc3Rybl9sZW4oJnVzZXJfYnVmZmVyW2ldLCBzaXplb2YodmFsc3RyKSAtIDEpOworICAgICAgICAgICAgICAgIGlmIChsZW4gPCAwKSB7IHJldHVybiBsZW47IH0KKwkJbWVtc2V0KHZhbHN0ciwgMCwgc2l6ZW9mKHZhbHN0cikpOworCQlpZiggY29weV9mcm9tX3VzZXIodmFsc3RyLCAmdXNlcl9idWZmZXJbaV0sIGxlbikpIAorCQkJcmV0dXJuIC1FRkFVTFQ7CisJCWkgKz0gbGVuOworCisJCWZvcigqbSA9IDA7KnYgJiYgbSA8IHBrdF9kZXYtPnNyY19tYWMgKyA2OyB2KyspIHsKKwkJCWlmICgqdiA+PSAnMCcgJiYgKnYgPD0gJzknKSB7CisJCQkJKm0gKj0gMTY7CisJCQkJKm0gKz0gKnYgLSAnMCc7CisJCQl9CisJCQlpZiAoKnYgPj0gJ0EnICYmICp2IDw9ICdGJykgeworCQkJCSptICo9IDE2OworCQkJCSptICs9ICp2IC0gJ0EnICsgMTA7CisJCQl9CisJCQlpZiAoKnYgPj0gJ2EnICYmICp2IDw9ICdmJykgeworCQkJCSptICo9IDE2OworCQkJCSptICs9ICp2IC0gJ2EnICsgMTA7CisJCQl9CisJCQlpZiAoKnYgPT0gJzonKSB7CisJCQkJbSsrOworCQkJCSptID0gMDsKKwkJCX0KKwkJfQkgIAorCisgICAgICAgICAgICAgICAgc3ByaW50ZihwZ19yZXN1bHQsICJPSzogc3JjbWFjIik7CisJCXJldHVybiBjb3VudDsKKwl9CisKKyAgICAgICAgaWYgKCFzdHJjbXAobmFtZSwgImNsZWFyX2NvdW50ZXJzIikpIHsKKyAgICAgICAgICAgICAgICBwa3RnZW5fY2xlYXJfY291bnRlcnMocGt0X2Rldik7CisgICAgICAgICAgICAgICAgc3ByaW50ZihwZ19yZXN1bHQsICJPSzogQ2xlYXJpbmcgY291bnRlcnMuXG4iKTsKKyAgICAgICAgICAgICAgICByZXR1cm4gY291bnQ7CisgICAgICAgIH0KKworCWlmICghc3RyY21wKG5hbWUsICJmbG93cyIpKSB7CisJCWxlbiA9IG51bV9hcmcoJnVzZXJfYnVmZmVyW2ldLCAxMCwgJnZhbHVlKTsKKyAgICAgICAgICAg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AgICAgICAgICAgcHJpbnRrKCJwa3RnZW46IEVSUk9SOiBjb3VsZCBub3QgZmluZCB0aHJlYWQgaW4gcHJvY190aHJlYWRfcmVhZFxuIik7CisgICAgICAgICAgICAgICAgcmV0dXJuIC1FSU5WQUw7CisgICAgICAgIH0KKworCXAgPSBidWY7CisJcCArPSBzcHJpbnRmKHAsICJOYW1lOiAlcyAgbWF4X2JlZm9yZV9zb2Z0aXJxOiAlZFxuIiwKKyAgICAgICAgICAgICAgICAgICAgIHQtPm5hbWUsIHQtPm1heF9iZWZvcmVfc29mdGlycSk7CisKKyAgICAgICAgcCArPSBzcHJpbnRmKHAsICJSdW5uaW5nOiAiKTsKKyAgICAgICAgCisgICAgICAgIGlmX2xvY2sodCk7CisgICAgICAgIGZvcihwa3RfZGV2ID0gdC0+aWZfbGlzdDtwa3RfZGV2OyBwa3RfZGV2ID0gcGt0X2Rldi0+bmV4dCkgCisJCWlmKHBrdF9kZXYtPnJ1bm5pbmcpCisJCQlwICs9IHNwcmludGYocCwgIiVzICIsIHBrdF9kZXYtPmlmbmFtZSk7CisgICAgICAgIAorICAgICAgICBwICs9IHNwcmludGYocCwgIlxuU3RvcHBlZDogIik7CisKKyAgICAgICAgZm9yKHBrdF9kZXYgPSB0LT5pZl9saXN0O3BrdF9kZXY7IHBrdF9kZXYgPSBwa3RfZGV2LT5uZXh0KSAKKwkJaWYoIXBrdF9kZXYtPnJ1bm5pbmcpCisJCQlwICs9IHNwcmludGYocCwgIiVzICIsIHBrdF9kZXYtPmlmbmFtZSk7CisKKwlpZiAodC0+cmVzdWx0WzBdKQorCQlwICs9IHNwcmludGYocCwgIlxuUmVzdWx0OiAlc1xuIiwgdC0+cmVzdWx0KTsKKwllbHNlCisJCXAgKz0gc3ByaW50ZihwLCAiXG5SZXN1bHQ6IE5BXG4iKTsKKworCSplb2YgPSAxOworCisgICAgICAgIGlmX3VubG9jayh0KTsKKworCXJldHVybiBwIC0gYnVmOworfQorCitzdGF0aWMgaW50IHByb2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gKGxlbiA8IDApICAKKwkJcmV0dXJuIGxlbjsgCisJCisJaSArPSBsZW47CisKKwlpZiAoZGVidWcpIAorCQlwcmludGsoInBrdGdlbjogdD0lcywgY291bnQ9JWx1XG4iLCBuYW1lLCBjb3VudCk7CisgICAgICAgIAorCisgICAgICAgIHQgPSAoc3RydWN0IHBrdGdlbl90aHJlYWQqKShkYXRhKTsKKwlpZighdCkgeworCQlwcmludGsoInBrdGdlbjogRVJST1I6IE5vIHRocmVhZFxuIik7CisJCXJldCA9IC1FSU5WQUw7CisJCWdvdG8gb3V0OworCX0KKworCXBnX3Jlc3VsdCA9ICYodC0+cmVzdWx0WzBdKTsKKworICAgICAgICBpZiAoIXN0cmNtcChuYW1lLCAiYWRkX2RldmljZSIpKSB7CisgICAgICAgICAgICAgICAgY2hhciBmWzMyXTsKKyAgICAgICAgICAgICAgICBtZW1zZXQoZiwgMCwgMzIpOworCQlsZW4gPSBzdHJuX2xlbigmdXNlcl9idWZmZXJbaV0sIHNpemVvZihmKSAtIDEpOworICAgICAgICAgICAgICAgIGlmIChsZW4gPCAwKSB7IAorCQkJcmV0ID0gbGVuOyAKKwkJCWdvdG8gb3V0OworCQl9CisJCWlmKCBjb3B5X2Zyb21fdXNlcihmLCAmdXNlcl9idWZmZXJbaV0sIGxlbikgKQorCQkJcmV0dXJuIC1FRkFVTFQ7CisJCWkgKz0gbGVuOworCQl0aHJlYWRfbG9jaygpOworICAgICAgICAgICAgICAgIHBrdGdlbl9hZGRfZGV2aWNlKHQsIGYpOworCQl0aHJlYWRfdW5sb2NrKCk7CisgICAgICAgICAgICAgICAgcmV0ID0gY291bnQ7CisgICAgICAgICAgICAgICAgc3ByaW50ZihwZ19yZXN1bHQsICJPSzogYWRkX2RldmljZT0lcyIsIGYpOworCQlnb3RvIG91dDsKKwl9CisKKyAgICAgICAgaWYgKCFzdHJjbXAobmFtZSwgInJlbV9kZXZpY2VfYWxsIikpIHsKKwkJdGhyZWFkX2xvY2soKTsKKwkJdC0+Y29udHJvbCB8PSBUX1JFTURFVjsKKwkJdGhyZWFkX3VubG9jaygpOworCQljdXJyZW50LT5zdGF0ZSA9IFRBU0tfSU5URVJSVVBUSUJMRTsKKwkJc2NoZWR1bGVfdGltZW91dChIWi84KTsgIC8qIFByb3BhZ2F0ZSB0aHJlYWQtPmNvbnRyb2wgICovCisJCXJldCA9IGNvdW50OworICAgICAgICAgICAgICAgIHNwcmludGYocGdfcmVzdWx0LCAiT0s6IHJlbV9kZXZpY2VfYWxsIik7CisJCWdvdG8gb3V0OworCX0KKworICAgICAgICBpZiAoIXN0cmNtcChuYW1lLCAibWF4X2JlZm9yZV9zb2Z0aXJxIikpIHsKKyAgICAgICAgICAgICAgICBsZW4gPSBudW1fYXJnKCZ1c2VyX2J1ZmZlcltpXSwgMTAsICZ2YWx1ZSk7CisJCXRocmVhZF9sb2NrKCk7CisgICAgICAgICAgICAgICAgdC0+bWF4X2JlZm9yZV9zb2Z0aXJxID0gdmFsdWU7CisJCXRocmVhZF91bmxvY2soKTsKKyAgICAgICAgICAgICAgICByZXQgPSBjb3VudDsKKyAgICAgICAgICAgICAgICBzcHJpbnRmKHBnX3Jlc3VsdCwgIk9LOiBtYXhfYmVmb3JlX3NvZnRpcnE9JWx1IiwgdmFsdWUpOworCQlnb3RvIG91dDsKKwl9CisKKwlyZXQgPSAtRUlOVkFMOworIG91dDoKKworCXJldHVybiByZXQ7Cit9CisKK3N0YXRpYyBpbnQgY3JlYXRlX3Byb2NfZGlyKHZvaWQpCit7CisgICAgICAgIGludCAgICAgbGVuOworICAgICAgICAvKiAgZG9lcyBwcm9jX2RpciBhbHJlYWR5IGV4aXN0cyAqLworICAgICAgICBsZW4gPSBzdHJsZW4oUEdfUFJPQ19ESVIpOworCisgICAgICAgIGZvciAocGdfcHJvY19kaXIgPSBwcm9jX25ldC0+c3ViZGlyOyBwZ19wcm9jX2RpcjsgcGdfcHJvY19kaXI9cGdfcHJvY19kaXItPm5leHQpIHsKKyAgICAgICAgICAgICAgICBpZiAoKHBnX3Byb2NfZGlyLT5uYW1lbGVuID09IGxlbikgJiYKKwkJICAgICghIG1lbWNtcChwZ19wcm9jX2Rpci0+bmFtZSwgUEdfUFJPQ19ESVIsIGxlbikpKSAKKyAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICB9CisgICAgICAgIAorICAgICAgICBpZiAoIXBnX3Byb2NfZGlyKSAKKyAgICAgICAgICAgICAgICBwZ19wcm9jX2RpciA9IGNyZWF0ZV9wcm9jX2VudHJ5KFBHX1BST0NfRElSLCBTX0lGRElSLCBwcm9jX25ldCk7CisgICAgICAgIAorICAgICAgICBpZiAoIXBnX3Byb2NfZGlyKSAKKyAgICAgICAgICAgICAgICByZXR1cm4gLUVOT0RFVjsKKyAgICAgICAgCisgICAgICAgIHJldHVybiAwOworfQorCitzdGF0aWMgaW50IHJlbW92ZV9wcm9jX2Rpcih2b2lkKQoreworICAgICAgICByZW1vdmVfcHJvY19lbnRyeShQR19QUk9DX0RJUiwgcHJvY19uZXQpOworICAgICAgICByZXR1cm4gMDsKK30KKworLyogVGhpbmsgZmluZCBvciByZW1vdmUgZm9yIE5OICovCitzdGF0aWMgc3RydWN0IHBrdGdlbl9kZXYgKl9fcGt0Z2VuX05OX3RocmVhZHMoY29uc3QgY2hhciogaWZuYW1lLCBpbnQgcmVtb3ZlKSAKK3sKKwlzdHJ1Y3QgcGt0Z2VuX3RocmVhZCAqdDsKKwlzdHJ1Y3QgcGt0Z2VuX2RldiAqcGt0X2RldiA9IE5VTEw7CisKKyAgICAgICAgdCA9IHBrdGdlbl90aHJlYWRzOworICAgICAgICAgICAgICAgIAorCXdoaWxlICh0KSB7CisJCXBrdF9kZXYgPSBwa3RnZW5fZmluZF9kZXYodCwgaWZuYW1lKTsKKwkJaWYgKHBrdF9kZXYpIHsKKwkJICAgICAgICAgICAgICAgIGlmKHJlbW92ZSkgeyAKKwkJCQkgICAgICAgIGlmX2xvY2sodCk7CisJCQkJICAgICAgICBwa3RnZW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MoZGV2LT5uYW1lLCBSRU1PVkUpOworCQlicmVhazsKKwl9OworCisJcmV0dXJuIE5PVElGWV9ET05FOworfQorCisvKiBBc3NvY2lhdGUgcGt0Z2VuX2RldiB3aXRoIGEgZGV2aWNlLiAqLworCitzdGF0aWMgc3RydWN0IG5ldF9kZXZpY2UqIHBrdGdlbl9zZXR1cF9kZXYoc3RydWN0IHBrdGdlbl9kZXYgKnBrdF9kZXYpIHsKKwlzdHJ1Y3QgbmV0X2RldmljZSAqb2RldjsKKworCS8qIENsZWFuIG9sZCBzZXR1cHMgKi8KKworCWlmIChwa3RfZGV2LT5vZGV2KSB7CisJCWRldl9wdXQocGt0X2Rldi0+b2Rldik7CisgICAgICAgICAgICAgICAgcGt0X2Rldi0+b2RldiA9IE5VTEw7CisgICAgICAgIH0KKworCW9kZXYgPSBkZXZfZ2V0X2J5X25hbWUocGt0X2Rldi0+aWZuYW1lKTsKKworCWlmICghb2RldikgeworCQlwcmludGsoInBrdGdlbjogbm8gc3VjaCBuZXRkZXZpY2U6IFwiJXNcIlxuIiwgcGt0X2Rldi0+aWZuYW1lKTsKKwkJZ290byBvdXQ7CisJfQorCWlmIChvZGV2LT50eXBlICE9IEFSUEhSRF9FVEhFUikgeworCQlwcmludGsoInBrdGdlbjogbm90IGFuIGV0aGVybmV0IGRldmljZTogXCIlc1wiXG4iLCBwa3RfZGV2LT5pZm5hbWUpOworCQlnb3RvIG91dF9wdXQ7CisJfQorCWlmICghbmV0aWZfcnVubmluZyhvZGV2KSkgeworCQlwcmludGsoInBrdGdlbjogZGV2aWNlIGlzIGRvd246IFwiJXNcIlxuIiwgcGt0X2Rldi0+aWZuYW1lKTsKKwkJZ290byBvdXRfcHV0OworCX0KKwlwa3RfZGV2LT5vZGV2ID0gb2RldjsKKwkKKyAgICAgICAgcmV0dXJuIHBrdF9kZXYtPm9kZXY7CisKK291dF9wdXQ6CisJZGV2X3B1dChvZGV2KTsKK291dDoKKyAJcmV0dXJuIE5VTEw7CisKK30KK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3VudCA+IHBrdF9kZXYtPmxmbG93KQorCQkJcGt0X2Rldi0+Zmxvd3NbZmxvd10uY291bnQgPSAwOworCX0JCQkJCQkKKworCisJLyogIERlYWwgd2l0aCBzb3VyY2UgTUFDICovCisgICAgICAgIGlmIChwa3RfZGV2LT5zcmNfbWFjX2NvdW50ID4gMSkgeworICAgICAgICAgICAgICAgIF9fdTMyIG1jOworICAgICAgICAgICAgICAgIF9fdTMyIHRtcDsKKworICAgICAgICAgICAgICAgIGlmIChwa3RfZGV2LT5mbGFncyAmIEZfTUFDU1JDX1JORCkgCisgICAgICAgICAgICAgICAgICAgICAgICBtYyA9IHBrdGdlbl9yYW5kb20oKSAlIChwa3RfZGV2LT5zcmNfbWFjX2NvdW50KTsKKyAgICAgICAgICAgICAgICBlbHNlIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIG1jID0gcGt0X2Rldi0+Y3VyX3NyY19tYWNfb2Zmc2V0Kys7CisgICAgICAgICAgICAgICAgICAgICAgICBpZiAocGt0X2Rldi0+Y3VyX3NyY19tYWNfb2Zmc2V0ID4gcGt0X2Rldi0+c3JjX21hY19jb3VudCkgCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBrdF9kZXYtPmN1cl9zcmNfbWFjX29mZnNldCA9IDA7CisgICAgICAgICAgICAgICAgfQorCisgICAgICAgICAgICAgICAgdG1wID0gcGt0X2Rldi0+c3JjX21hY1s1XSArIChtYyAmIDB4RkYpOworICAgICAgICAgICAgICAgIHBrdF9kZXYtPmhoWzExXSA9IHRtcDsKKyAgICAgICAgICAgICAgICB0bXAgPSAocGt0X2Rldi0+c3JjX21hY1s0XSArICgobWMgPj4gOCkgJiAweEZGKSArICh0bXAgPj4gOCkpOworICAgICAgICAgICAgICAgIHBrdF9kZXYtPmhoWzEwXSA9IHRtcDsKKyAgICAgICAgICAgICAgICB0bXAgPSAocGt0X2Rldi0+c3JjX21hY1szXSArICgobWMgPj4gMTYpICYgMHhGRikgKyAodG1wID4+IDgpKTsKKyAgICAgICAgICAgICAgICBwa3RfZGV2LT5oaFs5XSA9IHRtcDsKKyAgICAgICAgICAgICAgICB0bXAgPSAocGt0X2Rldi0+c3JjX21hY1syXSArICgobWMgPj4gMjQpICYgMHhGRikgKyAodG1wID4+IDgpKTsKKyAgICAgICAgICAgICAgICBwa3RfZGV2LT5oaFs4XSA9IHRtcDsKKyAgICAgICAgICAgICAgICB0bXAgPSAocGt0X2Rldi0+c3JjX21hY1sxXSArICh0bXAgPj4gOCkpOworICAgICAgICAgICAgICAgIHBrdF9kZXYtPmhoWzddID0gdG1wOyAgICAgICAgCisgICAgICAgIH0KKworICAgICAgICAvKiAgRGVhbCB3aXRoIERlc3RpbmF0aW9uIE1BQyAqLworICAgICAgICBpZiAocGt0X2Rldi0+ZHN0X21hY19jb3VudCA+IDEpIHsKKyAgICAgICAgICAgICAgICBfX3UzMiBtYzsKKyAgICAgICAgICAgICAgICBfX3UzMiB0bXA7CisKKyAgICAgICAgICAgICAgICBpZiAocGt0X2Rldi0+ZmxhZ3MgJiBGX01BQ0RTVF9STkQpIAorICAgICAgICAgICAgICAgICAgICAgICAgbWMgPSBwa3RnZW5fcmFuZG9tKCkgJSAocGt0X2Rldi0+ZHN0X21hY19jb3VudCk7CisKKyAgICAgICAgICAgICAgICBlbHNlIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIG1jID0gcGt0X2Rldi0+Y3VyX2RzdF9tYWNfb2Zmc2V0Kys7CisgICAgICAgICAgICAgICAgICAgICAgICBpZiAocGt0X2Rldi0+Y3VyX2RzdF9tYWNfb2Zmc2V0ID4gcGt0X2Rldi0+ZHN0X21hY19jb3VudCkgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwa3RfZGV2LT5jdXJfZHN0X21hY19vZmZzZXQgPSAwOworICAgICAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIH0KKworICAgICAgICAgICAgICAgIHRtcCA9IHBrdF9kZXYtPmRzdF9tYWNbNV0gKyAobWMgJiAweEZGKTsKKyAgICAgICAgICAgICAgICBwa3RfZGV2LT5oaFs1XSA9IHRtcDsKKyAgICAgICAgICAgICAgICB0bXAgPSAocGt0X2Rldi0+ZHN0X21hY1s0XSArICgobWMgPj4gOCkgJiAweEZGKSArICh0bXAgPj4gOCkpOworICAgICAgICAgICAgICAgIHBrdF9kZXYtPmhoWzRdID0gdG1wOworICAgICAgICAgICAgICAgIHRtcCA9IChwa3RfZGV2LT5kc3RfbWFjWzNdICsgKChtYyA+PiAxNikgJiAweEZGKSArICh0bXAgPj4gOCkpOworICAgICAgICAgICAgICAgIHBrdF9kZXYtPmhoWzNdID0gdG1wOworICAgICAgICAgICAgICAgIHRtcCA9IChwa3RfZGV2LT5kc3RfbWFjWzJdICsgKChtYyA+PiAyNCkgJiAweEZGKSArICh0bXAgPj4gOCkpOworICAgICAgICAgICAgICAgIHBrdF9kZXYtPmhoWzJdID0gdG1wOworICAgICAgICAgICAgICAgIHRtcCA9IChwa3RfZGV2LT5kc3RfbWFjWzFdICsgKHRtcCA+PiA4KSk7CisgICAgICAgICAgICAgICAgcGt0X2Rldi0+aGhbMV0gPSB0bXA7ICAgICAgICAKKyAgICAgICAgfQorCisgICAgICAgIGlmIChwa3RfZGV2LT51ZHBfc3JjX21pbiA8IHBrdF9kZXYtPnVkcF9zcmNfbWF4KSB7CisgICAgICAgICAgICAgICAgaWYgKHBrdF9kZXYtPmZsYWdzICYgRl9VRFBTUkNfUk5EKSAKKyAgICAgICAgICAgICAgICAgICAgICAgIHBrdF9kZXYtPmN1cl91ZHBfc3JjID0gKChwa3RnZW5fcmFuZG9tKCkgJSAocGt0X2Rldi0+dWRwX3NyY19tYXggLSBwa3RfZGV2LT51ZHBfc3JjX21pbikpICsgcGt0X2Rldi0+dWRwX3NyY19taW4pOworCisgICAgICAgICAgICAgICAgZWxzZSB7CisJCQlwa3RfZGV2LT5jdXJfdWRwX3NyYysrOworCQkJaWYgKHBrdF9kZXYtPmN1cl91ZHBfc3JjID49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GF0aWMgdW5zaWduZWQgaW50IHNjYW5faXA2KGNvbnN0IGNoYXIgKnMsY2hhciBpcFsxNl0pCit7CisJdW5zaWduZWQgaW50IGk7CisJdW5zaWduZWQgaW50IGxlbj0wOworCXVuc2lnbmVkIGxvbmcgdTsKKwljaGFyIHN1ZmZpeFsxNl07CisJdW5zaWduZWQgaW50IHByZWZpeGxlbj0wOworCXVuc2lnbmVkIGludCBzdWZmaXhsZW49MDsKKwlfX3UzMiB0bXA7CisKKwlmb3IgKGk9MDsgaTwxNjsgaSsrKSBpcFtpXT0wOworCisJZm9yICg7OykgeworCQlpZiAoKnMgPT0gJzonKSB7CisJCQlsZW4rKzsKKwkJCWlmIChzWzFdID09ICc6JykgeyAgICAgICAgLyogRm91bmQgIjo6Iiwgc2tpcCB0byBwYXJ0IDIgKi8KKwkJCQlzKz0yOworCQkJCWxlbisrOworCQkJCWJyZWFrOworCQkJfQorCQkJcysrOworCQl9CisJCXsKKwkJCWNoYXIgKnRtcDsKKwkJCXU9c2ltcGxlX3N0cnRvdWwocywmdG1wLDE2KTsKKwkJCWk9dG1wLXM7CisJCX0KKworCQlpZiAoIWkpIHJldHVybiAwOworCQlpZiAocHJlZml4bGVuPT0xMiAmJiBzW2ldPT0nLicpIHsKKworCQkJLyogdGhlIGxhc3QgNCBieXRlcyBtYXkgYmUgd3JpdHRlbiBhcyBJUHY0IGFkZHJlc3MgKi8KKworCQkJdG1wID0gaW5fYXRvbihzKTsKKwkJCW1lbWNweSgoc3RydWN0IGluX2FkZHIqKShpcCsxMiksICZ0bXAsIHNpemVvZih0bXApKTsKKwkJCXJldHVybiBpK2xlbjsKKwkJfQorCQlpcFtwcmVmaXhsZW4rK10gPSAodSA+PiA4KTsKKwkJaXBbcHJlZml4bGVuKytdID0gKHUgJiAyNTUpOworCQlzICs9IGk7IGxlbiArPSBpOworCQlpZiAocHJlZml4bGVuPT0xNikKKwkJCXJldHVybiBsZW47CisJfQorCisvKiBwYXJ0IDIsIGFmdGVyICI6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ICAgICAgIHJldHVybiByZXM7Cit9CisKK3N0YXRpYyBpbnQgcGt0Z2VuX3dhaXRfdGhyZWFkX3J1bihzdHJ1Y3QgcGt0Z2VuX3RocmVhZCAqdCApCit7CisgICAgICAgIGlmX2xvY2sodCk7CisKKyAgICAgICAgd2hpbGUodGhyZWFkX2lzX3J1bm5pbmcodCkpIHsKKworICAgICAgICAgICAgICAgIGlmX3VubG9jayh0KTsKKworCQltc2xlZXBfaW50ZXJydXB0aWJsZSgxMDApOyAKKworICAgICAgICAgICAgICAgIGlmIChzaWduYWxfcGVuZGluZyhjdXJyZW50KSkgCisgICAgICAgICAgICAgICAgICAgICAgICBnb3RvIHNpZ25hbDsKKyAgICAgICAgICAgICAgICBpZl9sb2NrKHQpOworICAgICAgICB9CisgICAgICAgIGlmX3VubG9jayh0KTsKKyAgICAgICAgcmV0dXJuIDE7Cisgc2lnbmFsOgorICAgICAgICByZXR1cm4gMDsKK30KKworc3RhdGljIGludCBwa3RnZW5fd2FpdF9hbGxfdGhyZWFkc19ydW4odm9pZCkKK3sKKwlzdHJ1Y3QgcGt0Z2VuX3RocmVhZCAqdCA9IHBrdGdlbl90aHJlYWRzOworCWludCBzaWcgPSAxOworCQorCXdoaWxlICh0KSB7CisJCXNpZyA9IHBrdGdlbl93YWl0X3RocmVhZF9ydW4odCk7CisJCWlmKCBzaWcgPT0gMCApIGJyZWFrOworCQl0aHJlYWRfbG9jaygpOworCQl0PXQtPm5leHQ7CisJCXRocmVhZF91bmxvY2soKTsKKwl9CisJaWYoc2lnID09IDApIHsKKwkJdGhyZWFkX2xvY2soKTsKKwkJd2hpbGUgKHQpIHsKKwkJCXQtPmNvbnRyb2wgfD0gKFRfU1RPUCk7CisJCQl0PXQtPm5leHQ7CisJCX0KKwkJdGhyZWFkX3VubG9jaygpOworCX0KKwlyZXR1cm4gc2lnOworfQorCitzdGF0aWMgdm9pZCBwa3RnZW5fcnVuX2FsbF90aHJlYWRzKHZvaWQpCit7CisgICAgICAgIHN0c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ICh1bnNpZ25lZCBsb25nIGxvbmcpIHBrdF9kZXYtPnNvZmFyLCAKKwkJICAgIHBrdF9kZXYtPmN1cl9wa3Rfc2l6ZSwgbnJfZnJhZ3MpOworCisgICAgICAgcHBzID0gcGt0X2Rldi0+c29mYXIgKiBVU0VDX1BFUl9TRUM7CisKKyAgICAgICB3aGlsZSAoKHRvdGFsX3VzID4+IDMyKSAhPSAwKSB7CisgICAgICAgICAgICAgICBwcHMgPj49IDE7CisgICAgICAgICAgICAgICB0b3RhbF91cyA+Pj0gMTsKKyAgICAgICB9CisKKyAgICAgICBkb19kaXYocHBzLCB0b3RhbF91cyk7CisgICAgICAgCisgICAgICAgYnBzID0gcHBzICogOCAqIHBrdF9kZXYtPmN1cl9wa3Rfc2l6ZTsKKworICAgICAgIG1icHMgPSBicHM7CisgICAgICAgZG9fZGl2KG1icHMsIDEwMDAwMDApOworICAgICAgIHAgKz0gc3ByaW50ZihwLCAiICAlbGx1cHBzICVsbHVNYi9zZWMgKCVsbHVicHMpIGVycm9yczogJWxsdSIsCisgICAgICAgICAgICAgICAgICAgICh1bnNpZ25lZCBsb25nIGxvbmcpIHBwcywgCisJCSAgICAodW5zaWduZWQgbG9uZyBsb25nKSBtYnBzLCAKKwkJICAgICh1bnNpZ25lZCBsb25nIGxvbmcpIGJwcywgCisJCSAgICAodW5zaWduZWQgbG9uZyBsb25nKSBwa3RfZGV2LT5lcnJvcnMpOworfQorIAorCisvKiBTZXQgc3RvcHBlZC1hdCB0aW1lciwgcmVtb3ZlIGZyb20gcnVubmluZyBsaXN0LCBkbyBjb3VudGVycyAmIHN0YXRpc3RpY3MgKi8KKworc3RhdGljIGludCBwa3RnZW5fc3RvcF9kZXZpY2Uoc3RydWN0IHBrdGdlbl9kZXYgKnBrdF9kZXYpIAoreworCQorICAgICAgICBpZiAoIXBrdF9kZXYtPnJ1bm5pbmcpIHsKKyAgICAgICAgICAgICAgICBwcmludGsoInBrdGdlbjogaW50ZXJmYWNlOiAlcyBpcyB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CisJCX0KKyAgICAgICAgICAgICAgICAKKwkJLyogRG9uZSB3aXRoIHRoaXMgKi8KKwkJcGt0Z2VuX3N0b3BfZGV2aWNlKHBrdF9kZXYpOworCX0gCisgb3V0OjsKKyB9CisKKy8qIAorICogTWFpbiBsb29wIG9mIHRoZSB0aHJlYWQgZ29lcyBoZXJlCisgKi8KKworc3RhdGljIHZvaWQgcGt0Z2VuX3RocmVhZF93b3JrZXIoc3RydWN0IHBrdGdlbl90aHJlYWQgKnQpIAoreworCURFRklORV9XQUlUKHdhaXQpOworICAgICAgICBzdHJ1Y3QgcGt0Z2VuX2RldiAqcGt0X2RldiA9IE5VTEw7CisJaW50IGNwdSA9IHQtPmNwdTsKKwlzaWdzZXRfdCB0bXBzaWc7CisJdTMyIG1heF9iZWZvcmVfc29mdGlycTsKKyAgICAgICAgdTMyIHR4X3NpbmNlX3NvZnRpcnEgPSAwOworCisJZGFlbW9uaXplKCJwa3RnZW4vJWQiLCBjcHUpOworCisgICAgICAgIC8qIEJsb2NrIGFsbCBzaWduYWxzIGV4Y2VwdCBTSUdLSUxMLCBTSUdTVE9QIGFuZCBTSUdURVJNICovCisKKyAgICAgICAgc3Bpbl9sb2NrX2lycSgmY3VycmVudC0+c2lnaGFuZC0+c2lnbG9jayk7CisgICAgICAgIHRtcHNpZyA9IGN1cnJlbnQtPmJsb2NrZWQ7CisgICAgICAgIHNpZ2luaXRzZXRpbnYoJmN1cnJlbnQtPmJsb2NrZWQsIAorICAgICAgICAgICAgICAgICAgICAgIHNpZ21hc2soU0lHS0lMTCkgfCAKKyAgICAgICAgICAgICAgICAgICAgICBzaWdtYXNrKFNJR1NUT1ApfCAKKyAgICAgICAgICAgICAgICAgICAgICBzaWdtYXNrKFNJR1RFUk0pKTsKKworICAgICAgICByZWNhbGNfc2lncGVuZGluZygpOworICAgICAgICBzcGluX3VubG9ja19pcnEoJmN1cnJlbnQtPnNpZ2hhbmQtPnNpZ2xvY2spOworCisJLyogTWlncmF0ZSB0byB0aGUgcmlnaHQgQ1BVICovCisJc2V0X2NwdXNfYWxsb3dlZChjdXJyZW50LCBjcHVtYXNrX29mX2NwdShjcHUpKTsKKyAgICAgICAgaWYgKHNtcF9wcm9jZXNzb3JfaWQoKSAhPSBjcHUpCisgICAgICAgICAgICAgICAgQlVHKCk7CisKKwlpbml0X3dhaXRxdWV1ZV9oZWFkKCZ0LT5xdWV1ZSk7CisKKwl0LT5jb250cm9sICY9IH4oVF9URVJNSU5BVEUpOworCXQtPmNvbnRyb2wgJj0gfihUX1JVTik7CisJdC0+Y29udHJvbCAmPSB+KFRfU1RPUCk7CisJdC0+Y29udHJvbCAmPSB+KFRfUkVNREVWKTsKKworICAgICAgICB0LT5waWQgPSBjdXJyZW50LT5waWQ7ICAgICAgICAKKworICAgICAgICBQR19ERUJVRyhwcmludGsoInBrdGdlbjogc3RhcnRpbmcgcGt0Z2VuLyVkOiAgcGlkPSVkXG4iLCBjcHUsIGN1cnJlbnQtPnBpZCkpOworCisJbWF4X2JlZm9yZV9zb2Z0aXJxID0gdC0+bWF4X2JlZm9yZV9zb2Z0aXJxOworICAgICAgICAKKyAgICAgICAgX19zZXRfY3VycmVudF9zdGF0ZShUQVNLX0lOVEVSUlVQVElCTEUpOworICAgICAgICBtYigpOworCisgICAgICAgIHdoaWxlICgxKSB7CisJCQorCQlfX3NldF9jdXJyZW50X3N0YXRlKFRBU0tfUlVOTklORyk7CisKKwkJLyoKKwkJICogR2V0IG5leHQgZGV2IHRvIHhtaXQgLS0gaWYgYW55LgorCQkgKi8KKworICAgICAgICAgICAgICAgIHBrdF9kZXYgPSBuZXh0X3RvX3J1bih0KTsKKyAgICAgICAgICAgICAgICAKKyAgICAgICAgICAgICAgICBpZiAocGt0X2RldikgeworCisJCQlwa3RnZW5feG1pdChwa3RfZGV2KTsKKworCQkJLyoKKwkJCSAqIFdlIGxpa2UgdG8gc3RheSBSVU5OSU5HIGJ1dCBtdXN0IGFsc28gZ2l2ZQorCQkJICogb3RoZXJzIGZhaXIgc2hhcmUuCisJCQkgKi8KKworCQkJdHhfc2luY2Vfc29mdGlycSArPSBwa3RfZGV2LT5sYXN0X29rOworCisJCQlpZiAodHhfc2luY2Vfc29mdGlycSA+IG1heF9iZWZvcmVfc29mdGlycSkgeworCQkJCWlmIChsb2NhbF9zb2Z0aXJxX3BlbmRpbmcoKSkKKwkJCQkJZG9fc29mdGlycSgpOworCQkJCXR4X3NpbmNlX3NvZnRpcnEgPSAwOworCQkJfQorCQl9IGVsc2UgeworCQkJcHJlcGFyZV90b193YWl0KCYodC0+cXVldWUpLCAmd2FpdCwgVEFTS19JTlRFUlJVUFRJQkxFKTsKKwkJCXNjaGVkdWxlX3RpbWVvdXQoSFovMTApOworCQkJZmluaXNoX3dhaXQoJih0LT5xdWV1ZSksICZ3YWl0KTsKKwkJfQorCisgICAgICAgICAgICAgICAgLyogCisJCSAqIEJhY2sgZnJvbSBzbGVlcCwgZWl0aGVyIGR1ZSB0byB0aGUgdGltZW91dCBvciBzaWduYWwuCisJCSAqIFdlIGNoZWNrIGlmIHdlIGhhdmUgYW55ICJwb3N0ZWQiIHdvcmsgZm9yIHVzLgorCQkgKi8KKworICAgICAgICAgICAgICAgIGlmICh0LT5jb250cm9sICYgVF9URVJNSU5BVEUgfHwgc2lnbmFsX3BlbmRpbmcoY3VycmVudCkpIAorICAgICAgICAgICAgICAgICAgICAgICAgLyogd2UgcmVjZWl2ZWQgYSByZXF1ZXN0IHRvIHRlcm1pbmF0ZSBvdXJzZWxmICovCisgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKKwkJCisKKwkJaWYodC0+Y29udHJvbCAmIFRfU1RPUCkgeworCQkJcGt0Z2VuX3N0b3AodCk7CisJCQl0LT5jb250cm9sICY9IH4oVF9TVE9QKTsKKwkJfQorCisJCWlmKHQtPmNvbnRyb2wgJiBUX1JVTikgeworCQkJcGt0Z2VuX3J1bih0KTsKKwkJCXQtPmNvbnRyb2wgJj0gfihUX1JVTik7CisJCX0KKworCQlpZih0LT5jb250cm9sICYgVF9SRU1ERVYpIHsKKwkJCXBrdGdlbl9yZW1fYWxsX2lmcyh0KTsKKwkJCXQtPmNvbnRyb2wgJj0gfihUX1JFTURFVik7CisJCX0KKworCQlpZiAobmVlZF9yZXNjaGVkKCkpIAorCQkJc2NoZWR1bGUoKTsKKyAgICAgICAgfSAKKworICAgICAgICBQR19ERUJVRyhwcmludGsoInBrdGdlbjogJXMgc3RvcHBpbmcgYWxsIGRldmljZVxuIiwgdC0+bmFtZSkpOworICAgICAgICBwa3RnZW5fc3RvcCh0KTsKKworICAgICAgICBQR19ERUJVRyhwcmludGsoInBrdGdlbjogJXMgcmVtb3ZpbmcgYWxsIGRldmljZVxuIiwgdC0+bmFtZSkpOworICAgICAgICBwa3RnZW5fcmVtX2FsbF9pZnModCk7CisKKyAgICAgICAgUEdfREVCVUcocHJpbnRrKCJwa3RnZW46ICVzIHJlbW92aW5nIHRocmVhZC5cbiIsIHQtPm5hbWUpKTsKKyAgICAgICAgcGt0Z2VuX3JlbV90aHJlYWQodCk7Cit9CisKK3N0YXRpYyBzdHJ1Y3QgcGt0Z2VuX2RldiAqcGt0Z2VuX2ZpbmRfZGV2KHN0cnVjdCBwa3RnZW5fdGhyZWFkICp0LCBjb25zdCBjaGFyKiBpZm5hbWUpIAoreworICAgICAgICBzdHJ1Y3QgcGt0Z2VuX2RldiAqcGt0X2RldiA9IE5VTEw7CisgICAgICAgIGlmX2xvY2sodCk7CisKKyAgICAgICAgZm9yKHBrdF9kZXY9dC0+aWZfbGlzdDsgcGt0X2RldjsgcGt0X2RldiA9IHBrdF9kZXYtPm5leHQgKSB7CisgICAgICAgICAgICAgICAgaWYgKHN0cmNtcChwa3RfZGV2LT5pZm5hbWUsIGlmbmFtZSkgPT0gMCkgeworICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgICAgfQorICAgICAgICB9CisKKyAgICAgICAgaWZfdW5sb2NrKHQpOworCVBHX0RFQlVHKHByaW50aygicGt0Z2VuOiBmaW5kX2RldiglcykgcmV0dXJuaW5nICVwXG4iLCBpZm5hbWUscGt0X2RldikpOworICAgICAgICByZXR1cm4gcGt0X2RldjsKK30KKworLyogCisgKiBBZGRzIGEgZGV2IGF0IGZyb250IG9mIGlmX2xpc3QuIAorICovCisKK3N0YXRpYyBpbnQgYWRkX2Rldl90b190aHJlYWQoc3RydWN0IHBrdGdlbl90aHJlYWQgKnQsIHN0cnVjdCBwa3RnZW5fZGV2ICpwa3RfZGV2KSAKK3sKKwlpbnQgcnYgPSAwOworCQorICAgICAgICBpZl9sb2NrKHQpOworCisgICAgICAgIGlmIChwa3RfZGV2LT5wZ190aHJlYWQpIHsKKyAgICAgICAgICAgICAgICBwcmludGsoInBrdGdlbjogRVJST1I6ICBhbHJlYWR5IGFzc2lnbmVkIHRvIGEgdGhyZWFkLlxuIik7CisgICAgICAgICAgICAgICAgcnYgPSAtRUJVU1k7CisgICAgICAgICAgICAgICAgZ290byBvdXQ7CisgICAgICAgIH0KKwlwa3RfZGV2LT5uZXh0ID10LT5pZl9saXN0OyB0LT5pZl9saXN0PXBrdF9kZXY7CisgICAgICAgIHBrdF9kZXYtPnBnX3RocmVhZCA9IHQ7CisJcGt0X2Rldi0+cnVubmluZyA9IDA7CisKKyBvdXQ6CisgICAgICAgIGlmX3VubG9jayh0KTsgICAgICAgIAorICAgICAgICByZXR1cm4gcnY7Cit9CisKKy8qIENhbGxlZCB1bmRlciB0aHJlYWQgbG9jayAqLworCitzdGF0aWMgaW50IHBrdGdlbl9hZGRfZGV2aWNlKHN0cnVjdCBwa3RnZW5fdGhyZWFkICp0LCBjb25zdCBjaGFyKiBpZm5hbWUpIAoreworICAgICAgICBzdHJ1Y3QgcGt0Z2VuX2RldiAqcGt0X2RldjsKKwkKKwkvKiBXZSBkb24ndCBhbGxvdyBhIGRldmljZSB0byBiZSBvbiBzZXZlcmFsIHRocmVhZHMgKi8KKworCWlmKCAocGt0X2RldiA9IF9fcGt0Z2VuX05OX3RocmV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ICAgICAgICAgcGt0X2Rldi0+dWRwX3NyY19taW4gPSA5OyAvKiBzaW5rIHBvcnQgKi8KKyAgICAgICAgICAgICAgICBwa3RfZGV2LT51ZHBfc3JjX21heCA9IDk7CisgICAgICAgICAgICAgICAgcGt0X2Rldi0+dWRwX2RzdF9taW4gPSA5OworICAgICAgICAgICAgICAgIHBrdF9kZXYtPnVkcF9kc3RfbWF4ID0gOTsKKworICAgICAgICAgICAgICAgIHN0cm5jcHkocGt0X2Rldi0+aWZuYW1lLCBpZm5hbWUsIDMxKTsKKyAgICAgICAgICAgICAgICBzcHJpbnRmKHBrdF9kZXYtPmZuYW1lLCAibmV0LyVzLyVzIiwgUEdfUFJPQ19ESVIsIGlmbmFtZSk7CisKKyAgICAgICAgICAgICAgICBpZiAoISBwa3RnZW5fc2V0dXBfZGV2KHBrdF9kZXYpKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBwcmludGsoInBrdGdlbjogRVJST1I6IHBrdGdlbl9zZXR1cF9kZXYgZmFpbGVkLlxuIik7CisJCQlpZiAocGt0X2Rldi0+Zmxvd3MpCisJCQkJdmZyZWUocGt0X2Rldi0+Zmxvd3MpOworICAgICAgICAgICAgICAgICAgICAgICAga2ZyZWUocGt0X2Rldik7CisgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gLUVOT0RFVjsKKyAgICAgICAgICAgICAgICB9CisKKyAgICAgICAgICAgICAgICBwa3RfZGV2LT5wcm9jX2VudCA9IGNyZWF0ZV9wcm9jX2VudHJ5KHBrdF9kZXYtPmZuYW1lLCAwNjAwLCBOVUxMKTsKKyAgICAgICAgICAgICAgICBpZiAoIXBrdF9kZXYtPnByb2NfZW50KSB7CisgICAgICAgICAgICAgICAgICAgICAgICBwcmludGsoInBrdGdlbjogY2Fubm90IGNyZWF0ZSAlcyBwcm9jZnMgZW50cnkuXG4iLCBwa3RfZGV2LT5mbmFtZSk7CisJCQlpZiAocGt0X2Rldi0+Zmxvd3MpCisJCQkJdmZyZWUocGt0X2Rldi0+Zmxvd3MpOworICAgICAgICAgICAgICAgICAgICAgICAga2ZyZWUocGt0X2Rldik7CisgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gLUVJTlZBTDsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgcGt0X2Rldi0+cHJvY19lbnQtPnJlYWRfcHJvYyA9IHByb2NfaWZfcmVhZDsKKyAgICAgICAgICAgICAgICBwa3RfZGV2LT5wcm9jX2VudC0+d3JpdGVfcHJvYyA9IHByb2NfaWZfd3JpdGU7CisgICAgICAgICAgICAgICAgcGt0X2Rldi0+cHJvY19lbnQtPmRhdGEgPSAodm9pZCopKHBrdF9kZXYpOworCQlwa3RfZGV2LT5wcm9jX2VudC0+b3duZXIgPSBUSElTX01PRFVMRTsKKworICAgICAgICAgICAgICAgIHJldHVybiBhZGRfZGV2X3RvX3RocmVhZCh0LCBwa3RfZGV2KTsKKyAgICAgICAgfQorICAgICAgICBlbHNlIHsKKyAgICAgICAgICAgICAgICBwcmludGsoInBrdGdlbjogRVJST1I6IGludGVyZmFjZSBhbHJlYWR5IHVzZWQuXG4iKTsKKyAgICAgICAgICAgICAgICByZXR1cm4gLUVCVVNZOworICAgICAgICB9Cit9CisKK3N0YXRpYyBzdHJ1Y3QgcGt0Z2VuX3RocmVhZCAqcGt0Z2VuX2ZpbmRfdGhyZWFkKGNvbnN0IGNoYXIqIG5hbWUpIAoreworICAgICAgICBzdHJ1Y3QgcGt0Z2VuX3RocmVhZCAqdCA9IE5VTEw7CisKKyAgICAgICB0aHJlYWRfbG9jaygpOworCisgICAgICAgIHQgPSBwa3RnZW5fdGhyZWFkczsKKyAgICAgICAgd2hpbGUgKHQpIHsKKyAgICAgICAgICAgICAgICBpZiAoc3RyY21wKHQtPm5hbWUsIG5hbWUpID09IDApIAorICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisKKyAgICAgICAgICAgICAgICB0ID0gdC0+bmV4dDsKKyAgICAgICAgfQorICAgICAgICB0aHJlYWRfdW5sb2NrKCk7CisgICAgICAgIHJldHVybiB0OworfQorCitzdGF0aWMgaW50IHBrdGdlbl9jcmVhdGVfdGhyZWFkKGNvbnN0IGNoYXIqIG5hbWUsIGludCBjcHUpIAoreworICAgICAgICBzdHJ1Y3QgcGt0Z2VuX3RocmVhZCAqdCA9IE5VTEw7CisKKyAgICAgICAgaWYgKHN0cmxlbihuYW1lKSA+IDMxKSB7CisgICAgICAgICAgICAgICAgcHJpbnRrKCJwa3RnZW46IEVSUk9SOiAgVGhyZWFkIG5hbWUgY2Fubm90IGJlIG1vcmUgdGhhbiAzMSBjaGFyYWN0ZXJzLlxuIik7CisgICAgICAgICAgICAgICAgcmV0dXJuIC1FSU5WQUw7CisgICAgICAgIH0KKyAgICAgICAgCisgICAgICAgIGlmIChwa3RnZW5fZmluZF90aHJlYWQobmFtZSkpIHsKKyAgICAgICAgICAgICAgICBwcmludGsoInBrdGdlbjogRVJST1I6IHRocmVhZDogJXMgYWxyZWFkeSBleGlzdHNcbiIsIG5hbWUpOworICAgICAgICAgICAgICAgIHJldHVybiAtRUlOVkFMOworICAgICAgICB9CisKKyAgICAgICAgdCA9IChzdHJ1Y3QgcGt0Z2VuX3RocmVhZCopKGttYWxsb2Moc2l6ZW9mKHN0cnVjdCBwa3RnZW5fdGhyZWFkKSwgR0ZQX0tFUk5FTCkpOworICAgICAgICBpZiAoIXQpIHsKKyAgICAgICAgICAgICAgICBwcmludGsoInBrdGdlbjogRVJST1I6IG91dCBvZiBtZW1vcnksIGNhbid0IGNyZWF0ZSBuZXcgdGhyZWFkLlxuIik7CisgICAgICAgICAgICAgICAgcmV0dXJuIC1FTk9NRU07CisgICAgICAgIH0KKworICAgICAgICBtZW1zZXQodCwgMCwgc2l6ZW9mKHN0cnVjdCBwa3RnZW5fdGhyZWFkKSk7CisgICAgICAgIHN0cmNweSh0LT5uYW1lLCBuYW1lKTsKKyAgICAgICAgc3Bpbl9sb2NrX2luaXQoJnQtPmlmX2xvY2spOworCXQtPmNwdSA9IGNwdTsKKyAgICAgICAgCisgICAgICAgIHNwcmludGYodC0+Zm5hbWUsICJuZXQvJXMvJXMiLCBQR19QUk9DX0RJUiwgdC0+bmFtZSk7CisgICAgICAgIHQtPnByb2NfZW50ID0gY3JlYXRlX3Byb2NfZW50cnkodC0+Zm5hbWUsIDA2MDAsIE5VTEwpOworICAgICAgICBpZiAoIXQtPnByb2NfZW50KSB7CisgICAgICAgICAgICAgICAgcHJpbnRrKCJwa3RnZW46IGNhbm5vdCBjcmVhdGUgJXMgcHJvY2ZzIGVudHJ5LlxuIiwgdC0+Zm5hbWUpOworICAgICAgICAgICAgICAgIGtmcmVlKHQpOworICAgICAgICAgICAgICAgIHJldHVybiAtRUlOVkFMOworICAgICAgICB9CisgICAgICAgIHQtPnByb2NfZW50LT5yZWFkX3Byb2MgPSBwcm9jX3RocmVhZF9yZWFkOworICAgICAgICB0LT5wcm9jX2VudC0+d3JpdGVfcHJvYyA9IHByb2NfdGhyZWFkX3dyaXRlOworICAgICAgICB0LT5wcm9jX2VudC0+ZGF0YSA9ICh2b2lkKikodCk7CisgICAgICAgIHQtPnByb2NfZW50LT5vd25lciA9IFRISVNfTU9EVUxFOworCisgICAgICAgIHQtPm5leHQgPSBwa3RnZW5fdGhyZWFkczsKKyAgICAgICAgcGt0Z2VuX3RocmVhZHMgPSB0OworCisJaWYgKGtlcm5lbF90aHJlYWQoKHZvaWQgKikgcGt0Z2VuX3RocmVhZF93b3JrZXIsICh2b2lkICopIHQsIAorCQkJICBDTE9ORV9GUyB8IENMT05FX0ZJTEVTIHwgQ0xPTkVfU0lHSEFORCkgPCAwKQorCQlwcmludGsoInBrdGdlbjoga2VybmVsX3RocmVhZCgpIGZhaWxlZCBmb3IgY3B1ICVkXG4iLCB0LT5jcHUpOworCisJcmV0dXJuIDA7Cit9CisKKy8qIAorICogUmVtb3ZlcyBhIGRldmljZSBmcm9tIHRoZSB0aHJlYWQgaWZfbGlzdC4gCisgKi8KK3N0YXRpYyB2b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JlYWQgaWZfbGlzdCAqLworCisJX3JlbV9kZXZfZnJvbV9pZl9saXN0KHQsIHBrdF9kZXYpOworCisgICAgICAgIC8qIENsZWFuIHVwIHByb2MgZmlsZSBzeXN0ZW0gKi8KKworICAgICAgICBpZiAoc3RybGVuKHBrdF9kZXYtPmZuYW1lKSkgCisgICAgICAgICAgICAgICAgcmVtb3ZlX3Byb2NfZW50cnkocGt0X2Rldi0+Zm5hbWUsIE5VTEwpOworCisJaWYgKHBrdF9kZXYtPmZsb3dzKQorCQl2ZnJlZShwa3RfZGV2LT5mbG93cyk7CisJa2ZyZWUocGt0X2Rldik7CisgICAgICAgIHJldHVybiAwOworfQorCitzdGF0aWMgaW50IF9faW5pdCBwZ19pbml0KHZvaWQpIAoreworCWludCBjcHU7CisJcHJpbnRrKHZlcnNpb24pOworCisgICAgICAgIG1vZHVsZV9mbmFtZVswXSA9IDA7CisKKwljcmVhdGVfcHJvY19kaXIoKTsKKworICAgICAgICBzcHJpbnRmKG1vZHVsZV9mbmFtZSwgIm5ldC8lcy9wZ2N0cmwiLCBQR19QUk9DX0RJUik7CisgICAgICAgIG1vZHVsZV9wcm9jX2VudCA9IGNyZWF0ZV9wcm9jX2VudHJ5KG1vZHVsZV9mbmFtZSwgMDYwMCwgTlVMTCk7CisgICAgICAgIGlmICghbW9kdWxlX3Byb2NfZW50KSB7CisgICAgICAgICAgICAgICAgcHJpbnRrKCJwa3RnZW46IEVSUk9SOiBjYW5ub3QgY3JlYXRlICVzIHByb2NmcyBlbnRyeS5cbiIsIG1vZHVsZV9mbmFtZSk7CisgICAgICAgICAgICAgICAgcmV0dXJuIC1FSU5WQUw7CisgICAgICAgIH0KKworICAgICAgICBtb2R1bGVfcHJvY19lbnQtPnByb2NfZm9wcyA9ICAmcGt0Z2VuX2ZvcHM7CisgICAgICAgIG1vZHVsZV9wcm9jX2VudC0+ZGF0YSA9IE5VTEw7CisKKwkvKiBSZWdpc3RlciB1cyB0byByZWNlaXZlIG5ldGRldmljZSBldmVudHMgKi8KKwlyZWdpc3Rlcl9uZXRkZXZpY2Vfbm90aWZpZXIoJnBrdGdlbl9ub3RpZmllcl9ibG9jayk7CisgICAgICAgIAorCWZvciAoY3B1ID0gMDsgY3B1IDwgTlJfQ1BVUyA7IGNwdSsrKSB7CisJCWNoYXIgYnVmWzMwXTsKKworCQlpZiAoIWNwdV9vbmxpbmUoY3B1KSkKKwkJCWNvbnRpbnVlOworCisgICAgICAgICAgICAgICAgc3ByaW50ZihidWYsICJrcGt0Z2VuZF8laSIsIGNwdSk7CisgICAgICAgICAgICAgICAgcGt0Z2VuX2NyZWF0ZV90aHJlYWQoYnVmLCBjcHUpOworICAgICAgICB9CisgICAgICAgIHJldHVybiAwOyAgICAgICAgCit9CisKK3N0YXRpYyB2b2lkIF9fZXhpdCBwZ19jbGVhbnVwKHZvaWQpCit7CisJd2FpdF9xdWV1ZV9oZWFkX3QgcXVldWU7CisJaW5pdF93YWl0cXVldWVfaGVhZCgmcXVldWUpOworCisgICAgICAgIC8qIFN0b3AgYWxsIGludGVyZmFjZXMgJiB0aHJlYWRzICovICAgICAgICAKKworICAgICAgICB3aGlsZSAocGt0Z2VuX3RocmVhZHMpIHsKKyAgICAgICAgICAgICAgICBzdHJ1Y3QgcGt0Z2VuX3RocmVhZCAqdCA9IHBrdGdlbl90aHJlYWRzOworICAgICAgICAgICAgICAgIHBrdGdlbl90aHJlYWRzLT5jb250cm9sIHw9IChUX1RFUk1JTkFURSk7CisKKwkJd2FpdF9ldmVudF9pbnRlcnJ1cHRpYmxlX3RpbWVvdXQocXVldWUsICh0ICE9IHBrdGdlbl90aHJlYWRzKSwgSFopOworICAgICAgICB9CisKKyAgICAgICAgLyogVW4tcmVnaXN0ZXIgdXMgZnJvbSByZWNlaXZpbmcgbmV0ZGV2aWNlIGV2ZW50cyAqLworCXVucmVnaXN0ZXJfbmV0ZGV2aWNlX25vdGlmaWVyKCZwa3RnZW5fbm90aWZpZXJfYmxvY2spOworCisgICAgICAgIC8qI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OVVgKKyAqICAgICAgICAgICAgICBvcGVyYXRpbmcgc3lzdGVtLiAgREVDbmV0IGlzIGltcGxlbWVudGVkIHVzaW5nIHRoZSAgQlNEIFNvY2tldAorICogICAgICAgICAgICAgIGludGVyZmFjZSBhcyB0aGUgbWVhbnMgb2YgY29tbXVuaWNhdGlvbiB3aXRoIHRoZSB1c2VyIGxldmVsLgorICoKKyAqICAgICAgICAgICAgICBERUNuZXQgU29ja2V0IExheWVyIEludGVyZmFjZQorICoKKyAqIEF1dGhvcnM6ICAgICBFZHVhcmRvIE1hcmNlbG8gU2VycmF0IDxlbXNlcnJhdEBnZW9jaXRpZXMuY29tPgorICogICAgICAgICAgICAgIFBhdHJpY2sgQ2F1bGZpZWxkIDxwYXRyaWNrQHBhbmRoLmRlbW9uLmNvLnVrPgorICoKKyAqIENoYW5nZXM6CisgKiAgICAgICAgU3RldmUgV2hpdGVob3VzZTogQ29waWVkIGZyb20gRWR1YXJkbyBTZXJyYXQgYW5kIFBhdHJpY2sgQ2F1bGZpZWxkJ3MKKyAqICAgICAgICAgICAgICAgICAgICAgICAgICB2ZXJzaW9uIG9mIHRoZSBjb2RlLiBPcmlnaW5hbCBjb3B5cmlnaHQgcHJlc2VydmVkCisgKiAgICAgICAgICAgICAgICAgICAgICAgICAgYmVsb3cuCisgKiAgICAgICAgU3RldmUgV2hpdGVob3VzZTogU29tZSBidWcgZml4ZXMsIGNsZWFuaW5nIHVwIHNvbWUgY29kZSB0byBtYWtlIGl0CisgKiAgICAgICAgICAgICAgICAgICAgICAgICAgY29tcGF0aWJsZSB3aXRoIG15IHJvdXRpbmcgbGF5ZXIuCisgKiAgICAgICAgU3RldmUgV2hpdGVob3VzZTogTWVyZ2luZyBjaGFuZ2VzIGZyb20gRWR1YXJkbyBTZXJyYXQgYW5kIFBhdHJpY2sKKyAqICAgICAgICAgICAgICAgICAgICAgICAgICBDYXVsZmllbGQuCisgKiAgICAgICAgU3RldmUgV2hpdGVob3VzZTogRnVydGhlciBidWc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5ldyBzb2NrZXQgbG9ja2luZworICogICAgICAgIFN0ZXZlIFdoaXRlaG91c2U6IFNvY2tldCBsaXN0IGhhc2hpbmcvbG9ja2luZworICogICAgICAgICBBcm5hbGRvIEMuIE1lbG86IHVzZSBjYXBhYmxlLCBub3Qgc3VzZXIKKyAqICAgICAgICBTdGV2ZSBXaGl0ZWhvdXNlOiBSZW1vdmVkIHVudXNlZCBjb2RlLiBGaXggdG8gdXNlIHNrLT5hbGxvY2F0aW9uCisgKiAgICAgICAgICAgICAgICAgICAgICAgICAgd2hlbiByZXF1aXJlZC4KKyAqICAgICAgIFBhdHJpY2sgQ2F1bGZpZWxkOiAvcHJvYy9uZXQvZGVjbmV0IG5vdyBoYXMgb2JqZWN0IG5hbWUvbnVtYmVyCisgKiAgICAgICAgU3RldmUgV2hpdGVob3VzZTogRml4ZWQgbG9jYWwgcG9ydCBhbGxvY2F0aW9uLCBoYXNoZWQgc2sgbGlzdAorICogICAgICAgICAgTWF0dGhldyBXaWxjb3g6IEZpeGVzIGZvciBkbl9pb2N0bCgpCisgKiAgICAgICAgU3RldmUgV2hpdGVob3VzZTogTmV3IGNvbm5lY3QvYWNjZXB0IGxvZ2ljIHRvIGFsbG93IHRpbWVvdXRzIGFuZAorICogICAgICAgICAgICAgICAgICAgICAgICAgIHByZXBhcmUgZm9yIHNlbmRwYWdlIGV0Yy4KKyAqLworCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyAgICAoYykgMTk5NS0xOTk4IEUuTS4gU2VycmF0CQllbXNlcnJhdEBnZW9jaXRpZXMuY29tCisgICAgCisgICAgVGhpcyBwcm9ncmFtIGlzIGZyZWUgc29mdHdhcmU7IHlvdSBjYW4gcmVkaXN0cmlidXRlIGl0IGFuZC9vciBtb2RpZnkKKyAgICBpdCB1bmRlciB0aGUgdGVybXMgb2YgdGhlIEdOVSBHZW5lcmFsIFB1Ymxp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RoLmRlbW9uLmNvLnVrKQorCisJCQkJCVBvcnQgdG8gbmV3IGtlcm5lbCBkZXZlbG9wbWVudCB2ZXJzaW9uLgorCitWZXJzaW9uIDAuMC4zICAgICAyLjEuMTA2ICAgMjUtanVuLTk4ICAgRWR1YXJkbyBNYXJjZWxvIFNlcnJhdAorCQkJCQkoZW1zZXJyYXRAZ2VvY2l0aWVzLmNvbSkKKwkJCQkJXworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEFkZGVkIHN1cHBvcnQgZm9yIGluY29taW5nIGNvbm5lY3Rpb25zCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc28gd2UgY2FuIHN0YXJ0IGRldmVsb3Bpbmcgc2VydmVyIGFwcHMKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvbiBMaW51eC4KKwkJCQkJLQorCQkJCQlNb2R1bGUgU3VwcG9ydAorVmVyc2lvbiAwLjAuNCAgICAgMi4xLjEwOSAgIDIxLWp1bC05OCAgIEVkdWFyZG8gTWFyY2VsbyBTZXJyYXQKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIChlbXNlcnJhdEBnZW9jaXRpZXMuY29tKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEFkZGVkIHN1cHBvcnQgZm9yIFgxMVI2LjQuIE5vdyB3ZSBjYW4gCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdXNlIERFQ25ldCB0cmFuc3BvcnQgZm9yIFggb24gTGludXghISEKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC0KK1ZlcnNpb24gMC4wLjUgICAgMi4xLjExMCAgIDAxLWF1Zy05OCAgIEVkdWFyZG8gTWFyY2VsbyBTZXJyYXQKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIChlbXNlcnJhdEBnZW9jaXRpZXMuY29tKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgUmVtb3ZlZCBidWdzIG9uIGZsb3cgY29udHJvbAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgUmVtb3ZlZCBidWdzIG9uIGluY29taW5nIGFjY2Vzc2RhdGEKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9yZGVyCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAtCitWZXJzaW9uIDAuMC42ICAgIDIuMS4xMTAgICAwNy1hdWctOTggICBFZHVhcmRvIE1hcmNlbG8gU2VycmF0CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkbl9yZWN2bXNnIGZpeGVzCisKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBQYXRyaWNrIEouIENhdWxmaWVsZAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZG5fYmluZCBmaXhlcworKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKworI2luY2x1ZGUgPGxpbnV4L2NvbmZpZy5oPgorI2luY2x1ZGUgPGxpbnV4L21vZHVsZS5oPgorI2luY2x1ZGUgPGxpbnV4L2Vycm5vLmg+CisjaW5jbHVkZSA8bGludXgvdHlwZXMuaD4KKyNpbmNsdWRlIDxsaW51eC9zbGFiLmg+CisjaW5jbHVkZSA8bGludXgvc29ja2V0Lmg+CisjaW5jbHVkZSA8bGludXgvaW4uaD4KKyNpbmNsdWRlIDxsaW51eC9rZXJuZWwuaD4KKyNpbmNsdWRlIDxsaW51eC9zY2hlZC5oPgorI2luY2x1ZGUgPGxpbnV4L3RpbWVyLmg+CisjaW5jbHVkZSA8bGludXgvc3RyaW5nLmg+CisjaW5jbHVkZSA8bGludXgvc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RkcikKK3sKKwlzdHJ1Y3QgaGxpc3RfaGVhZCAqbGlzdCA9IGxpc3Rlbl9oYXNoKGFkZHIpOworCXN0cnVjdCBobGlzdF9ub2RlICpub2RlOworCXN0cnVjdCBzb2NrICpzazsKKworCXJlYWRfbG9jaygmZG5faGFzaF9sb2NrKTsKKwlza19mb3JfZWFjaChzaywgbm9kZSwgbGlzdCkgeworCQlzdHJ1Y3QgZG5fc2NwICpzY3AgPSBETl9TSyhzayk7CisJCWlmIChzay0+c2tfc3RhdGUgIT0gVENQX0xJU1RFTikKKwkJCWNvbnRpbnVlOworCQlpZiAoc2NwLT5hZGRyLnNkbl9vYmpudW0pIHsKKwkJCWlmIChzY3AtPmFkZHIuc2RuX29iam51bSAhPSBhZGRyLT5zZG5fb2JqbnVtKQorCQkJCWNvbnRpbnVlOworCQl9IGVsc2UgeworCQkJaWYgKGFkZHItPnNkbl9vYmpudW0pCisJCQkJY29udGludWU7CisJCQlpZiAoc2NwLT5hZGRyLnNkbl9vYmpuYW1lbCAhPSBhZGRyLT5zZG5fb2JqbmFtZWwpCisJCQkJY29udGludWU7CisJCQlpZiAobWVtY21wKHNjcC0+YWRkci5zZG5fb2JqbmFtZSwgYWRkci0+c2RuX29iam5hbWUsIGRuX250b2hzKGFkZHItPnNkbl9vYmpuYW1lbCkpICE9IDApCisJCQkJY29udGludWU7CisJCX0KKwkJc29ja19ob2xkKHNrKTsKKwkJcmVhZF91bmxvY2soJmRuX2hhc2hfbG9jayk7CisJCXJldHVybiBzazsKKwl9CisKKwlzayA9IHNrX2hlYWQoJmRuX3dpbGRfc2spOworCWlmIChzaykgeworCSAgICAgICAJaWYgKHNrLT5za19zdGF0ZSA9PSBUQ1BfTElTVEVOKQorCQkJc29ja19ob2xkKHNrKTsKKwkJZWxzZQorCQkJc2sgPSBOVUxMOworCX0KKworCXJlYWRfdW5sb2NrKCZkbl9oYXNoX2xvY2spOworCXJldHVybiBzazsKK30KKworc3RydWN0IHNvY2sgKmRuX2Zpbm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isJCQlmb3IoOzspIHsKKwkJCQlpZiAoc2tiID09CisJCQkJICAgIChzdHJ1Y3Qgc2tfYnVmZiAqKSZzay0+c2tfcmVjZWl2ZV9xdWV1ZSkKKwkJCQkJYnJlYWs7CisJCQkJYW1vdW50ICs9IHNrYi0+bGVuOworCQkJCXNrYiA9IHNrYi0+bmV4dDsKKwkJCX0KKwkJfQorCQlyZWxlYXNlX3NvY2soc2spOworCQllcnIgPSBwdXRfdXNlcihhbW91bnQsIChpbnQgX191c2VyICopYXJnKTsKKwkJYnJlYWs7CisKKwlkZWZhdWx0OgorCQllcnIgPSBkZXZfaW9jdGwoY21kLCAodm9pZCBfX3VzZXIgKilhcmcpOworCQlicmVhazsKKwl9CisKKwlyZXR1cm4gZXJyOworfQorCitzdGF0aWMgaW50IGRuX2xpc3RlbihzdHJ1Y3Qgc29ja2V0ICpzb2NrLCBpbnQgYmFja2xvZykKK3sKKwlzdHJ1Y3Qgc29jayAqc2sgPSBzb2NrLT5zazsKKwlpbnQgZXJyID0gLUVJTlZBTDsKKworCWxvY2tfc29jayhzayk7CisKKwlpZiAoc29ja19mbGFnKHNrLCBTT0NLX1pBUFBFRCkpCisJCWdvdG8gb3V0OworCisJaWYgKChETl9TSyhzayktPnN0YXRlICE9IEROX08pIHx8IChzay0+c2tfc3RhdGUgPT0gVENQX0xJU1RFTikpCisJCWdvdG8gb3V0OworCisJc2stPnNrX21heF9hY2tfYmFja2xvZyA9IGJhY2tsb2c7CisJc2stPnNrX2Fja19iYWNrbG9nICAgICA9IDA7CisJc2stPnNrX3N0YXRlICAgICAgICAgICA9IFRDUF9MSVNURU47CisJZXJyICAgICAgICAgICAgICAgICA9IDA7CisJZG5fcmVoYXNoX3NvY2soc2spOworCitvdXQ6CisJcmVsZWFzZV9zb2NrKHNrKTsKKworICAgICAgICByZXR1cm4gZXJyOworfQorCisKK3N0YXRpYyBpbnQgZG5fc2h1dGRvd24oc3RydWN0IHNvY2tldCAqc29jaywgaW50IGhvdykKK3sKKwlzdHJ1Y3Qgc29jayAqc2sgPSBzb2NrLT5zazsKKwlzdHJ1Y3QgZG5fc2NwICpzY3AgPSBETl9TSyhzayk7CisJaW50IGVyciA9IC1FTk9UQ09OTjsKKworCWxvY2tfc29jayhzayk7CisKKwlpZiAoc29jay0+c3RhdGUgPT0gU1NfVU5DT05ORUNURUQpCisJCWdvdG8gb3V0OworCisJZXJyID0gMDsKKwlpZiAoc29jay0+c3RhdGUgPT0gU1NfRElTQ09OTkVDVElORykKKwkJZ290byBvdXQ7CisKKwllcnIgPSAtRUlOVkFMOworCWlmIChzY3AtPnN0YXRlID09IEROX08pCisJCWdvdG8gb3V0OworCisJaWYgKGhvdyAhPSBTSFVURE9XTl9NQVNLKQorCQlnb3RvIG91dDsKKworCXNrLT5za19zaHV0ZG93biA9IGhvdzsKKwlkbl9kZXN0cm95X3NvY2soc2spOworCWVyciA9IDA7CisKK291dDoKKwlyZWxlYXNlX3NvY2soc2spOworCisJcmV0dXJuIGVycjsKK30KKworc3RhdGljIGludCBkbl9zZXRzb2Nrb3B0KHN0cnVjdCBzb2NrZXQgKnNvY2ssIGludCBsZXZlbCwgaW50IG9wdG5hbWUsIGNoYXIgX191c2VyICpvcHR2YWwsIGludCBvcHRsZW4pCit7CisJc3RydWN0IHNvY2sgKnNrID0gc29jay0+c2s7CisJaW50IGVycjsKKworCWxvY2tfc29jayhzayk7CisJZXJyID0gX19kbl9zZXRzb2Nrb3B0KHNvY2ssIGxldmVsLCBvcHRuYW1lLCBvcHR2YWwsIG9wdGxlbiwgMCk7CisJcmVsZWFzZV9zb2NrKHNrKTsKKworCXJldHVybiBlcnI7Cit9CisKK3N0YXRpYyBpbnQgX19kbl9zZXRzb2Nrb3B0KHN0cnVjdCBzb2NrZXQgKnNvY2ssIGludCBsZXZlbCxpbnQgb3B0bmFtZSwgY2hhciBfX3VzZXIgKm9wdHZhbCwgaW50IG9wdGxlbiwgaW50IGZsYWdzKSAKK3sKKwlzdHJ1Y3QJc29jayAqc2sg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mlvcml0eQorCX0sCisJeworCQkuY3RsX25hbWUgPSBORVRfREVDTkVUX0NPTkZfREVWX1QyLAorCQkucHJvY25hbWUgPSAidDIiLAorCQkuZGF0YSA9ICh2b2lkICopRE5fREVWX1BBUk1TX09GRlNFVCh0MiksCisJCS5tYXhsZW4gPSBzaXplb2YoaW50KSwKKwkJLm1vZGUgPSAwNjQ0LAorCQkucHJvY19oYW5kbGVyID0gcHJvY19kb2ludHZlY19taW5tYXgsCisJCS5zdHJhdGVneSA9IHN5c2N0bF9pbnR2ZWMsCisJCS5leHRyYTEgPSAmbWluX3QyLAorCQkuZXh0cmEyID0gJm1heF90MgorCX0sCisJeworCQkuY3RsX25hbWUgPSBORVRfREVDTkVUX0NPTkZfREVWX1QzLAorCQkucHJvY25hbWUgPSAidDMiLAorCQkuZGF0YSA9ICh2b2lkICopRE5fREVWX1BBUk1TX09GRlNFVCh0MyksCisJCS5tYXhsZW4gPSBzaXplb2YoaW50KSwKKwkJLm1vZGUgPSAwNjQ0LAorCQkucHJvY19oYW5kbGVyID0gcHJvY19kb2ludHZlY19taW5tYXgsCisJCS5zdHJhdGVneSA9IHN5c2N0bF9pbnR2ZWMsCisJCS5leHRyYTEgPSAmbWluX3QzLAorCQkuZXh0cmEyID0gJm1heF90MworCX0sCisJezB9CisJfSwKKwl7eworCQkuY3RsX25hbWUgPSAwLCAKKwkJLnByb2NuYW1lID0gIiIsIAorCQkubW9kZSA9IDA1NTUsIAorCQkuY2hpbGQgPSBkbl9kZXZfc3lzY3RsLmRuX2Rldl92YXJzCisJfSwgezB9fSwKKwl7eworCQkuY3RsX25hbWUgPSBORVRfREVDTkVUX0NPTkYsCisJCS5wcm9jbmFtZSA9ICJjb25mIiwgCisJCS5tb2RlID0gMDU1NSwgCisJCS5jaGlsZCA9IGRuX2Rldl9zeXNjdGwuZG5fZGV2X2RldgorCX0sIHswfX0sCisJe3sKKwkJLmN0bF9uYW1lID0gTkVUX0RFQ05FVCwgCisJCS5wcm9jbmFtZS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dCBkbl9pZmFkZHIgKilwdHI7CisKKwlzd2l0Y2goZXZlbnQpIHsKKwkJY2FzZSBORVRERVZfVVA6CisJCQlkbl9maWJfYWRkX2lmYWRkcihpZmEpOworCQkJZG5fZmliX3N5bmNfdXAoaWZhLT5pZmFfZGV2LT5kZXYpOworCQkJZG5fcnRfY2FjaGVfZmx1c2goLTEpOworCQkJYnJlYWs7CisJCWNhc2UgTkVUREVWX0RPV046CisJCQlkbl9maWJfZGVsX2lmYWRkcihpZmEpOworCQkJaWYgKGlmYS0+aWZhX2RldiAmJiBpZmEtPmlmYV9kZXYtPmlmYV9saXN0ID09IE5VTEwpIHsKKwkJCQlkbl9maWJfZGlzYWJsZV9hZGRyKGlmYS0+aWZhX2Rldi0+ZGV2LCAxKTsKKwkJCX0gZWxzZSB7CisJCQkJZG5fcnRfY2FjaGVfZmx1c2goLTEpOworCQkJfQorCQkJYnJlYWs7CisJfQorCXJldHVybiBOT1RJRllfRE9ORTsKK30KKworaW50IGRuX2ZpYl9zeW5jX2Rvd24oZG5fYWRkcmVzcyBsb2NhbCwgc3RydWN0IG5ldF9kZXZpY2UgKmRldiwgaW50IGZvcmNlKQoreworICAgICAgICBpbnQgcmV0ID0gMDsKKyAgICAgICAgaW50IHNjb3BlID0gUlRfU0NPUEVfTk9XSEVSRTsKKworICAgICAgICBpZiAoZm9yY2UpCisgICAgICAgICAgICAgICAgc2NvcGUgPSAtMTsKKworICAgICAgICBmb3JfZmliX2luZm8oKSB7CisgICAgICAgICAgICAgICAgLyogCisgICAgICAgICAgICAgICAgICogVGhpcyBtYWtlcyBubyBzZW5zZSBmb3IgREVDbmV0Li4uLiB3ZSB3aWxsIGFsbW9zdAorICAgICAgICAgICAgICAgICAqIGNlcnRhaW5seSBoYXZlIG1vcmUgdGhhbiBvbmUgbG9jYWwgYWRkcmVzcyB0aGUgc2FtZQorICAgICAgICAgICAgICAgICAqIG92ZXIgYWxsIG91ciBpbnRlcmZhY2VzLiBJdCBuZWVkcyB0aGlua2luZyBhYm91dAorICAgICAgICAgICAgICAgICAqIHNvbWUgbW9yZS4KKyAgICAgICAgICAgICAgICAgKi8KKyAgICAgICAgICAgICAgICBpZiAobG9jYWwgJiYgZmktPmZpYl9wcmVmc3JjID09IGxvY2FsKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBmaS0+ZmliX2ZsYWdzIHw9IFJUTkhfRl9ERUFEOworICAgICAgICAgICAgICAgICAgICAgICAgcmV0Kys7CisgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChkZXYgJiYgZmktPmZpYl9uaHMpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIGludCBkZWFkID0gMDsKKworICAgICAgICAgICAgICAgICAgICAgICAgY2hhbmdlX25leHRob3BzKGZpKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChuaC0+bmhfZmxhZ3MmUlROSF9GX0RFQUQpCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVhZCsrOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbHNlIGlmIChuaC0+bmhfZGV2ID09IGRldiAmJgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmgtPm5oX3Njb3BlICE9IHNjb3BlKSB7CisJCQkJCXNwaW5fbG9ja19iaCgmZG5fZmliX211bHRpcGF0aF9sb2NrKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuaC0+bmhfZmxhZ3MgfD0gUlROSF9GX0RFQUQ7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZmktPmZpYl9wb3dlciAtPSBuaC0+bmhfcG93ZXI7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmgtPm5oX3Bvd2VyID0gMDsKKwkJCQkJc3Bpbl91bmxvY2tfYmgoJmRuX2ZpYl9tdWx0aXBhdGhfbG9jayk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVhZCsrOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgICAgICB9IGVuZGZvcl9uZXh0aG9wcyhmaSkKKyAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkZWFkID09IGZpLT5maWJfbmhzKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZpLT5maWJfZmxhZ3MgfD0gUlROSF9GX0RFQUQ7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldCsrOworICAgICAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIH0KKyAgICAgICAgfSBlbmRmb3JfZmliX2luZm8oKTsKKyAgICAgICAgcmV0dXJuIHJldDsKK30KKworCitpbnQgZG5fZmliX3N5bmNfdXAoc3RydWN0IG5ldF9kZXZpY2UgKmRldikKK3sKKyAgICAgICAgaW50IHJldCA9IDA7CisKKyAgICAgICAgaWYgKCEoZGV2LT5mbGFncyZJRkZfVVApKQorICAgICAgICAgICAgICAgIHJldHVybiAwOworCisgICAgICAgIGZvcl9maWJfaW5mbygpIHsKKyAgICAgICAgICAgICAgICBpbnQgYWxpdmUgPSAwOworCisgICAgICAgICAgICAgICAgY2hhbmdlX25leHRob3BzKGZpKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIShuaC0+bmhfZmxhZ3MmUlROSF9GX0RFQUQpKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFsaXZlKys7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOworICAgICAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG5oLT5uaF9kZXYgPT0gTlVMTCB8fCAhKG5oLT5uaF9kZXYtPmZsYWdzJklGRl9VUCkpCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOworICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG5oLT5uaF9kZXYgIT0gZGV2IHx8IGRldi0+ZG5fcHRyID09IE5VTEwpCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOworICAgICAgICAgICAgICAgICAgICAgICAgYWxpdmUrKzsKKwkJCXNwaW5fbG9ja19iaCgmZG5fZmliX211bHRpcGF0aF9sb2NrKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIG5oLT5uaF9wb3dlciA9IDA7CisgICAgICAgICAgICAgICAgICAgICAgICBuaC0+bmhfZmxhZ3MgJj0gflJUTkhfRl9ERUFEOworCQkJc3Bpbl91bmxvY2tfYmgoJmRuX2ZpYl9tdWx0aXBhdGhfbG9jayk7CisgICAgICAgICAgICAgICAgfSBlbmRmb3JfbmV4dGhvcHMoZmkpOworCisgICAgICAgICAgICAgICAgaWYgKGFsaXZlID4gMCkgeworICAgICAgICAgICAgICAgICAgICAgICAgZmktPmZpYl9mbGFncyAmPSB+UlROSF9GX0RFQUQ7CisgICAgICAgICAgICAgICAgICAgICAgICByZXQrKzsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgIH0gZW5kZm9yX2ZpYl9pbmZvKCk7CisgICAgICAgIHJldHVybiByZXQ7Cit9CisKK3ZvaWQgZG5fZmliX2ZsdXNoKHZvaWQpCit7CisgICAgICAgIGludCBmbHVzaGVkID0gMDsKKyAgICAgICAgc3RydWN0IGRuX2ZpYl90YWJsZSAqdGI7CisgICAgICAgIGludCBpZDsKKworICAgICAgICBmb3IoaWQgPSBSVF9UQUJMRV9NQVg7IGlkID4gMDsgaWQtLSkgeworICAgICAgICAgICAgICAgIGlmICgodGIgPSBkbl9maWJfZ2V0X3RhYmxlKGlkLCAwKSkgPT0gTlVMTCkKKyAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOworICAgICAgICAgICAgICAgIGZsdXNoZWQgKz0gdGItPmZsdXNoKHRiKTsKKyAgICAgICAgfQorCisgICAgICAgIGlmIChmbHVzaGVkKQorICAgICAg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ZXIgbGV2ZWwuCisgKgorICogICAgICAgICAgICAgIERFQ25ldCBOZWlnaGJvdXIgRnVuY3Rpb25zIChBZGphY2VuY3kgRGF0YWJhc2UgYW5kIAorICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIE9uLUV0aGVybmV0IENhY2hlKQorICoKKyAqIEF1dGhvcjogICAgICBTdGV2ZSBXaGl0ZWhvdXNlIDxTdGV2ZVdAQUNNLm9yZz4KKyAqCisgKgorICogQ2hhbmdlczoKKyAqICAgICBTdGV2ZSBXaGl0ZWhvdXNlICAgICA6IEZpeGVkIHJvdXRlciBsaXN0aW5nIHJvdXRpbmUKKyAqICAgICBTdGV2ZSBXaGl0ZWhvdXNlICAgICA6IEFkZGVkIGVycm9yX3JlcG9ydCBmdW5jdGlvbnMKKyAqICAgICBTdGV2ZSBXaGl0ZWhvdXNlICAgICA6IEFkZGVkIGRlZmF1bHQgcm91dGVyIGRldGVjdGlvbgorICogICAgIFN0ZXZlIFdoaXRlaG91c2UgICAgIDogSG9wIGNvdW50cyBpbiBvdXRnb2luZyBtZXNzYWdlcworICogICAgIFN0ZXZlIFdoaXRlaG91c2UgICAgIDogRml4ZWQgc3JjL2RzdCBpbiBvdXRnb2luZyBtZXNzYWdlcyBzbworICogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yd2FyZGluZyBub3cgc3RhbmRzIGEgZ29vZCBjaGFuY2Ugb2YKKyAqICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdvcmtpbmcuCisgKiAgICAgU3RldmUgV2hpdGVob3VzZSAgICAgOiBGaXhlZCBuZWlnaGJvdXIgc3RhdGVzIChmb3Igbm93IGFueXdheSkuCisgKiAgICAgU3RldmUgV2hpdGVob3VzZSAgICAgOiBNYWRlIGVycm9yX3JlcG9ydCBmdW5jdGlvbnMgZHVtbWllcy4gVGhpcworICogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXMgbm90IHRoZSByaWdodCBwbGFj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AyOworCXN0cnVjdCBkbl9zaG9ydF9wYWNrZXQgKnNwOworCXVuc2lnbmVkIGNoYXIgKmRhdGE7CisJc3RydWN0IGRuX3NrYl9jYiAqY2IgPSBETl9TS0JfQ0Ioc2tiKTsKKworCisgICAgICAgIGlmIChza2JfaGVhZHJvb20oc2tiKSA8IGhlYWRyb29tKSB7CisgICAgICAgICAgICAgICAgc3RydWN0IHNrX2J1ZmYgKnNrYjIgPSBza2JfcmVhbGxvY19oZWFkcm9vbShza2IsIGhlYWRyb29tKTsKKyAgICAgICAgICAgICAgICBpZiAoc2tiMiA9PSBOVUxMKSB7CisJCQlpZiAobmV0X3JhdGVsaW1pdCgpKQorICAgICAgICAgICAgICAgICAgICAgICAgCXByaW50ayhLRVJOX0NSSVQgImRuX3Nob3J0X291dHB1dDogbm8gbWVtb3J5XG4iKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGtmcmVlX3NrYihza2IpOworICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIC1FTk9CVUZTOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBrZnJlZV9za2Ioc2tiKTsKKyAgICAgICAgICAgICAgICBza2IgPSBza2IyOworCQlpZiAobmV0X3JhdGVsaW1pdCgpKQorICAgICAgICAgICAgICAgIAlwcmludGsoS0VSTl9JTkZPICJkbl9zaG9ydF9vdXRwdXQ6IEluY3JlYXNpbmcgaGVhZHJvb21cbiIpOworICAgICAgICB9CisKKwlkYXRhID0gc2tiX3B1c2goc2tiLCBzaXplb2Yoc3RydWN0IGRuX3Nob3J0X3BhY2tldCkgKyAyKTsKKwkqKCh1bnNpZ25lZCBzaG9ydCAqKWRhdGEpID0gZG5faHRvbnMoc2tiLT5sZW4gLSAyKTsKKwlzcCA9IChzdHJ1Y3QgZG5fc2hvcnRfcGFja2V0ICopKGRhdGErMik7CisKKwlzcC0+bXNnZmxnICAgICA9IEROX1JUX1BLVF9TSE9SVHwoY2ItPnJ0X2ZsYWdzJihETl9SVF9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c29ja2V0cyBpbnRvIFJVTiB3aGVuIGFja3MgYXJlCisgKiAgICAgICAgICAgICAgICAgICAgICAgcmVjZWl2ZWQuCisgKiAgICBTdGV2ZSBXaGl0ZWhvdXNlOgorICogICBQYXRyaWNrIENhdWxmaWVsZDogIENoZWNraW5nIGNvbm5pbml0cyBmb3IgY29ycmVjdG5lc3MgJiBzZW5kaW5nIG9mIGVycm9yCisgKiAgICAgICAgICAgICAgICAgICAgICAgcmVzcG9uc2VzLgorICogICAgU3RldmUgV2hpdGVob3VzZTogIEFkZGVkIGJhY2tsb2cgY29uZ2VzdGlvbiBsZXZlbCByZXR1cm4gY29kZXMuCisgKiAgIFBhdHJpY2sgQ2F1bGZpZWxkOgorICogICAgU3RldmUgV2hpdGVob3VzZTogIEFkZGVkIGZsb3cgY29udHJvbCBzdXBwb3J0IChvdXRib3VuZCkKKyAqICAgIFN0ZXZlIFdoaXRlaG91c2U6ICBQcmVwYXJlIGZvciBub25saW5lYXIgc2ticworICovCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyAgICAoYykgMTk5NS0xOTk4IEUuTS4gU2VycmF0CQllbXNlcnJhdEBnZW9jaXRpZXMuY29tCisgICAgCisgICAgVGhpcyBwcm9ncmFtIGlzIGZyZWUgc29mdHdhcmU7IHlvdSBjYW4gcmVkaXN0cmlidXRlIGl0IGFuZC9vciBtb2RpZnkKKyAgICBpdCB1bmRlciB0aGUgdGVybXMgb2YgdGhlIEdOVSBHZW5lcmFsIFB1YmxpYyBMaWNlbnNlIGFzIHB1Ymxpc2hlZCBieQorICAgIHRoZSBGcmVlIFNvZnR3YXJlIEZvdW5kYXRpb247IGVpdGhlciB2ZXJzaW9uIDIgb2YgdGhlIExpY2Vuc2UsIG9yCisgICAgYW55IGxhdGVyIHZlcnNpb24uCisKKyAgICBUaGlzIHByb2dyYW0gaXMgZGlzdHJpYnV0ZWQgaW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c29jayAqc2ssIHN0cnVjdCBza19idWZmICpza2IsIGludCBzaWcsIHN0cnVjdCBza19idWZmX2hlYWQgKnF1ZXVlKQoreworCWludCBlcnI7CisJCisgICAgICAgIC8qIENhc3Qgc2tiLT5yY3ZidWYgdG8gdW5zaWduZWQuLi4gSXQncyBwb2ludGxlc3MsIGJ1dCByZWR1Y2VzCisgICAgICAgICAgIG51bWJlciBvZiB3YXJuaW5ncyB3aGVuIGNvbXBpbGluZyB3aXRoIC1XIC0tQU5LCisgICAgICAgICAqLworICAgICAgICBpZiAoYXRvbWljX3JlYWQoJnNrLT5za19ybWVtX2FsbG9jKSArIHNrYi0+dHJ1ZXNpemUgPj0KKwkgICAgKHVuc2lnbmVkKXNrLT5za19yY3ZidWYpIHsKKyAgICAgICAgCWVyciA9IC1FTk9NRU07CisgICAgICAgIAlnb3RvIG91dDsKKyAgICAgICAgfQorCisJZXJyID0gc2tfZmlsdGVyKHNrLCBza2IsIDApOworCWlmIChlcnIpCisJCWdvdG8gb3V0OworCisgICAgICAgIHNrYl9zZXRfb3duZXJfcihza2IsIHNrKTsKKyAgICAgICAgc2tiX3F1ZXVlX3RhaWwocXVldWUsIHNrYik7CisKKwkvKiBUaGlzIGNvZGUgb25seSBydW5zIGZyb20gQkggb3IgQkggcHJvdGVjdGVkIGNvbnRleHQuCisJICogVGhlcmVmb3JlIHRoZSBwbGFpbiByZWFkX2xvY2sgaXMgb2sgaGVyZS4gLURhdmVNCisJICovCisJcmVhZF9sb2NrKCZzay0+c2tfY2FsbGJhY2tfbG9jayk7CisgICAgICAgIGlmICghc29ja19mbGFnKHNrLCBTT0NLX0RFQUQpKSB7CisJCXN0cnVjdCBzb2NrZXQgKnNvY2sgPSBzay0+c2tfc29ja2V0OworCQl3YWtlX3VwX2ludGVycnVwdGlibGUoc2stPnNrX3NsZWVwKTsKKwkJaWYgKHNvY2sgJiYgc29jay0+ZmFzeW5jX2xpc3QgJiYKKwkJICAgICF0ZXN0X2JpdChTT0NLX0FTW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fZXJybm8odGltZW8pOworCQkJYnJlYWs7CisJCX0KKworCQlpZiAoc2stPnNrX3NodXRkb3duICYgU0VORF9TSFVURE9XTikgeworCQkJKmVyciA9IEVJTlZBTDsKKwkJCWJyZWFrOworCQl9CisKKwkJaWYgKHNrLT5za19lcnIpCisJCQlicmVhazsKKworCQlsZW4gPSAqc2l6ZSArIDExOworCQlzcGFjZSA9IHNrLT5za19zbmRidWYgLSBhdG9taWNfcmVhZCgmc2stPnNrX3dtZW1fYWxsb2MpOworCisJCWlmIChzcGFjZSA8IGxlbikgeworCQkJaWYgKChzay0+c2tfc29ja2V0LT50eXBlID09IFNPQ0tfU1RSRUFNKSAmJgorCQkJICAgIChzcGFjZSA+PSAoMTYgKyAxMSkpKQorCQkJCWxlbiA9IHNwYWNlOworCQl9CisKKwkJaWYgKHNwYWNlIDwgbGVuKSB7CisJCQlzZXRfYml0KFNPQ0tfQVNZTkNfTk9TUEFDRSwgJnNrLT5za19zb2NrZXQtPmZsYWdzKTsKKwkJCWlmIChub2Jsb2NrKSB7CisJCQkJKmVyciA9IEVXT1VMREJMT0NLOworCQkJCWJyZWFrOworCQkJfQorCisJCQljbGVhcl9iaXQoU09DS19BU1lOQ19XQUlUREFUQSwgJnNrLT5za19zb2NrZXQtPmZsYWdzKTsKKwkJCVNPQ0tfU0xFRVBfUFJFKHNrKQorCisJCQlpZiAoKHNrLT5za19zbmRidWYgLSBhdG9taWNfcmVhZCgmc2stPnNrX3dtZW1fYWxsb2MpKSA8CisJCQkgICAgbGVuKQorCQkJCXNjaGVkdWxlKCk7CisKKwkJCVNPQ0tfU0xFRVBfUE9TVChzaykKKwkJCWNvbnRpbnVlOworCQl9CisKKwkJaWYgKChza2IgPSBkbl9hbGxvY19za2Ioc2ssIGxlbiwgc2stPnNrX2FsbG9jYXRpb24pKSA9PSBOVUxMKQorCQkJY29udGludWU7CisKKwkJKnNpemUgPSBsZW4gLSAxMTsKKwl9CisKKwlyZXR1cm4gc2tiOworfQorCisvKgorIC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MSU5VWAorICogICAgICAgICAgICAgIG9wZXJhdGluZyBzeXN0ZW0uICBERUNuZXQgaXMgaW1wbGVtZW50ZWQgdXNpbmcgdGhlICBCU0QgU29ja2V0CisgKiAgICAgICAgICAgICAgaW50ZXJmYWNlIGFzIHRoZSBtZWFucyBvZiBjb21tdW5pY2F0aW9uIHdpdGggdGhlIHVzZXIgbGV2ZWwuCisgKgorICogICAgICAgICAgICAgIERFQ25ldCBSb3V0aW5nIEZ1bmN0aW9ucyAoRW5kbm9kZSBhbmQgUm91dGVyKQorICoKKyAqIEF1dGhvcnM6ICAgICBTdGV2ZSBXaGl0ZWhvdXNlIDxTdGV2ZVdAQUNNLm9yZz4KKyAqICAgICAgICAgICAgICBFZHVhcmRvIE1hcmNlbG8gU2VycmF0IDxlbXNlcnJhdEBnZW9jaXRpZXMuY29tPgorICoKKyAqIENoYW5nZXM6CisgKiAgICAgICAgICAgICAgU3RldmUgV2hpdGVob3VzZSA6IEZpeGVzIHRvIGFsbG93ICJpbnRyYS1ldGhlcm5ldCIgYW5kCisgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICJyZXR1cm4tdG8tc2VuZGVyIiBiaXRzIG9uIG91dGdvaW5nCisgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhY2tldHMuCisgKgkJU3RldmUgV2hpdGVob3VzZSA6IFRpbWVvdXRzIGZvciBjYWNoZWQgcm91dGVzLgorICogICAgICAgICAgICAgIFN0ZXZlIFdoaXRlaG91c2UgOiBVc2UgZHN0IGNhY2hlIGZvciBpbnB1dCByb3V0ZXMgdG9vLgorICogICAgICAgICAgICAgIFN0ZXZlIFdoaXRlaG91c2UgOiBGaXhlZCBlcnJvciB2YWx1ZXMgaW4gZG5fc2VuZF9za2IuCisgKiAgICAgICAgICAgICAgU3RldmUgV2hpdGVob3VzZSA6IFJld29yayByb3V0aW5nIGZ1bmN0aW9ucyB0byBiZXR0ZXIgZml0CisgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIERFQ25ldCByb3V0aW5nIGRlc2lnbgorICogICAgICAgICAgICAgIEFsZXhleSBLdXpuZXRzb3YgOiBOZXcgU01QIGxvY2tpbmcKKyAqICAgICAgICAgICAgICBTdGV2ZSBXaGl0ZWhvdXNlIDogTW9yZSBTTVAgbG9ja2luZyBjaGFuZ2VzICYgZG5fY2FjaGVfZHVtcCgpCisgKiAgICAgICAgICAgICAgU3RldmUgV2hpdGVob3VzZSA6IFByZXJvdXRpbmcgTkYgaG9vaywgbm93IHJlYWxseSBpcyBwcmVyb3V0aW5nLgorICoJCQkJICAgRml4ZWQgcG9zc2libGUgc2tiIGxlYWsgaW4gcnRuZXRsaW5rIGZ1bmNzLgorICogICAgICAgICAgICAgIFN0ZXZlIFdoaXRlaG91c2UgOiBEYXZlIE1pbGxlcidzIGR5bmFtaWMgaGFzaCB0YWJsZSBzaXppbmcgYW5kCisgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEFsZXhleSBLdXpuZXRzb3YncyBmaW5lciBncmFpbmVkIGxvY2tpbmcKKyAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZnJvbSBpcHY0L3JvdXRlLmMuCisgKiAgICAgICAgICAgICAgU3RldmUgV2hpdGVob3VzZSA6IFJvdXRpbmcgaXMgbm93IHN0YXJ0aW5nIHRvIGxvb2sgbGlrZSBhCisgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbnNpYmxlIHNldCBvZiBjb2RlIG5vdywgbWFpbmx5IGR1ZSB0bworICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBteSBjb3B5aW5nIHRoZSBJUHY0IHJvdXRpbmcgY29kZS4gVGhlCisgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhvb2tzIGhlcmUgYXJlIG1vZGlmaWVkIGFuZCB3aWxsIGNvbnRpbnVlCisgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRvIGV2b2x2ZSBmb3IgYSB3aGlsZS4KKyAqICAgICAgICAgICAgICBTdGV2ZSBXaGl0ZWhvdXNlIDogUmVhbCBTTVAgYXQgbGFzdCA6LSkgQWxzbyBuZXcgbmV0ZmlsdGVyCisgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0dWZmLiBMb29rIG91dCByYXcgc29ja2V0cyB5b3VyIGRheXMKKyAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXJlIG51bWJlcmVkIQorICogICAgICAgICAgICAgIFN0ZXZlIFdoaXRlaG91c2UgOiBBZGRlZCByZXR1cm4tdG8tc2VuZGVyIGZ1bmN0aW9ucy4gQWRkZWQKKyAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYmFja2xvZyBjb25nZXN0aW9uIGxldmVsIHJldHVybiBjb2Rlcy4KKyAqCQlTdGV2ZSBXaGl0ZWhvdXNlIDogRml4ZWQgYnVnIHdoZXJlIHJvdXRlcyB3ZXJlIHNldCB1cCB3aXRoCisgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5vIHJlZiBjb3VudCBvbiBuZXQgZGV2aWNlcy4KKyAqICAgICAgICAgICAgICBTdGV2ZSBXaGl0ZWhvdXNlIDogUkNVIGZvciB0aGUgcm91dGUgY2FjaGUKKyAqICAgICAgICAgICAgICBTdGV2ZSBXaGl0ZWhvdXNlIDogUHJlcGFyYXRpb25zIGZvciB0aGUgZmxvdyBjYWNoZQorICogICAgICAgICAgICAgIFN0ZXZlIFdoaXRlaG91c2UgOiBQcmVwYXJlIGZvciBub25saW5lYXIgc2ticworICovCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyAgICAoYykgMTk5NS0xOTk4IEUuTS4gU2VycmF0CQllbXNlcnJhdEBnZW9jaXRpZXMuY29tCisgICAgCisgICAgVGhpcyBwcm9ncmFtIGlzIGZyZWUgc29mdHdh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pbnQgZG5fcm91dGVfcnhfbG9uZyhzdHJ1Y3Qgc2tfYnVmZiAqc2tiKQoreworCXN0cnVjdCBkbl9za2JfY2IgKmNiID0gRE5fU0tCX0NCKHNrYik7CisJdW5zaWduZWQgY2hhciAqcHRyID0gc2tiLT5kYXRhOworCisJaWYgKCFwc2tiX21heV9wdWxsKHNrYiwgMjEpKSAvKiAyMCBmb3IgbG9uZyBoZWFkZXIsIDEgZm9yIHNob3J0ZXN0IG5zcCAqLworCQlnb3RvIGRyb3BfaXQ7CisKKwlza2JfcHVsbChza2IsIDIwKTsKKwlza2ItPmgucmF3ID0gc2tiLT5kYXRhOworCisgICAgICAgIC8qIERlc3RpbmF0aW9uIGluZm8gKi8KKyAgICAgICAgcHRyICs9IDI7CisJY2ItPmRzdCA9IGRuX2h0b25zKGRuX2V0aDJkbihwdHIpKTsKKyAgICAgICAgaWYgKG1lbWNtcChwdHIsIGRuX2hpb3JkX2FkZHIsIDQpICE9IDApCisgICAgICAgICAgICAgICAgZ290byBkcm9wX2l0OworICAgICAgICBwdHIgKz0gNjsKKworCisgICAgICAgIC8qIFNvdXJjZSBpbmZvICovCisgICAgICAgIHB0ciArPSAyOworCWNiLT5zcmMgPSBkbl9odG9ucyhkbl9ldGgyZG4ocHRyKSk7CisgICAgICAgIGlmIChtZW1jbXAocHRyLCBkbl9oaW9yZF9hZGRyLCA0KSAhPSAwKQorICAgICAgICAgICAgICAgIGdvdG8gZHJvcF9pdDsKKyAgICAgICAgcHRyICs9IDY7CisgICAgICAgIC8qIE90aGVyIGp1bmsgKi8KKyAgICAgICAgcHRyKys7CisgICAgICAgIGNiLT5ob3BzID0gKnB0cisrOyAvKiBWaXNpdCBDb3VudCAqLworCisJcmV0dXJuIE5GX0hPT0soUEZfREVDbmV0LCBORl9ETl9QUkVfUk9VVElORywgc2tiLCBza2ItPmRldiwgTlVMTCwgZG5fcm91dGVfcnhfcGFja2V0KTsKKworZHJvcF9pdDoKKwlrZnJlZV9za2Ioc2tiKT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290byBkdW1wX2l0OworCisJCXN3aXRjaChmbGFncyAmIEROX1JUX0NOVExfTVNLKSB7CisgICAgICAgICAgICAgICAgCWNhc2UgRE5fUlRfUEtUX0hFTE86CisJCQkJcmV0dXJuIE5GX0hPT0soUEZfREVDbmV0LCBORl9ETl9IRUxMTywgc2tiLCBza2ItPmRldiwgTlVMTCwgZG5fcm91dGVfcHRwX2hlbGxvKTsKKworICAgICAgICAgICAgICAgIAljYXNlIEROX1JUX1BLVF9MMVJUOgorICAgICAgICAgICAgICAgIAljYXNlIEROX1JUX1BLVF9MMlJUOgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gTkZfSE9PSyhQRl9ERUNuZXQsIE5GX0ROX1JPVVRFLCBza2IsIHNrYi0+ZGV2LCBOVUxMLCBkbl9yb3V0ZV9kaXNjYXJkKTsKKyAgICAgICAgICAgICAgICAJY2FzZSBETl9SVF9QS1RfRVJUSDoKKwkJCQlyZXR1cm4gTkZfSE9PSyhQRl9ERUNuZXQsIE5GX0ROX0hFTExPLCBza2IsIHNrYi0+ZGV2LCBOVUxMLCBkbl9uZWlnaF9yb3V0ZXJfaGVsbG8pOworCisgICAgICAgICAgICAgICAgCWNhc2UgRE5fUlRfUEtUX0VFREg6CisJCQkJcmV0dXJuIE5GX0hPT0soUEZfREVDbmV0LCBORl9ETl9IRUxMTywgc2tiLCBza2ItPmRldiwgTlVMTCwgZG5fbmVpZ2hfZW5kbm9kZV9oZWxsbyk7CisgICAgICAgICAgICAgICAgfQorICAgICAgICB9IGVsc2UgeworCQlpZiAoZG4tPnBhcm1zLnN0YXRlICE9IEROX0RFVl9TX1JVKQorCQkJZ290byBkdW1wX2l0OworCisJCXNrYl9wdWxsKHNrYiwgMSk7IC8qIFB1bGwgZmxhZ3MgKi8KKworICAgICAgICAgICAgICAgIHN3aXRjaChmbGFncyAmIEROX1JUX1BLVF9NU0spIHsKKyAgICAgICAgICAgICAgICAJY2FzZSBETl9SVF9QS1RfTE9ORzoK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gZ29hbDsgb3JkZXIrKykKKwkJLyogTk9USElORyAqLzsKKworICAgICAgICAvKgorICAgICAgICAgKiBPbmx5IHdhbnQgMTAyNCBlbnRyaWVzIG1heCwgc2luY2UgdGhlIHRhYmxlIGlzIHZlcnksIHZlcnkgdW5saWtlbHkKKyAgICAgICAgICogdG8gYmUgbGFyZ2VyIHRoYW4gdGhhdC4KKyAgICAgICAgICovCisgICAgICAgIHdoaWxlKG9yZGVyICYmICgoKCgxVUwgPDwgb3JkZXIpICogUEFHRV9TSVpFKSAvIAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaXplb2Yoc3RydWN0IGRuX3J0X2hhc2hfYnVja2V0KSkgPj0gMjA0OCkpCisgICAgICAgICAgICAgICAgb3JkZXItLTsKKworICAgICAgICBkbyB7CisgICAgICAgICAgICAgICAgZG5fcnRfaGFzaF9tYXNrID0gKDFVTCA8PCBvcmRlcikgKiBQQUdFX1NJWkUgLworICAgICAgICAgICAgICAgICAgICAgICAgc2l6ZW9mKHN0cnVjdCBkbl9ydF9oYXNoX2J1Y2tldCk7CisgICAgICAgICAgICAgICAgd2hpbGUoZG5fcnRfaGFzaF9tYXNrICYgKGRuX3J0X2hhc2hfbWFzayAtIDEpKQorICAgICAgICAgICAgICAgICAgICAgICAgZG5fcnRfaGFzaF9tYXNrLS07CisgICAgICAgICAgICAgICAgZG5fcnRfaGFzaF90YWJsZSA9IChzdHJ1Y3QgZG5fcnRfaGFzaF9idWNrZXQgKikKKyAgICAgICAgICAgICAgICAgICAgICAgIF9fZ2V0X2ZyZWVfcGFnZXMoR0ZQX0FUT01JQywgb3JkZXIpOworICAgICAgICB9IHdoaWxlIChkbl9ydF9oYXNoX3RhYmxlID09IE5VTEwgJiYgLS1vcmRlciA+IDApOworCisJaWYgKCFkbl9ydF9oYXNoX3RhYmxlKQorICAgICAgICAgICAgICAgIHBhbmljKCJGYWlsZWQgdG8gYWxsb2NhdGUgREVDbmV0IHJvdXRlIGNhY2hlIGhhc2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fZ3cpOworICAgICAgICAgICAgICAgIGlmIChmaS0+ZmliX25oLT5uaF9vaWYpCisgICAgICAgICAgICAgICAgICAgICAgICBSVEFfUFVUKHNrYiwgUlRBX09JRiwgc2l6ZW9mKGludCksICZmaS0+ZmliX25oLT5uaF9vaWYpOworICAgICAgICB9CisgICAgICAgIGlmIChmaS0+ZmliX25ocyA+IDEpIHsKKyAgICAgICAgICAgICAgICBzdHJ1Y3QgcnRuZXh0aG9wICpuaHA7CisgICAgICAgICAgICAgICAgc3RydWN0IHJ0YXR0ciAqbXBfaGVhZDsKKyAgICAgICAgICAgICAgICBpZiAoc2tiX3RhaWxyb29tKHNrYikgPD0gUlRBX1NQQUNFKDApKQorICAgICAgICAgICAgICAgICAgICAgICAgZ290byBydGF0dHJfZmFpbHVyZTsKKyAgICAgICAgICAgICAgICBtcF9oZWFkID0gKHN0cnVjdCBydGF0dHIgKilza2JfcHV0KHNrYiwgUlRBX1NQQUNFKDApKTsKKworICAgICAgICAgICAgICAgIGZvcl9uZXh0aG9wcyhmaSkgeworICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNrYl90YWlscm9vbShza2IpIDwgUlRBX0FMSUdOKFJUQV9BTElHTihzaXplb2YoKm5ocCkpICsgNCkpCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdvdG8gcnRhdHRyX2ZhaWx1cmU7CisgICAgICAgICAgICAgICAgICAgICAgICBuaHAgPSAoc3RydWN0IHJ0bmV4dGhvcCAqKXNrYl9wdXQoc2tiLCBSVEFfQUxJR04oc2l6ZW9mKCpuaHApKSk7CisgICAgICAgICAgICAgICAgICAgICAgICBuaHAtPnJ0bmhfZmxhZ3MgPSBuaC0+bmhfZmxhZ3MgJiAweEZGOworICAgICAgICAgICAgICAgICAgICAgICAgbmhwLT5ydG5oX2hvcHMgPSBuaC0+bmhfd2VpZ2h0IC0gMTsKKyAgICAgICAgICAgICAgICAgICAgICAgIG5ocC0+cnRuaF9pZmluZGV4ID0gbmgtPm5oX29pZjsKKyAgICAgICAgICAgICAgICAgICAgICAgIGlmIChuaC0+bmhfZ3cpCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFJUQV9QVVQoc2tiLCBSVEFfR0FURVdBWSwgMiwgJm5oLT5uaF9ndyk7CisgICAgICAgICAgICAgICAgICAgICAgICBuaHAtPnJ0bmhfbGVuID0gc2tiLT50YWlsIC0gKHVuc2lnbmVkIGNoYXIgKiluaHA7CisgICAgICAgICAgICAgICAgfSBlbmRmb3JfbmV4dGhvcHMoZmkpOworICAgICAgICAgICAgICAgIG1wX2hlYWQtPnJ0YV90eXBlID0gUlRBX01VTFRJUEFUSDsKKyAgICAgICAgICAgICAgICBtcF9oZWFkLT5ydGFfbGVuID0gc2tiLT50YWlsIC0gKHU4KiltcF9oZWFkOworICAgICAgICB9CisKKyAgICAgICAgbmxoLT5ubG1zZ19sZW4gPSBza2ItPnRhaWwgLSBiOworICAgICAgICByZXR1cm4gc2tiLT5sZW47CisKKworbmxtc2dfZmFpbHVyZToKK3J0YXR0cl9mYWlsdXJlOgorICAgICAgICBza2JfdHJpbShza2IsIGIgLSBza2ItPmRhdGEpOworICAgICAgICByZXR1cm4gLTE7Cit9CisKKworc3RhdGljIHZvaWQgZG5fcnRtc2dfZmliKGludCBldmVudCwgc3RydWN0IGRuX2ZpYl9ub2RlICpmLCBpbnQgeiwgaW50IHRiX2lkLAorICAgICAgICAgICAgICAgICAgICAgICAgc3RydWN0IG5sbXNnaGRyICpubGgsIHN0cnVjdCBuZXRsaW5rX3NrYl9wYXJtcyAqcmVxKQoreworICAgICAgICBzdHJ1Y3Qgc2tfYnVmZiAqc2tiOworICAgICAgICB1MzIgcGlkID0gcmVxID8gcmVxLT5waWQgOiAwOworICAgICAgICBpbnQgc2l6ZSA9IE5MTVNHX1NQQUNFKHNpemVvZihzdHJ1Y3QgcnRtc2cpICsgMjU2KTsKKworICAgICAgICBza2IgPSBhbGxvY19za2Ioc2l6ZSwgR0ZQX0tFUk5FTCk7CisgICAgICAgIGlmICghc2tiKQorICAgICAgICAgICAgICAgIHJldHVybjsKKworICAgICAgICBpZiAoZG5fZmliX2R1bXBfaW5mbyhza2IsIHBpZCwgbmxoLT5ubG1zZ19zZXEsIGV2ZW50LCB0Yl9pZCwgCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGYtPmZuX3R5cGUsIGYtPmZuX3Njb3BlLCAmZi0+Zm5fa2V5LCB6LCAKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgRE5fRklCX0lORk8oZikpIDwgMCkgeworICAgICAgICAgICAgICAgIGtmcmVlX3NrYihza2IpOworICAgICAgICAgICAgICAgIHJldHVybjsKKyAgICAgICAgfQorICAgICAgICBORVRMSU5LX0NCKHNrYikuZHN0X2dyb3VwcyA9IFJUTUdSUF9ERUNuZXRfUk9VVEU7CisgICAgICAgIGlmIChubGgtPm5sbXNnX2ZsYWdzICYgTkxNX0ZfRUNITykKKyAgICAgICAgICAgICAgICBhdG9taWNfaW5jKCZza2ItPnVzZXJzKTsKKyAgICAgICAgbmV0bGlua19icm9hZGNhc3QocnRubCwgc2tiLCBwaWQsIFJUTUdSUF9ERUNuZXRfUk9VVEUsIEdGUF9LRVJORUwpOworICAgICAgICBpZiAobmxoLT5ubG1zZ19mbGFncyAmIE5MTV9GX0VDSE8pCisgICAgICAgICAgICAgICAgbmV0bGlua191bmljYXN0KHJ0bmwsIHNrYiwgcGlkLCBNU0dfRE9OVFdBSVQpOworfQorCitzdGF0aWMgX19pbmxpbmVfXyBpbnQgZG5faGFzaF9kdW1wX2J1Y2tldChzdHJ1Y3Qgc2tfYnVmZiAqc2tiLCAKKwkJCQlzdHJ1Y3QgbmV0bGlua19jYWxsYmFjayAqY2IsCisJCQkJc3RydWN0IGRuX2ZpYl90YWJsZSAqdGIsCisJCQkJc3RydWN0IGRuX3pvbmUgKmR6LAorCQkJCXN0cnVjdCBkbl9maWJfbm9kZSAqZikKK3sKKwlpbnQgaSwgc19pOworCisJc19pID0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SBmLT5mbl90eXBlOworCQkJCXJlcy0+c2NvcGUgPSBmLT5mbl9zY29wZTsgCisJCQkJcmVzLT5wcmVmaXhsZW4gPSBkei0+ZHpfb3JkZXI7CisJCQkJZ290byBvdXQ7CisJCQl9CisJCQlpZiAoZXJyIDwgMCkKKwkJCQlnb3RvIG91dDsKKwkJfQorCX0KKwllcnIgPSAxOworb3V0OgorCXJlYWRfdW5sb2NrKCZkbl9maWJfdGFibGVzX2xvY2spOworICAgICAgICByZXR1cm4gZXJyOworfQorCisKK3N0cnVjdCBkbl9maWJfdGFibGUgKmRuX2ZpYl9nZXRfdGFibGUoaW50IG4sIGludCBjcmVhdGUpCit7CisgICAgICAgIHN0cnVjdCBkbl9maWJfdGFibGUgKnQ7CisKKyAgICAgICAgaWYgKG4gPCBSVF9UQUJMRV9NSU4pCisgICAgICAgICAgICAgICAgcmV0dXJuIE5VTEw7CisKKyAgICAgICAgaWYgKG4gPiBSVF9UQUJMRV9NQVgpCisgICAgICAgICAgICAgICAgcmV0dXJuIE5VTEw7CisKKyAgICAgICAgaWYgKGRuX2ZpYl90YWJsZXNbbl0pIAorICAgICAgICAgICAgICAgIHJldHVybiBkbl9maWJfdGFibGVzW25dOworCisgICAgICAgIGlmICghY3JlYXRlKQorICAgICAgICAgICAgICAgIHJldHVybiBOVUxMOworCisgICAgICAgIGlmIChpbl9pbnRlcnJ1cHQoKSAmJiBuZXRfcmF0ZWxpbWl0KCkpIHsKKyAgICAgICAgICAgICAgICBwcmludGsoS0VSTl9ERUJVRyAiREVDbmV0OiBCVUchIEF0dGVtcHQgdG8gY3JlYXRlIHJvdXRpbmcgdGFibGUgZnJvbSBpbnRlcnJ1cHRcbiIpOyAKKyAgICAgICAgICAgICAgICByZXR1cm4gTlVMTDsKKyAgICAgICAgfQorICAgICAgICBpZiAoKHQgPSBrbWFsbG9jKHNpemVvZihzdHJ1Y3QgZG5fZmliX3RhYmxlKSArIHNpemVvZihzdHJ1Y3QgZG5faGFzaCksIEdGUF9LRVJORUwpKSA9PSBOVUxMKQorICAgICAgICAgICAgICAgIHJldHVybiBOVUxMOworCisgICAgICAgIG1lbXNldCh0LCAwLCBzaXplb2Yoc3RydWN0IGRuX2ZpYl90YWJsZSkpOworCisgICAgICAgIHQtPm4gPSBuOworICAgICAgICB0LT5pbnNlcnQgPSBkbl9maWJfdGFibGVfaW5zZXJ0OworICAgICAgICB0LT5kZWxldGUgPSBkbl9maWJfdGFibGVfZGVsZXRlOworICAgICAgICB0LT5sb29rdXAgPSBkbl9maWJfdGFibGVfbG9va3VwOworICAgICAgICB0LT5mbHVzaCAgPSBkbl9maWJfdGFibGVfZmx1c2g7CisgICAgICAgIHQtPmR1bXAgPSBkbl9maWJfdGFibGVfZHVtcDsKKwltZW1zZXQodC0+ZGF0YSwgMCwgc2l6ZW9mKHN0cnVjdCBkbl9oYXNoKSk7CisgICAgICAgIGRuX2ZpYl90YWJsZXNbbl0gPSB0OworCisgICAgICAgIHJldHVybiB0OworfQorCitzdGF0aWMgdm9pZCBkbl9maWJfZGVsX3RyZWUoaW50IG4pCit7CisgICAgICAgIHN0cnVjdCBkbl9maWJfdGFibGUgKnQ7CisKKyAgICAgICAgd3JpdGVfbG9jaygmZG5fZmliX3RhYmxlc19sb2NrKTsKKyAgICAgICAgdCA9IGRuX2ZpYl90YWJsZXNbbl07CisgICAgICAgIGRuX2ZpYl90YWJsZXNbbl0gPSBOVUxMOworICAgICAgICB3cml0ZV91bmxvY2soJmRuX2ZpYl90YWJsZXNfbG9jayk7CisKKyAgICAgICAgaWYgKHQpIHsKKyAgICAgICAgICAgICAgICBrZnJlZSh0KTsKKyAgICAgICAgfQorfQorCitzdHJ1Y3QgZG5fZmliX3RhYmxlICpkbl9maWJfZW1wdHlfdGFibGUodm9pZCkKK3sKKyAgICAgICAgaW50IGlkOworCisgICAgICAgIGZvcihpZCA9IFJUX1RBQkxFX01JTjsgaWQgPD0gUlRfVEFCTEVfTUFYOyBpZCsrKQorICAgICAgICAgICAgICAgIGlm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tPmJpbmQodWRwc29jaywgKHN0cnVjdCBzb2NrYWRkciAqKSZzaW4sCisJCQkJc2l6ZW9mKHNpbikpOworCWlmIChlcnJvciA8IDApCisJeworCQlwcmludGsoIkFVTjogYmluZCBlcnJvciAlZFxuIiwgLWVycm9yKTsKKwkJZ290byByZWxlYXNlOworCX0KKworCXVkcHNvY2stPnNrLT5za19kYXRhX3JlYWR5ID0gYXVuX2RhdGFfYXZhaWxhYmxlOworCisJcmV0dXJuIDA7CisKK3JlbGVhc2U6CisJc29ja19yZWxlYXNlKHVkcHNvY2spOworCXVkcHNvY2sgPSBOVUxMOworCXJldHVybiBlcnJvcjsKK30KKyNlbmRpZgorCisjaWZkZWYgQ09ORklHX0VDT05FVF9OQVRJVkUKKworLyoKKyAqCVJlY2VpdmUgYW4gRWNvbmV0IGZyYW1lIGZyb20gYSBkZXZpY2UuCisgKi8KKworc3RhdGljIGludCBlY29uZXRfcmN2KHN0cnVjdCBza19idWZmICpza2IsIHN0cnVjdCBuZXRfZGV2aWNlICpkZXYsIHN0cnVjdCBwYWNrZXRfdHlwZSAqcHQpCit7CisJc3RydWN0IGVjX2ZyYW1laGRyICpoZHI7CisJc3RydWN0IHNvY2sgKnNrOworCXN0cnVjdCBlY19kZXZpY2UgKmVkZXYgPSBkZXYtPmVjX3B0cjsKKworCWlmIChza2ItPnBrdF90eXBlID09IFBBQ0tFVF9PVEhFUkhPU1QpCisJCWdvdG8gZHJvcDsKKworCWlmICghZWRldikKKwkJZ290byBkcm9wOworCisJaWYgKChza2IgPSBza2Jfc2hhcmVfY2hlY2soc2tiLCBHRlBfQVRPTUlDKSkgPT0gTlVMTCkKKwkJcmV0dXJuIE5FVF9SWF9EUk9QOworCisJaWYgKCFwc2tiX21heV9wdWxsKHNrYiwgc2l6ZW9mKHN0cnVjdCBlY19mcmFtZWhkcikpKQorCQlnb3RvIGRyb3A7CisKKwloZHIgPSAoc3RydWN0IGVjX2ZyYW1laGRyICopIHNrYi0+ZGF0YTsKKworCS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C5wcm90b2NvbCA9ICAgSVBQUk9UT19UQ1AsCisgICAgICAgICAgICAgICAgLnByb3QgPSAgICAgICAmdGNwX3Byb3QsCisgICAgICAgICAgICAgICAgLm9wcyA9ICAgICAgICAmaW5ldF9zdHJlYW1fb3BzLAorICAgICAgICAgICAgICAgIC5jYXBhYmlsaXR5ID0gLTEsCisgICAgICAgICAgICAgICAgLm5vX2NoZWNrID0gICAwLAorICAgICAgICAgICAgICAgIC5mbGFncyA9ICAgICAgSU5FVF9QUk9UT1NXX1BFUk1BTkVOVCwKKyAgICAgICAgfSwKKworICAgICAgICB7CisgICAgICAgICAgICAgICAgLnR5cGUgPSAgICAgICBTT0NLX0RHUkFNLAorICAgICAgICAgICAgICAgIC5wcm90b2NvbCA9ICAgSVBQUk9UT19VRFAsCisgICAgICAgICAgICAgICAgLnByb3QgPSAgICAgICAmdWRwX3Byb3QsCisgICAgICAgICAgICAgICAgLm9wcyA9ICAgICAgICAmaW5ldF9kZ3JhbV9vcHMsCisgICAgICAgICAgICAgICAgLmNhcGFiaWxpdHkgPSAtMSwKKyAgICAgICAgICAgICAgICAubm9fY2hlY2sgPSAgIFVEUF9DU1VNX0RFRkFVTFQsCisgICAgICAgICAgICAgICAgLmZsYWdzID0gICAgICBJTkVUX1BST1RPU1dfUEVSTUFORU5ULAorICAgICAgIH0sCisgICAgICAgIAorCisgICAgICAgeworICAgICAgICAgICAgICAgLnR5cGUgPSAgICAgICBTT0NLX1JBVywKKyAgICAgICAgICAgICAgIC5wcm90b2NvbCA9ICAgSVBQUk9UT19JUCwJLyogd2lsZCBjYXJkICovCisgICAgICAgICAgICAgICAucHJvdCA9ICAgICAgICZyYXdfcHJvdCwKKyAgICAgICAgICAgICAgIC5vcHMgPSAgICAgICAgJmluZXRfc29ja3Jhd19vcHMsCisgICAgICAgICAgICAgICAuY2FwYWJpbGl0eSA9IENBUF9ORVRfUkFXLAorICAgICAgICAgICAgICAgLm5vX2NoZWNrID0gICBVRFBfQ1NVTV9ERUZ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aWYgKChpbWkgPSBJTl9ERVZfTUVESVVNX0lEKGluX2RldikpID09IDApCisJCXJldHVybiAxOworCWlmIChpbWkgPT0gLTEpCisJCXJldHVybiAwOworCisJLyogcGxhY2UgdG8gY2hlY2sgZm9yIHByb3h5X2FycCBmb3Igcm91dGVzICovCisKKwlpZiAoKG91dF9kZXYgPSBpbl9kZXZfZ2V0KHJ0LT51LmRzdC5kZXYpKSAhPSBOVUxMKSB7CisJCW9taSA9IElOX0RFVl9NRURJVU1fSUQob3V0X2Rldik7CisJCWluX2Rldl9wdXQob3V0X2Rldik7CisJfQorCXJldHVybiAob21pICE9IGltaSAmJiBvbWkgIT0gLTEpOworfQorCisvKgorICoJSW50ZXJmYWNlIHRvIGxpbmsgbGF5ZXI6IHNlbmQgcm91dGluZSBhbmQgcmVjZWl2ZSBoYW5kbGVyLgorICovCisKKy8qCisgKglDcmVhdGUgYW4gYXJwIHBhY2tldC4gSWYgKGRlc3RfaHcgPT0gTlVMTCksIHdlIGNyZWF0ZSBhIGJyb2FkY2FzdAorICoJbWVzc2FnZS4KKyAqLworc3RydWN0IHNrX2J1ZmYgKmFycF9jcmVhdGUoaW50IHR5cGUsIGludCBwdHlwZSwgdTMyIGRlc3RfaXAsCisJCQkgICBzdHJ1Y3QgbmV0X2RldmljZSAqZGV2LCB1MzIgc3JjX2lwLAorCQkJICAgdW5zaWduZWQgY2hhciAqZGVzdF9odywgdW5zaWduZWQgY2hhciAqc3JjX2h3LAorCQkJICAgdW5zaWduZWQgY2hhciAqdGFyZ2V0X2h3KQoreworCXN0cnVjdCBza19idWZmICpza2I7CisJc3RydWN0IGFycGhkciAqYXJwOworCXVuc2lnbmVkIGNoYXIgKmFycF9wdHI7CisKKwkvKgorCSAqCUFsbG9jYXRlIGEgYnVmZmVyCisJICovCisJCisJc2tiID0gYWxsb2Nfc2tiKHNpemVvZihzdHJ1Y3QgYXJwaGRyKSsgMiooZGV2LT5hZGRyX2xlbis0KQorCQkJCSsgTExfUkVTRVJWR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RhdGljIF9faW5saW5lX18gdm9pZCBpZ21wX3N0b3BfdGltZXIoc3RydWN0IGlwX21jX2xpc3QgKmltKQoreworCXNwaW5fbG9ja19iaCgmaW0tPmxvY2spOworCWlmIChkZWxfdGltZXIoJmltLT50aW1lcikpCisJCWF0b21pY19kZWMoJmltLT5yZWZjbnQpOworCWltLT50bV9ydW5uaW5nPTA7CisJaW0tPnJlcG9ydGVyID0gMDsKKwlpbS0+dW5zb2xpY2l0X2NvdW50ID0gMDsKKwlzcGluX3VubG9ja19iaCgmaW0tPmxvY2spOworfQorCisvKiBJdCBtdXN0IGJlIGNhbGxlZCB3aXRoIGxvY2tlZCBpbS0+bG9jayAqLworc3RhdGljIHZvaWQgaWdtcF9zdGFydF90aW1lcihzdHJ1Y3QgaXBfbWNfbGlzdCAqaW0sIGludCBtYXhfZGVsYXkpCit7CisJaW50IHR2PW5ldF9yYW5kb20oKSAlIG1heF9kZWxheTsKKworCWltLT50bV9ydW5uaW5nPTE7CisJaWYgKCFtb2RfdGltZXIoJmltLT50aW1lciwgamlmZmllcyt0disyKSkKKwkJYXRvbWljX2luYygmaW0tPnJlZmNudCk7Cit9CisKK3N0YXRpYyB2b2lkIGlnbXBfZ3Ffc3RhcnRfdGltZXIoc3RydWN0IGluX2RldmljZSAqaW5fZGV2KQoreworCWludCB0diA9IG5ldF9yYW5kb20oKSAlIGluX2Rldi0+bXJfbWF4ZGVsYXk7CisKKwlpbl9kZXYtPm1yX2dxX3J1bm5pbmcgPSAxOworCWlmICghbW9kX3RpbWVyKCZpbl9kZXYtPm1yX2dxX3RpbWVyLCBqaWZmaWVzK3R2KzIpKQorCQlpbl9kZXZfaG9sZChpbl9kZXYpOworfQorCitzdGF0aWMgdm9pZCBpZ21wX2lmY19zdGFydF90aW1lcihzdHJ1Y3QgaW5fZGV2aWNlICppbl9kZXYsIGludCBkZWxheSkKK3sKKwlpbnQgdHYgPSBuZXRfcmFuZG9tKCkgJSBkZWxheTsKKworCWlmICghbW9kX3Rpb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cnRubF9zaHVubG9jaygpOworCWlmICghcHNsKSB7CisJCWxlbiA9IDA7CisJCWNvdW50ID0gMDsKKwl9IGVsc2UgeworCQljb3VudCA9IHBzbC0+c2xfY291bnQ7CisJfQorCWNvcHljb3VudCA9IGNvdW50IDwgbXNmLT5pbXNmX251bXNyYyA/IGNvdW50IDogbXNmLT5pbXNmX251bXNyYzsKKwlsZW4gPSBjb3B5Y291bnQgKiBzaXplb2YocHNsLT5zbF9hZGRyWzBdKTsKKwltc2YtPmltc2ZfbnVtc3JjID0gY291bnQ7CisJaWYgKHB1dF91c2VyKElQX01TRklMVEVSX1NJWkUoY29weWNvdW50KSwgb3B0bGVuKSB8fAorCSAgICBjb3B5X3RvX3VzZXIob3B0dmFsLCBtc2YsIElQX01TRklMVEVSX1NJWkUoMCkpKSB7CisJCXJldHVybiAtRUZBVUxUOworCX0KKwlpZiAobGVuICYmCisJICAgIGNvcHlfdG9fdXNlcigmb3B0dmFsLT5pbXNmX3NsaXN0WzBdLCBwc2wtPnNsX2FkZHIsIGxlbikpCisJCXJldHVybiAtRUZBVUxUOworCXJldHVybiAwOworZG9uZToKKwlydG5sX3NodW5sb2NrKCk7CisJcmV0dXJuIGVycjsKK30KKworaW50IGlwX21jX2dzZmdldChzdHJ1Y3Qgc29jayAqc2ssIHN0cnVjdCBncm91cF9maWx0ZXIgKmdzZiwKKwlzdHJ1Y3QgZ3JvdXBfZmlsdGVyIF9fdXNlciAqb3B0dmFsLCBpbnQgX191c2VyICpvcHRsZW4pCit7CisJaW50IGVyciwgaSwgY291bnQsIGNvcHljb3VudDsKKwlzdHJ1Y3Qgc29ja2FkZHJfaW4gKnBzaW47CisJdTMyIGFkZHI7CisJc3RydWN0IGlwX21jX3NvY2tsaXN0ICpwbWM7CisJc3RydWN0IGluZXRfc29jayAqaW5ldCA9IGluZXRfc2soc2spOworCXN0cnVjdCBpcF9zZl9zb2NrbGlzdCAqcHNsOworCisJcHNpbiA9IChzdHJ1Y3Qgc29ja2FkZHJ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hbQkqLworCWludAkJbWVhdDsKKwlzcGlubG9ja190CWxvY2s7CisJYXRvbWljX3QJcmVmY250OworCXN0cnVjdCB0aW1lcl9saXN0IHRpbWVyOwkvKiB3aGVuIHdpbGwgdGhpcyBxdWV1ZSBleHBpcmU/CQkqLworCXN0cnVjdCBpcHEJKipwcHJldjsKKwlpbnQJCWlpZjsKKwlzdHJ1Y3QgdGltZXZhbAlzdGFtcDsKK307CisKKy8qIEhhc2ggdGFibGUuICovCisKKyNkZWZpbmUgSVBRX0hBU0hTWgk2NAorCisvKiBQZXItYnVja2V0IGxvY2sgaXMgZWFzeSB0byBhZGQgbm93LiAqLworc3RhdGljIHN0cnVjdCBpcHEgKmlwcV9oYXNoW0lQUV9IQVNIU1pdOworc3RhdGljIERFRklORV9SV0xPQ0soaXBmcmFnX2xvY2spOworc3RhdGljIHUzMiBpcGZyYWdfaGFzaF9ybmQ7CitzdGF0aWMgTElTVF9IRUFEKGlwcV9scnVfbGlzdCk7CitpbnQgaXBfZnJhZ19ucXVldWVzID0gMDsKKworc3RhdGljIF9faW5saW5lX18gdm9pZCBfX2lwcV91bmxpbmsoc3RydWN0IGlwcSAqcXApCit7CisJaWYocXAtPm5leHQpCisJCXFwLT5uZXh0LT5wcHJldiA9IHFwLT5wcHJldjsKKwkqcXAtPnBwcmV2ID0gcXAtPm5leHQ7CisJbGlzdF9kZWwoJnFwLT5scnVfbGlzdCk7CisJaXBfZnJhZ19ucXVldWVzLS07Cit9CisKK3N0YXRpYyBfX2lubGluZV9fIHZvaWQgaXBxX3VubGluayhzdHJ1Y3QgaXBxICppcHEpCit7CisJd3JpdGVfbG9jaygmaXBmcmFnX2xvY2spOworCV9faXBxX3VubGluayhpcHEpOworCXdyaXRlX3VubG9jaygmaXBmcmFnX2xvY2spOworfQorCitzdGF0aWMgdW5zaWduZWQgaW50IGlwcWhhc2hmbih1MTYgaWQsIHUzMiBzYWRkciwgdTMyIGRhZGRyLCB1OCBwcm90KQoreworCXJldHVybiBqaGF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W5pdDsKKwludCA9IGRldi0+cHJpdjsKKwludC0+cGFybXMgPSAqcGFybXM7CisKKwlpZiAocmVnaXN0ZXJfbmV0ZGV2aWNlKGRldikgPCAwKSB7CisJCWZyZWVfbmV0ZGV2KGRldik7CisJCWdvdG8gZmFpbGVkOworCX0KKworCW50ID0gZGV2LT5wcml2OworCW50LT5wYXJtcyA9ICpwYXJtczsKKworCWRldl9ob2xkKGRldik7CisJaXBncmVfdHVubmVsX2xpbmsobnQpOworCS8qIERvIG5vdCBkZWNyZW1lbnQgTU9EX1VTRV9DT1VOVCBoZXJlLiAqLworCXJldHVybiBudDsKKworZmFpbGVkOgorCXJldHVybiBOVUxMOworfQorCitzdGF0aWMgdm9pZCBpcGdyZV90dW5uZWxfdW5pbml0KHN0cnVjdCBuZXRfZGV2aWNlICpkZXYpCit7CisJaXBncmVfdHVubmVsX3VubGluaygoc3RydWN0IGlwX3R1bm5lbCopZGV2LT5wcml2KTsKKwlkZXZfcHV0KGRldik7Cit9CisKKworc3RhdGljIHZvaWQgaXBncmVfZXJyKHN0cnVjdCBza19idWZmICpza2IsIHUzMiBpbmZvKQoreworI2lmbmRlZiBJX1dJU0hfV09STERfV0VSRV9QRVJGRUNUCisKKy8qIEl0IGlzIG5vdCA6LSggQWxsIHRoZSByb3V0ZXJzIChleGNlcHQgZm9yIExpbnV4KSByZXR1cm4gb25seQorICAgOCBieXRlcyBvZiBwYWNrZXQgcGF5bG9hZC4gSXQgbWVhbnMsIHRoYXQgcHJlY2lzZSByZWxheWluZyBvZgorICAgSUNNUCBpbiB0aGUgcmVhbCBJbnRlcm5ldCBpcyBhYnNvbHV0ZWx5IGluZmVhc2libGUuCisKKyAgIE1vcmVvdmVyLCBDaXNjbyAid2lzZSBtZW4iIHB1dCBHUkUga2V5IHRvIHRoZSB0aGlyZCB3b3JkCisgICBpbiBHUkUgaGVhZGVyLiBJdCBtYWtlcyBpbXBvc3NpYmxlIG1haW50YWluaW5nIGV2ZW4gc29mdCBzdGF0Z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dF9leHQodTggKmUpCit7CisJbWVtY3B5KGUsIGljX2Jvb3RwX2Nvb2tpZSwgNCk7CS8qIFJGQzEwNDggTWFnaWMgQ29va2llICovCisJZSArPSA0OworCSplKysgPSAxOwkJLyogU3VibmV0IG1hc2sgcmVxdWVzdCAqLworCSplKysgPSA0OworCWUgKz0gNDsKKwkqZSsrID0gMzsJCS8qIERlZmF1bHQgZ2F0ZXdheSByZXF1ZXN0ICovCisJKmUrKyA9IDQ7CisJZSArPSA0OworCSplKysgPSA1OwkJLyogTmFtZSBzZXJ2ZXIgcmVxdWVzdCAqLworCSplKysgPSA4OworCWUgKz0gODsKKwkqZSsrID0gMTI7CQkvKiBIb3N0IG5hbWUgcmVxdWVzdCAqLworCSplKysgPSAzMjsKKwllICs9IDMyOworCSplKysgPSA0MDsJCS8qIE5JUyBEb21haW4gbmFtZSByZXF1ZXN0ICovCisJKmUrKyA9IDMyOworCWUgKz0gMzI7CisJKmUrKyA9IDE3OwkJLyogQm9vdCBwYXRoICovCisJKmUrKyA9IDQwOworCWUgKz0gNDA7CisKKwkqZSsrID0gNTc7CQkvKiBzZXQgZXh0ZW5zaW9uIGJ1ZmZlciBzaXplIGZvciByZXBseSAqLyAKKwkqZSsrID0gMjsKKwkqZSsrID0gMTsJCS8qIDEyOCsyMzYrOCsyMCsxNCwgc2VlIGRoY3BkIHNvdXJjZXMgKi8gCisJKmUrKyA9IDE1MDsKKworCSplKysgPSAyNTU7CQkvKiBFbmQgb2YgdGhlIGxpc3QgKi8KK30KKworCisvKgorICogIEluaXRpYWxpemUgdGhlIERIQ1AvQk9PVFAgbWVjaGFuaXNtLgorICovCitzdGF0aWMgaW5saW5lIHZvaWQgaWNfYm9vdHBfaW5pdCh2b2lkKQoreworCWludCBpOworCisJZm9yIChpID0gMDsgaSA8IENPTkZfTkFNRVNFUlZFUlNfTUFYOyBpKyspCisJCWljX25hbWVzZXJ2ZXJzW2ldID0gSU5BRERSX05PTkU7CisKKwlkZXZfYWRkX3BhY2so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pZgorCQkJCSAqIHRoZXkgYXJlIGRpZmZlcmVudC4KKwkJCQkgKi8KKwkJCQlpZiAoKHNlcnZlcl9pZCAhPSBJTkFERFJfTk9ORSkgJiYKKwkJCQkgICAgKGItPnNlcnZlcl9pcCAhPSBzZXJ2ZXJfaWQpKQorCQkJCQliLT5zZXJ2ZXJfaXAgPSBpY19zZXJ2YWRkcjsKKwkJCQlicmVhazsKKworCQkJY2FzZSBESENQQUNLOgorCQkJCWlmIChtZW1jbXAoZGV2LT5kZXZfYWRkciwgYi0+aHdfYWRkciwgZGV2LT5hZGRyX2xlbikgIT0gMCkKKwkJCQkJZ290byBkcm9wX3VubG9jazsKKworCQkJCS8qIFllYWghICovCisJCQkJYnJlYWs7CisKKwkJCWRlZmF1bHQ6CisJCQkJLyogVXJxdWUuICBGb3JnZXQgaXQqLworCQkJCWljX215YWRkciA9IElOQUREUl9OT05FOworCQkJCWljX3NlcnZhZGRyID0gSU5BRERSX05PTkU7CisJCQkJZ290byBkcm9wX3VubG9jazsKKwkJCX07CisKKwkJCWljX2RoY3BfbXNndHlwZSA9IG10OworCisJCX0KKyNlbmRpZiAvKiBJUENPTkZJR19ESENQICovCisKKwkJZXh0ID0gJmItPmV4dGVuWzRdOworCQl3aGlsZSAoZXh0IDwgZW5kICYmICpleHQgIT0gMHhmZikgeworCQkJdTggKm9wdCA9IGV4dCsrOworCQkJaWYgKCpvcHQgPT0gMCkJLyogUGFkZGluZyAqLworCQkJCWNvbnRpbnVlOworCQkJZXh0ICs9ICpleHQgKyAxOworCQkJaWYgKGV4dCA8IGVuZCkKKwkJCQlpY19kb19ib290cF9leHQob3B0KTsKKwkJfQorCX0KKworCS8qIFdlIGhhdmUgYSB3aW5uZXIhICovCisJaWNfZGV2ID0gZGV2OworCWljX215YWRkciA9IGItPnlvdXJfaXA7CisJaWNfc2VydmFkZHIgPSBiLT5zZXJ2ZXJfaXA7CisJaWYgKGljX2dhdGV3YXkgPT0gSU5BRERSX05PTkUgJiYgYi0+c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mV4dCA/IENPTkZfSU5URVJfVElNRU9VVCA6IHRpbWVvdXQpOworCQl3aGlsZSAodGltZV9iZWZvcmUoamlmZmllcywgamlmZikgJiYgIWljX2dvdF9yZXBseSkgeworCQkJc2V0X2N1cnJlbnRfc3RhdGUoVEFTS19VTklOVEVSUlVQVElCTEUpOworCQkJc2NoZWR1bGVfdGltZW91dCgxKTsKKwkJfQorI2lmZGVmIElQQ09ORklHX0RIQ1AKKwkJLyogREhDUCBpc24ndCBkb25lIHVudGlsIHdlIGdldCBhIERIQ1BBQ0suICovCisJCWlmICgoaWNfZ290X3JlcGx5ICYgSUNfQk9PVFApCisJCSAgICAmJiAoaWNfcHJvdG9fZW5hYmxlZCAmIElDX1VTRV9ESENQKQorCQkgICAgJiYgaWNfZGhjcF9tc2d0eXBlICE9IERIQ1BBQ0spCisJCXsKKwkJCWljX2dvdF9yZXBseSA9IDA7CisJCQlwcmludGsoIiwiKTsKKwkJCWNvbnRpbnVlOworCQl9CisjZW5kaWYgLyogSVBDT05GSUdfREhDUCAqLworCisJCWlmIChpY19nb3RfcmVwbHkpIHsKKwkJCXByaW50aygiIE9LXG4iKTsKKwkJCWJyZWFrOworCQl9CisKKwkJaWYgKChkID0gZC0+bmV4dCkpCisJCQljb250aW51ZTsKKworCQlpZiAoISAtLXJldHJpZXMpIHsKKwkJCXByaW50aygiIHRpbWVkIG91dCFcbiIpOworCQkJYnJlYWs7CisJCX0KKworCQlkID0gaWNfZmlyc3RfZGV2OworCisJCXRpbWVvdXQgPSB0aW1lb3V0IENPTkZfVElNRU9VVF9NVUxUOworCQlpZiAodGltZW91dCA+IENPTkZfVElNRU9VVF9NQVgpCisJCQl0aW1lb3V0ID0gQ09ORl9USU1FT1VUX01BWDsKKworCQlwcmludGsoIi4iKTsKKwl9CisKKyNpZmRlZiBJUENPTkZJR19CT09UUAorCWlmIChkb19ib290cCkKKwkJaWNfYm9vdHBfY2xlYW51cCgpOworI2VuZGlmCisjaWZkZWYgSVBDT05GSUdfU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PSAoKmFkZHJzICYmIAorCQkoc3RyY21wKGFkZHJzLCAib2ZmIikgIT0gMCkgJiYgCisJCShzdHJjbXAoYWRkcnMsICJub25lIikgIT0gMCkpOworCWlmICghaWNfZW5hYmxlKQorCQlyZXR1cm4gMTsKKworCWlmIChpY19wcm90b19uYW1lKGFkZHJzKSkKKwkJcmV0dXJuIDE7CisKKwkvKiBQYXJzZSB0aGUgd2hvbGUgc3RyaW5nICovCisJaXAgPSBhZGRyczsKKwl3aGlsZSAoaXAgJiYgKmlwKSB7CisJCWlmICgoY3AgPSBzdHJjaHIoaXAsICc6JykpKQorCQkJKmNwKysgPSAnXDAnOworCQlpZiAoc3RybGVuKGlwKSA+IDApIHsKKwkJCURCRygoIklQLUNvbmZpZzogUGFyYW1ldGVyICMlZDogYCVzJ1xuIiwgbnVtLCBpcCkpOworCQkJc3dpdGNoIChudW0pIHsKKwkJCWNhc2UgMDoKKwkJCQlpZiAoKGljX215YWRkciA9IGluX2F0b24oaXApKSA9PSBJTkFERFJfQU5ZKQorCQkJCQlpY19teWFkZHIgPSBJTkFERFJfTk9ORTsKKwkJCQlicmVhazsKKwkJCWNhc2UgMToKKwkJCQlpZiAoKGljX3NlcnZhZGRyID0gaW5fYXRvbihpcCkpID09IElOQUREUl9BTlkpCisJCQkJCWljX3NlcnZhZGRyID0gSU5BRERSX05PTkU7CisJCQkJYnJlYWs7CisJCQljYXNlIDI6CisJCQkJaWYgKChpY19nYXRld2F5ID0gaW5fYXRvbihpcCkpID09IElOQUREUl9BTlkpCisJCQkJCWljX2dhdGV3YXkgPSBJTkFERFJfTk9ORTsKKwkJCQlicmVhazsKKwkJCWNhc2UgMzoKKwkJCQlpZiAoKGljX25ldG1hc2sgPSBpbl9hdG9uKGlwKSkgPT0gSU5BRERSX0FOWSkKKwkJCQkJaWNfbmV0bWFzayA9IElOQUREUl9OT05FOworCQkJCWJyZWFrOworCQkJY2FzZSA0OgorCQkJCWlmICgoZHAgPSBzdHJjaHIoaXAsICcuJyk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CisJaWYgKCFzcGluX3RyeWxvY2soJm1mY191bnJlc19sb2NrKSkgeworCQltb2RfdGltZXIoJmlwbXJfZXhwaXJlX3RpbWVyLCBqaWZmaWVzK0haLzEwKTsKKwkJcmV0dXJuOworCX0KKworCWlmIChhdG9taWNfcmVhZCgmY2FjaGVfcmVzb2x2ZV9xdWV1ZV9sZW4pID09IDApCisJCWdvdG8gb3V0OworCisJbm93ID0gamlmZmllczsKKwlleHBpcmVzID0gMTAqSFo7CisJY3AgPSAmbWZjX3VucmVzX3F1ZXVlOworCisJd2hpbGUgKChjPSpjcCkgIT0gTlVMTCkgeworCQlpZiAodGltZV9hZnRlcihjLT5tZmNfdW4udW5yZXMuZXhwaXJlcywgbm93KSkgeworCQkJdW5zaWduZWQgbG9uZyBpbnRlcnZhbCA9IGMtPm1mY191bi51bnJlcy5leHBpcmVzIC0gbm93OworCQkJaWYgKGludGVydmFsIDwgZXhwaXJlcykKKwkJCQlleHBpcmVzID0gaW50ZXJ2YWw7CisJCQljcCA9ICZjLT5uZXh0OworCQkJY29udGludWU7CisJCX0KKworCQkqY3AgPSBjLT5uZXh0OworCisJCWlwbXJfZGVzdHJveV91bnJlcyhjKTsKKwl9CisKKwlpZiAoYXRvbWljX3JlYWQoJmNhY2hlX3Jlc29sdmVfcXVldWVfbGVuKSkKKwkJbW9kX3RpbWVyKCZpcG1yX2V4cGlyZV90aW1lciwgamlmZmllcyArIGV4cGlyZXMpOworCitvdXQ6CisJc3Bpbl91bmxvY2soJm1mY191bnJlc19sb2NrKTsKK30KKworLyogRmlsbCBvaWZzIGxpc3QuIEl0IGlzIGNhbGxlZCB1bmRlciB3cml0ZSBsb2NrZWQgbXJ0X2xvY2suICovCisKK3N0YXRpYyB2b2lkIGlwbXJfdXBkYXRlX3RocmVzaG91bGRzKHN0cnVjdCBtZmNfY2FjaGUgKmNhY2hlLCB1bnNpZ25lZCBjaGFyICp0dGxzKQoreworCWludCB2aWZpOworCisJY2FjaGUtPm1mY191bi5yZXMub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reworCS8qIGluY3JlYXNlIHRoZSBtb2R1bGUgdXNlIGNvdW50ICovCisJaXBfdnNfdXNlX2NvdW50X2luYygpOworCisJZG93bigmX19pcF92c19hcHBfbXV0ZXgpOworCisJbGlzdF9hZGQoJmFwcC0+YV9saXN0LCAmaXBfdnNfYXBwX2xpc3QpOworCisJdXAoJl9faXBfdnNfYXBwX211dGV4KTsKKworCXJldHVybiAwOworfQorCisKKy8qCisgKglpcF92c19hcHAgdW5yZWdpc3RyYXRpb24gcm91dGluZQorICoJV2UgYXJlIHN1cmUgdGhlcmUgYXJlIG5vIGFwcCBpbmNhcm5hdGlvbnMgYXR0YWNoZWQgdG8gc2VydmljZXMKKyAqLwordm9pZCB1bnJlZ2lzdGVyX2lwX3ZzX2FwcChzdHJ1Y3QgaXBfdnNfYXBwICphcHApCit7CisJc3RydWN0IGlwX3ZzX2FwcCAqaW5jLCAqbnh0OworCisJZG93bigmX19pcF92c19hcHBfbXV0ZXgpOworCisJbGlzdF9mb3JfZWFjaF9lbnRyeV9zYWZlKGluYywgbnh0LCAmYXBwLT5pbmNzX2xpc3QsIGFfbGlzdCkgeworCQlpcF92c19hcHBfaW5jX3JlbGVhc2UoaW5jKTsKKwl9CisKKwlsaXN0X2RlbCgmYXBwLT5hX2xpc3QpOworCisJdXAoJl9faXBfdnNfYXBwX211dGV4KTsKKworCS8qIGRlY3JlYXNlIHRoZSBtb2R1bGUgdXNlIGNvdW50ICovCisJaXBfdnNfdXNlX2NvdW50X2RlYygpOworfQorCisKKyNpZiAwMDAwCisvKgorICoJR2V0IHJlZmVyZW5jZSB0byBhcHAgYnkgbmFtZSAoY2FsbGVkIGZyb20gdXNlciBjb250ZXh0KQorICovCitzdHJ1Y3QgaXBfdnNfYXBwICppcF92c19hcHBfZ2V0X2J5X25hbWUoY2hhciAqYXBwbmFtZSkKK3sKKwlzdHJ1Y3QgaXBfdnNfYXBwICphcHAsICphID0gTlVMTDsKKworCWRvd24oJl9faXBfdnNfYXBwX211dGV4KT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dGlvbikgYW55IGxhdGVyIHZlcnNpb24uCisgKgorICogQ2hhbmdlczoKKyAqICAgICBNYXJ0aW4gSGFtaWx0b24gICAgICAgICA6ICAgIGZpeGVkIHRoZSB0ZXJyaWJsZSBsb2NraW5nIGJ1Z3MKKyAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqbG9jayh0YmwtPmxvY2spID09PiAqbG9jaygmdGJsLT5sb2NrKQorICogICAgIFdlbnNvbmcgWmhhbmcgICAgICAgICAgIDogICAgZml4ZWQgdGhlIHVuaW5pdGlsaXplZCB0YmwtPmxvY2sgYnVnCisgKiAgICAgV2Vuc29uZyBaaGFuZyAgICAgICAgICAgOiAgICBhZGRlZCBkb2luZyBmdWxsIGV4cGlyYXRpb24gY2hlY2sgdG8KKyAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb2xsZWN0IHN0YWxlIGVudHJpZXMgb2YgMjQrIGhvdXJzIHdoZW4KKyAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBubyBwYXJ0aWFsIGV4cGlyZSBjaGVjayBpbiBhIGhhbGYgaG91cgorICogICAgIEp1bGlhbiBBbmFzdGFzb3YgICAgICAgIDogICAgcmVwbGFjZWQgZGVsX3RpbWVyIGNhbGwgd2l0aCBkZWxfdGltZXJfc3luYworICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRvIGF2b2lkIHRoZSBwb3NzaWJsZSByYWNlIGJldHdlZW4gdGltZXIKKyAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYW5kbGVyIGFuZCBkZWxfdGltZXIgdGhyZWFkIGluIFNNUAorICoKKyAqLworCisvKgorICogVGhlIGxibGMgYWxnb3JpdGhtIGlzIGFzIGZvbGxvd3MgKHBzZXVkbyBjb2RlKToKKyAqCisgKiAgICAgICBpZiBjYWNoZW5vZGVbZGVzdF9pcF0gaXMgbnVsbCB0aGVuCisgKiAgICAgICAgICAgICAgIG4sIGNhY2hl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AgICAgICAgICAgICBhZGRyOyAgICAgICAgICAgLyogZGVzdGluYXRpb24gSVAgYWRkcmVzcyAqLworCXN0cnVjdCBpcF92c19kZXN0ICAgICAgICpkZXN0OyAgICAgICAgICAvKiByZWFsIHNlcnZlciAoY2FjaGUpICovCisJdW5zaWduZWQgbG9uZyAgICAgICAgICAgbGFzdHVzZTsgICAgICAgIC8qIGxhc3QgdXNlZCB0aW1lICovCit9OworCisKKy8qCisgKiAgICAgIElQVlMgbGJsYyBoYXNoIHRhYmxlCisgKi8KK3N0cnVjdCBpcF92c19sYmxjX3RhYmxlIHsKKwlyd2xvY2tfdAkgICAgICAgIGxvY2s7ICAgICAgICAgICAvKiBsb2NrIGZvciB0aGlzIHRhYmxlICovCisJc3RydWN0IGxpc3RfaGVhZCAgICAgICAgYnVja2V0W0lQX1ZTX0xCTENfVEFCX1NJWkVdOyAgLyogaGFzaCBidWNrZXQgKi8KKwlhdG9taWNfdCAgICAgICAgICAgICAgICBlbnRyaWVzOyAgICAgICAgLyogbnVtYmVyIG9mIGVudHJpZXMgKi8KKwlpbnQgICAgICAgICAgICAgICAgICAgICBtYXhfc2l6ZTsgICAgICAgLyogbWF4aW11bSBzaXplIG9mIGVudHJpZXMgKi8KKwlzdHJ1Y3QgdGltZXJfbGlzdCAgICAgICBwZXJpb2RpY190aW1lcjsgLyogY29sbGVjdCBzdGFsZSBlbnRyaWVzICovCisJaW50ICAgICAgICAgICAgICAgICAgICAgcm92ZXI7ICAgICAgICAgIC8qIHJvdmVyIGZvciBleHBpcmUgY2hlY2sgKi8KKwlpbnQgICAgICAgICAgICAgICAgICAgICBjb3VudGVyOyAgICAgICAgLyogY291bnRlciBmb3Igbm8gZXhwaXJlICovCit9OworCisKKy8qCisgKiAgICAgIElQVlMgTEJMQyBzeXNjdGwgdGFibGUKKyAqLworCitzdGF0aWMgY3RsX3RhYmxlIHZzX3ZhcnNfdGFibGVbXSA9IHsKKwl7CisJCS5jdGxfbmFtZQk9IE5FVF9JUFY0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WNvbnRpbnVlOworCisJCQlpcF92c19sYmxjX2ZyZWUoZW4pOworCQkJYXRvbWljX2RlYygmdGJsLT5lbnRyaWVzKTsKKwkJfQorCQl3cml0ZV91bmxvY2soJnRibC0+bG9jayk7CisJfQorCXRibC0+cm92ZXIgPSBqOworfQorCisKKy8qCisgKiAgICAgIFBlcmlvZGljYWwgdGltZXIgaGFuZGxlciBmb3IgSVBWUyBsYmxjIHRhYmxlCisgKiAgICAgIEl0IGlzIHVzZWQgdG8gY29sbGVjdCBzdGFsZSBlbnRyaWVzIHdoZW4gdGhlIG51bWJlciBvZiBlbnRyaWVzCisgKiAgICAgIGV4Y2VlZHMgdGhlIG1heGltdW0gc2l6ZSBvZiB0aGUgdGFibGUuCisgKgorICogICAgICBGaXhtZTogd2UgcHJvYmFibHkgbmVlZCBtb3JlIGNvbXBsaWNhdGVkIGFsZ29yaXRobSB0byBjb2xsZWN0CisgKiAgICAgICAgICAgICBlbnRyaWVzIHRoYXQgaGF2ZSBub3QgYmVlbiB1c2VkIGZvciBhIGxvbmcgdGltZSBldmVuCisgKiAgICAgICAgICAgICBpZiB0aGUgbnVtYmVyIG9mIGVudHJpZXMgZG9lc24ndCBleGNlZWQgdGhlIG1heGltdW0gc2l6ZQorICogICAgICAgICAgICAgb2YgdGhlIHRhYmxlLgorICogICAgICBUaGUgZnVsbCBleHBpcmF0aW9uIGNoZWNrIGlzIGZvciB0aGlzIHB1cnBvc2Ugbm93LgorICovCitzdGF0aWMgdm9pZCBpcF92c19sYmxjX2NoZWNrX2V4cGlyZSh1bnNpZ25lZCBsb25nIGRhdGEpCit7CisJc3RydWN0IGlwX3ZzX2xibGNfdGFibGUgKnRibDsKKwl1bnNpZ25lZCBsb25nIG5vdyA9IGppZmZpZXM7CisJaW50IGdvYWw7CisJaW50IGksIGo7CisJc3RydWN0IGlwX3ZzX2xibGNfZW50cnkgKmVuLCAqbnh0OworCisJdGJsID0gKHN0cnVjdCBpcF92c19sYmxjX3RhYmxlICopZGF0Y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FtIGlzIGZyZWUgc29mdHdhcmU7IHlvdSBjYW4gcmVkaXN0cmlidXRlIGl0IGFuZC9vcgorICogICAgICAgICAgICAgIG1vZGlmeSBpdCB1bmRlciB0aGUgdGVybXMgb2YgdGhlIEdOVSBHZW5lcmFsIFB1YmxpYyBMaWNlbnNlCisgKiAgICAgICAgICAgICAgYXMgcHVibGlzaGVkIGJ5IHRoZSBGcmVlIFNvZnR3YXJlIEZvdW5kYXRpb247IGVpdGhlciB2ZXJzaW9uCisgKiAgICAgICAgICAgICAgMiBvZiB0aGUgTGljZW5zZSwgb3IgKGF0IHlvdXIgb3B0aW9uKSBhbnkgbGF0ZXIgdmVyc2lvbi4KKyAqCisgKiBDaGFuZ2VzOgorICogICAgIEp1bGlhbiBBbmFzdGFzb3YgICAgICAgIDogICAgQWRkZWQgdGhlIG1pc3NpbmcgKGRlc3QtPndlaWdodD4wKQorICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uZGl0aW9uIGluIHRoZSBpcF92c19kZXN0X3NldF9tYXguCisgKgorICovCisKKy8qCisgKiBUaGUgbGJsYy9yIGFsZ29yaXRobSBpcyBhcyBmb2xsb3dzIChwc2V1ZG8gY29kZSk6CisgKgorICogICAgICAgaWYgc2VydmVyU2V0W2Rlc3RfaXBdIGlzIG51bGwgdGhlbgorICogICAgICAgICAgICAgICBuLCBzZXJ2ZXJTZXRbZGVzdF9pcF0gPC0ge3dlaWdodGVkIGxlYXN0LWNvbm4gbm9kZX07CisgKiAgICAgICBlbHNlCisgKiAgICAgICAgICAgICAgIG4gPC0ge2xlYXN0LWNvbm4gKGFsaXZlKSBub2RlIGluIHNlcnZlclNldFtkZXN0X2lwXX07CisgKiAgICAgICAgICAgICAgIGlmIChuIGlzIG51bGwpIE9SCisgKiAgICAgICAgICAgICAgICAgIChuLmNvbm5zPm4ud2VpZ2h0IEFORAorICogICAgICAgICAgICAgICAgICAgdGhlcmUgaXMgYSBub2RlIG0gd2l0aCBtLmNvbm5zPG0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cmVzcyBhbmQgaXRzIGRlc3RpbmF0aW9uIHNlcnZlciBzZXQKKyAqLworc3RydWN0IGlwX3ZzX2xibGNyX2VudHJ5IHsKKwlzdHJ1Y3QgbGlzdF9oZWFkICAgICAgICBsaXN0OworCV9fdTMyICAgICAgICAgICAgICAgICAgIGFkZHI7ICAgICAgICAgICAvKiBkZXN0aW5hdGlvbiBJUCBhZGRyZXNzICovCisJc3RydWN0IGlwX3ZzX2Rlc3Rfc2V0ICAgc2V0OyAgICAgICAgICAgIC8qIGRlc3RpbmF0aW9uIHNlcnZlciBzZXQgKi8KKwl1bnNpZ25lZCBsb25nICAgICAgICAgICBsYXN0dXNlOyAgICAgICAgLyogbGFzdCB1c2VkIHRpbWUgKi8KK307CisKKworLyoKKyAqICAgICAgSVBWUyBsYmxjciBoYXNoIHRhYmxlCisgKi8KK3N0cnVjdCBpcF92c19sYmxjcl90YWJsZSB7CisJcndsb2NrX3QJICAgICAgICBsb2NrOyAgICAgICAgICAgLyogbG9jayBmb3IgdGhpcyB0YWJsZSAqLworCXN0cnVjdCBsaXN0X2hlYWQgICAgICAgIGJ1Y2tldFtJUF9WU19MQkxDUl9UQUJfU0laRV07ICAvKiBoYXNoIGJ1Y2tldCAqLworCWF0b21pY190ICAgICAgICAgICAgICAgIGVudHJpZXM7ICAgICAgICAvKiBudW1iZXIgb2YgZW50cmllcyAqLworCWludCAgICAgICAgICAgICAgICAgICAgIG1heF9zaXplOyAgICAgICAvKiBtYXhpbXVtIHNpemUgb2YgZW50cmllcyAqLworCXN0cnVjdCB0aW1lcl9saXN0ICAgICAgIHBlcmlvZGljX3RpbWVyOyAvKiBjb2xsZWN0IHN0YWxlIGVudHJpZXMgKi8KKwlpbnQgICAgICAgICAgICAgICAgICAgICByb3ZlcjsgICAgICAgICAgLyogcm92ZXIgZm9yIGV4cGlyZSBjaGVjayAqLworCWludCAgICAgICAgICAgICAgICAgICAgIGNvdW50ZXI7ICAgICAgICAvKiBjb3VudGVyIGZvciBubyBleH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ICAgICAvKiBXaGljaCBwcm90b2NvbCAoVENQL1VEUCkgKi8KKwlfX3UxNgkJCWNwb3J0OworCV9fdTE2ICAgICAgICAgICAgICAgICAgIHZwb3J0OworCV9fdTE2ICAgICAgICAgICAgICAgICAgIGRwb3J0OworCV9fdTMyICAgICAgICAgICAgICAgICAgIGNhZGRyOyAgICAgICAgICAvKiBjbGllbnQgYWRkcmVzcyAqLworCV9fdTMyICAgICAgICAgICAgICAgICAgIHZhZGRyOyAgICAgICAgICAvKiB2aXJ0dWFsIGFkZHJlc3MgKi8KKwlfX3UzMiAgICAgICAgICAgICAgICAgICBkYWRkcjsgICAgICAgICAgLyogZGVzdGluYXRpb24gYWRkcmVzcyAqLworCisJLyogRmxhZ3MgYW5kIHN0YXRlIHRyYW5zaXRpb24gKi8KKwlfX3UxNiAgICAgICAgICAgICAgICAgICBmbGFnczsgICAgICAgICAgLyogc3RhdHVzIGZsYWdzICovCisJX191MTYgICAgICAgICAgICAgICAgICAgc3RhdGU7ICAgICAgICAgIC8qIHN0YXRlIGluZm8gKi8KKworCS8qIFRoZSBzZXF1ZW5jZSBvcHRpb25zIHN0YXJ0IGhlcmUgKi8KK307CisKK3N0cnVjdCBpcF92c19zeW5jX2Nvbm5fb3B0aW9ucyB7CisJc3RydWN0IGlwX3ZzX3NlcSAgICAgICAgaW5fc2VxOyAgICAgICAgIC8qIGluY29taW5nIHNlcS4gc3RydWN0ICovCisJc3RydWN0IGlwX3ZzX3NlcSAgICAgICAgb3V0X3NlcTsgICAgICAgIC8qIG91dGdvaW5nIHNlcS4gc3RydWN0ICovCit9OworCisjZGVmaW5lIElQX1ZTX1NZTkNfQ09OTl9USU1FT1VUICgzKjYwKkhaKQorI2RlZmluZSBTSU1QTEVfQ09OTl9TSVpFICAoc2l6ZW9mKHN0cnVjdCBpcF92c19zeW5jX2Nvbm4pKQorI2RlZmluZSBGVUxMX0NPTk5fU0laRSAgXAorKHNpemVvZihzdHJ1Y3QgaXBfdnNfc3luY19jb25uKSArIHNpemVvZihzdHJ1Y3QgaXBfdnNfc3luY19jb25uX29wdGlvbnMpKQorCisKKy8qCisgIFRoZSBtYXN0ZXIgbXVsaXRjYXN0cyBtZXNzYWdlcyB0byB0aGUgYmFja3VwIGxvYWQgYmFsYW5jZXJzIGluIHRoZQorICBmb2xsb3dpbmcgZm9ybWF0LgorCisgICAgICAgMCAgICAgICAgICAgICAgICAgICAxICAgICAgICAgICAgICAgICAgIDIgICAgICAgICAgICAgICAgICAgMworICAgICAgIDAgMSAyIDMgNCA1IDYgNyA4IDkgMCAxIDIgMyA0IDUgNiA3IDggOSAwIDEgMiAzIDQgNSA2IDcgOCA5IDAgMQorICAgICAgKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSsKKyAgICAgIHwgIENvdW50IENvbm5zICB8ICAgIFN5bmNJRCAgICAgfCAgICAgICAgICAgIFNpemUgICAgICAgICAgICAgICB8CisgICAgICArLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKworICAgICAgfCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwKKyAgICAgIHwgICAgICAgICAgICAgICAgICAgIElQVlMgU3luYyBDb25uZWN0aW9uICgxKSAgICAgICAgICAgICAgICAgICB8CisgICAgICArLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKworICAgICAgfCAgICAgICAgICAgICAgICAgICAgICAgICAgICAuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwKKyAgICAgIHwgICAgICAgICAgICAgICAgICAgICAgICAgICAgLiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB8CisgICAgICB8ICAgICAgICAgICAgICAgICAgICAgICAgICAgIC4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfAorICAgICAgKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSsKKyAgICAgIHwgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB8CisgICAgICB8ICAgICAgICAgICAgICAgICAgICBJUFZTIFN5bmMgQ29ubmVjdGlvbiAobikgICAgICAgICAgICAgICAgICAgfAorICAgICAgKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSsKKyovCisKKyNkZWZpbmUgU1lOQ19NRVNHX0hFQURFUl9MRU4JNAorCitzdHJ1Y3QgaXBfdnNfc3luY19tZXNnIHsKKwlfX3U4ICAgICAgICAgICAgICAgICAgICBucl9jb25uczsKKwlfX3U4ICAgICAgICAgICAgICAgICAgICBzeW5jaWQ7CisJX191MTYgICAgICAgICAgICAgICAgICAgc2l6ZTsKKworCS8qIGlwX3ZzX3N5bmNfY29ubiBlbnRyaWVzIHN0YXJ0IGhlcmUgKi8KK307CisKKy8qIHRoZSBtYXhpbXVtIGxlbmd0aCBvZiBzeW5jIChzZW5kaW5nL3JlY2VpdmluZykgbWVzc2FnZSAqLworc3RhdGljIGludCBzeW5jX3NlbmRfbWVzZ19tYXhsZW47CitzdGF0aWMgaW50IHN5bmNfcmVjdl9tZXNnX21heGxlbjsKKworc3RydWN0IGlwX3ZzX3N5bmNfYnVmZiB7CisJc3RydWN0IGxpc3RfaGVhZCAgICAgICAgbGlzdDsKKwl1bnNpZ25lZCBsb25nICAgICAgICAgICBmaXJzdHVzZTsKKworCS8qIHBvaW50ZXJzIGZvciB0aGUgbWVzc2FnZSBkYXRhICovCisJc3RydWN0IGlwX3ZzX3N5bmNfbWVzZyAgKm1lc2c7CisJdW5zaWduZWQgY2hhciAgICAgICAgICAgKmhlYWQ7C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Y2hhbmdlZCBmb3IgdGhlIGQtbGlua2VkIGRlc3RpbmF0aW9uIGxpc3QKKyAqICAgICBXZW5zb25nIFpoYW5nICAgICAgICAgICAgOiAgICAgYWRkZWQgdGhlIGlwX3ZzX3dycl91cGRhdGVfc3ZjCisgKiAgICAgSnVsaWFuIEFuYXN0YXNvdiAgICAgICAgIDogICAgIGZpeGVkIHRoZSBidWcgb2YgcmV0dXJuaW5nIGRlc3RpbmF0aW9uCisgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdpdGggd2VpZ2h0IDAgd2hlbiBhbGwgd2VpZ2h0cyBhcmUgemVybworICoKKyAqLworCisjaW5jbHVkZSA8bGludXgvbW9kdWxlLmg+CisjaW5jbHVkZSA8bGludXgva2VybmVsLmg+CisKKyNpbmNsdWRlIDxuZXQvaXBfdnMuaD4KKworLyoKKyAqIGN1cnJlbnQgZGVzdGluYXRpb24gcG9pbnRlciBmb3Igd2VpZ2h0ZWQgcm91bmQtcm9iaW4gc2NoZWR1bGluZworICovCitzdHJ1Y3QgaXBfdnNfd3JyX21hcmsgeworCXN0cnVjdCBsaXN0X2hlYWQgKmNsOwkvKiBjdXJyZW50IGxpc3QgaGVhZCAqLworCWludCBjdzsJCQkvKiBjdXJyZW50IHdlaWdodCAqLworCWludCBtdzsJCQkvKiBtYXhpbXVtIHdlaWdodCAqLworCWludCBkaTsJCQkvKiBkZWNyZWFzaW5nIGludGVydmFsICovCit9OworCisKKy8qCisgKiAgICBHZXQgdGhlIGdjZCBvZiBzZXJ2ZXIgd2VpZ2h0cworICovCitzdGF0aWMgaW50IGdjZChpbnQgYSwgaW50IGIpCit7CisJaW50IGM7CisKKwl3aGlsZSAoKGMgPSBhICUgYikpIHsKKwkJYSA9IGI7CisJCWIgPSBjOworCX0KKwlyZXR1cm4gYjsKK30KKworc3RhdGljIGludCBpcF92c193cnJfZ2NkX3dlaWdodChzdHJ1Y3QgaXBfdnNfc2VydmljZSAqc3ZjKQoreworCXN0cnV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25hdF9mdHAubworb2JqLSQoQ09ORklHX0lQX05GX05BVF9JUkMpICs9IGlwX25hdF9pcmMubworCisjIGdlbmVyaWMgSVAgdGFibGVzIAorb2JqLSQoQ09ORklHX0lQX05GX0lQVEFCTEVTKSArPSBpcF90YWJsZXMubworCisjIHRoZSB0aHJlZSBpbnN0YW5jZXMgb2YgaXBfdGFibGVzCitvYmotJChDT05GSUdfSVBfTkZfRklMVEVSKSArPSBpcHRhYmxlX2ZpbHRlci5vCitvYmotJChDT05GSUdfSVBfTkZfTUFOR0xFKSArPSBpcHRhYmxlX21hbmdsZS5vCitvYmotJChDT05GSUdfSVBfTkZfTkFUKSArPSBpcHRhYmxlX25hdC5vCitvYmotJChDT05GSUdfSVBfTkZfUkFXKSArPSBpcHRhYmxlX3Jhdy5vCisKKyMgbWF0Y2hlcworb2JqLSQoQ09ORklHX0lQX05GX01BVENIX0hFTFBFUikgKz0gaXB0X2hlbHBlci5vCitvYmotJChDT05GSUdfSVBfTkZfTUFUQ0hfTElNSVQpICs9IGlwdF9saW1pdC5vCitvYmotJChDT05GSUdfSVBfTkZfTUFUQ0hfSEFTSExJTUlUKSArPSBpcHRfaGFzaGxpbWl0Lm8KK29iai0kKENPTkZJR19JUF9ORl9NQVRDSF9TQ1RQKSArPSBpcHRfc2N0cC5vCitvYmotJChDT05GSUdfSVBfTkZfTUFUQ0hfTUFSSykgKz0gaXB0X21hcmsubworb2JqLSQoQ09ORklHX0lQX05GX01BVENIX01BQykgKz0gaXB0X21hYy5vCitvYmotJChDT05GSUdfSVBfTkZfTUFUQ0hfSVBSQU5HRSkgKz0gaXB0X2lwcmFuZ2Uubworb2JqLSQoQ09ORklHX0lQX05GX01BVENIX1BLVFRZUEUpICs9IGlwdF9wa3R0eXBlLm8KK29iai0kKENPTkZJR19JUF9ORl9NQVRDSF9NVUxUSVBPUlQpICs9IGlwdF9tdWx0aXBvcnQubworb2JqLSQoQ09ORklHX0lQX05GX01BVENIX09XTkVSKSArPSBpcHRfb3du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H0gd2hpbGUoMCkKKworI2lmZGVmIENPTkZJR19TTVAKKyNkZWZpbmUgVEFCTEVfT0ZGU0VUKHQscCkgKFNNUF9BTElHTigodCktPnNpemUpKihwKSkKKyNlbHNlCisjZGVmaW5lIFRBQkxFX09GRlNFVCh0LHApIDAKKyNlbmRpZgorCitzdGF0aWMgaW5saW5lIGludCBhcnBfZGV2YWRkcl9jb21wYXJlKGNvbnN0IHN0cnVjdCBhcnB0X2RldmFkZHJfaW5mbyAqYXAsCisJCQkJICAgICAgY2hhciAqaGRyX2FkZHIsIGludCBsZW4pCit7CisJaW50IGksIHJldDsKKworCWlmIChsZW4gPiBBUlBUX0RFVl9BRERSX0xFTl9NQVgpCisJCWxlbiA9IEFSUFRfREVWX0FERFJfTEVOX01BWDsKKworCXJldCA9IDA7CisJZm9yIChpID0gMDsgaSA8IGxlbjsgaSsrKQorCQlyZXQgfD0gKGhkcl9hZGRyW2ldIF4gYXAtPmFkZHJbaV0pICYgYXAtPm1hc2tbaV07CisKKwlyZXR1cm4gKHJldCAhPSAwKTsKK30KKworLyogUmV0dXJucyB3aGV0aGVyIHBhY2tldCBtYXRjaGVzIHJ1bGUgb3Igbm90LiAqLworc3RhdGljIGlubGluZSBpbnQgYXJwX3BhY2tldF9tYXRjaChjb25zdCBzdHJ1Y3QgYXJwaGRyICphcnBoZHIsCisJCQkJICAgc3RydWN0IG5ldF9kZXZpY2UgKmRldiwKKwkJCQkgICBjb25zdCBjaGFyICppbmRldiwKKwkJCQkgICBjb25zdCBjaGFyICpvdXRkZXYsCisJCQkJICAgY29uc3Qgc3RydWN0IGFycHRfYXJwICphcnBpbmZvKQoreworCWNoYXIgKmFycHB0ciA9IChjaGFyICopKGFycGhkciArIDEpOworCWNoYXIgKnNyY19kZXZhZGRyLCAqdGd0X2RldmFkZHI7CisJdTMyIHNyY19pcGFkZHIsIHRndF9pcGFkZHI7CisJaW50IGksIHJldDsKKworI2RlZmluZSBGV0lOVihib29sLGludmZsZykgKChib29sKSBe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SBlLCBlLT5uZXh0X29mZnNldCk7CisJCXJldHVybiAtRUlOVkFMOworCX0KKworCS8qIENoZWNrIGhvb2tzICYgdW5kZXJmbG93cyAqLworCWZvciAoaCA9IDA7IGggPCBORl9BUlBfTlVNSE9PS1M7IGgrKykgeworCQlpZiAoKHVuc2lnbmVkIGNoYXIgKillIC0gYmFzZSA9PSBob29rX2VudHJpZXNbaF0pCisJCQluZXdpbmZvLT5ob29rX2VudHJ5W2hdID0gaG9va19lbnRyaWVzW2hdOworCQlpZiAoKHVuc2lnbmVkIGNoYXIgKillIC0gYmFzZSA9PSB1bmRlcmZsb3dzW2hdKQorCQkJbmV3aW5mby0+dW5kZXJmbG93W2hdID0gdW5kZXJmbG93c1toXTsKKwl9CisKKwkvKiBGSVhNRTogdW5kZXJmbG93cyBtdXN0IGJlIHVuY29uZGl0aW9uYWwsIHN0YW5kYXJkIHZlcmRpY3RzCisgICAgICAgICAgIDwgMCAobm90IEFSUFRfUkVUVVJOKS4gLS1SUiAqLworCisJLyogQ2xlYXIgY291bnRlcnMgYW5kIGNvbWVmcm9tICovCisJZS0+Y291bnRlcnMgPSAoKHN0cnVjdCBhcnB0X2NvdW50ZXJzKSB7IDAsIDAgfSk7CisJZS0+Y29tZWZyb20gPSAwOworCisJKCppKSsrOworCXJldHVybiAwOworfQorCitzdGF0aWMgaW5saW5lIGludCBjbGVhbnVwX2VudHJ5KHN0cnVjdCBhcnB0X2VudHJ5ICplLCB1bnNpZ25lZCBpbnQgKmkpCit7CisJc3RydWN0IGFycHRfZW50cnlfdGFyZ2V0ICp0OworCisJaWYgKGkgJiYgKCppKS0tID09IDApCisJCXJldHVybiAxOworCisJdCA9IGFycHRfZ2V0X3RhcmdldChlKTsKKwlpZiAodC0+dS5rZXJuZWwudGFyZ2V0LT5kZXN0cm95KQorCQl0LT51Lmtlcm5lbC50YXJnZXQtPmRlc3Ryb3kodC0+ZGF0YSwKKwkJCQkJICAgIHQtPnUudGFyZ2V0X3NpemUgLSBzaXplb2YoKnQpKTsKKwltb2R1bGVfcHV0KHQtPnUua2VybmVsLnRhcmdldC0+bWUpOworCXJldHVybiAwOworfQorCisvKiBDaGVja3MgYW5kIHRyYW5zbGF0ZXMgdGhlIHVzZXItc3VwcGxpZWQgdGFibGUgc2VnbWVudCAoaGVsZCBpbgorICogbmV3aW5mbykuCisgKi8KK3N0YXRpYyBpbnQgdHJhbnNsYXRlX3RhYmxlKGNvbnN0IGNoYXIgKm5hbWUsCisJCQkgICB1bnNpZ25lZCBpbnQgdmFsaWRfaG9va3MsCisJCQkgICBzdHJ1Y3QgYXJwdF90YWJsZV9pbmZvICpuZXdpbmZvLAorCQkJICAgdW5zaWduZWQgaW50IHNpemUsCisJCQkgICB1bnNpZ25lZCBpbnQgbnVtYmVyLAorCQkJICAgY29uc3QgdW5zaWduZWQgaW50ICpob29rX2VudHJpZXMsCisJCQkgICBjb25zdCB1bnNpZ25lZCBpbnQgKnVuZGVyZmxvd3MpCit7CisJdW5zaWduZWQgaW50IGk7CisJaW50IHJldDsKKworCW5ld2luZm8tPnNpemUgPSBzaXplOworCW5ld2luZm8tPm51bWJlciA9IG51bWJlcjsKKworCS8qIEluaXQgYWxsIGhvb2tzIHRvIGltcG9zc2libGUgdmFsdWUuICovCisJZm9yIChpID0gMDsgaSA8IE5GX0FSUF9OVU1IT09LUzsgaSsrKSB7CisJCW5ld2luZm8tPmhvb2tfZW50cnlbaV0gPSAweEZGRkZGRkZGOworCQluZXdpbmZvLT51bmRlcmZsb3dbaV0gPSAweEZGRkZGRkZGOworCX0KKworCWR1cHJpbnRmKCJ0cmFuc2xhdGVfdGFibGU6IHNpemUgJXVcbiIsIG5ld2luZm8tPnNpemUpOworCWkgPSAwOworCisJLyogV2FsayB0aHJvdWdoIGVudHJpZXMsIGNoZWNraW5nIG9mZnNldHMuICovCisJcmV0ID0gQVJQVF9FTlRSWV9JVEVSQVRFKG5ld2luZm8tPmVudHJpZXMsIG5ld2luZm8tPnNpemUsCisJCQkJIGNoZWN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ID0gLUVGQVVMVDsKKwkJZ290byBmcmVlX25ld2luZm87CisJfQorCisJY291bnRlcnMgPSB2bWFsbG9jKHRtcC5udW1fY291bnRlcnMgKiBzaXplb2Yoc3RydWN0IGFycHRfY291bnRlcnMpKTsKKwlpZiAoIWNvdW50ZXJzKSB7CisJCXJldCA9IC1FTk9NRU07CisJCWdvdG8gZnJlZV9uZXdpbmZvOworCX0KKwltZW1zZXQoY291bnRlcnMsIDAsIHRtcC5udW1fY291bnRlcnMgKiBzaXplb2Yoc3RydWN0IGFycHRfY291bnRlcnMpKTsKKworCXJldCA9IHRyYW5zbGF0ZV90YWJsZSh0bXAubmFtZSwgdG1wLnZhbGlkX2hvb2tzLAorCQkJICAgICAgbmV3aW5mbywgdG1wLnNpemUsIHRtcC5udW1fZW50cmllcywKKwkJCSAgICAgIHRtcC5ob29rX2VudHJ5LCB0bXAudW5kZXJmbG93KTsKKwlpZiAocmV0ICE9IDApCisJCWdvdG8gZnJlZV9uZXdpbmZvX2NvdW50ZXJzOworCisJZHVwcmludGYoImFycF90YWJsZXM6IFRyYW5zbGF0ZWQgdGFibGVcbiIpOworCisJdCA9IGFycHRfZmluZF90YWJsZV9sb2NrKHRtcC5uYW1lLCAmcmV0LCAmYXJwdF9tdXRleCk7CisJaWYgKCF0KQorCQlnb3RvIGZyZWVfbmV3aW5mb19jb3VudGVyc191bnRyYW5zOworCisJLyogWW91IGxpZWQhICovCisJaWYgKHRtcC52YWxpZF9ob29rcyAhPSB0LT52YWxpZF9ob29rcykgeworCQlkdXByaW50ZigiVmFsaWQgaG9vayBjcmFwOiAlMDhYIHZzICUwOFhcbiIsCisJCQkgdG1wLnZhbGlkX2hvb2tzLCB0LT52YWxpZF9ob29rcyk7CisJCXJldCA9IC1FSU5WQUw7CisJCWdvdG8gZnJlZV9uZXdpbmZvX2NvdW50ZXJzX3VudHJhbnNfdW5sb2NrOworCX0KKworCS8qIEdldCBhIHJlZmVyZW5jZSBpbiBhZHZhbmNlLCB3ZSdyZ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tPmNvdW50ZXJzLAorCQkJICAgJmkpOworIHVubG9ja191cF9mcmVlOgorCXdyaXRlX3VubG9ja19iaCgmdC0+bG9jayk7CisJdXAoJmFycHRfbXV0ZXgpOworIGZyZWU6CisJdmZyZWUocGFkZGMpOworCisJcmV0dXJuIHJldDsKK30KKworc3RhdGljIGludCBkb19hcnB0X3NldF9jdGwoc3RydWN0IHNvY2sgKnNrLCBpbnQgY21kLCB2b2lkIF9fdXNlciAqdXNlciwgdW5zaWduZWQgaW50IGxlbikKK3sKKwlpbnQgcmV0OworCisJaWYgKCFjYXBhYmxlKENBUF9ORVRfQURNSU4pKQorCQlyZXR1cm4gLUVQRVJNOworCisJc3dpdGNoIChjbWQpIHsKKwljYXNlIEFSUFRfU09fU0VUX1JFUExBQ0U6CisJCXJldCA9IGRvX3JlcGxhY2UodXNlciwgbGVuKTsKKwkJYnJlYWs7CisKKwljYXNlIEFSUFRfU09fU0VUX0FERF9DT1VOVEVSUzoKKwkJcmV0ID0gZG9fYWRkX2NvdW50ZXJzKHVzZXIsIGxlbik7CisJCWJyZWFrOworCisJZGVmYXVsdDoKKwkJZHVwcmludGYoImRvX2FycHRfc2V0X2N0bDogIHVua25vd24gcmVxdWVzdCAlaVxuIiwgY21kKTsKKwkJcmV0ID0gLUVJTlZBTDsKKwl9CisKKwlyZXR1cm4gcmV0OworfQorCitzdGF0aWMgaW50IGRvX2FycHRfZ2V0X2N0bChzdHJ1Y3Qgc29jayAqc2ssIGludCBjbWQsIHZvaWQgX191c2VyICp1c2VyLCBpbnQgKmxlbikKK3sKKwlpbnQgcmV0OworCisJaWYgKCFjYXBhYmxlKENBUF9ORVRfQURNSU4pKQorCQlyZXR1cm4gLUVQRVJNOworCisJc3dpdGNoIChjbWQpIHsKKwljYXNlIEFSUFRfU09fR0VUX0lORk86IHsKKwkJY2hhciBuYW1lW0FSUFRfVEFCTEVfTUFYTkFNRUxFTl07CisJCXN0cnVjdCBhcnB0X3RhYmxlICp0OworCisJCWlmICgqbG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TkFMXS50dXBsZSA9ICp0dXBsZTsKKwljb25udHJhY2stPnR1cGxlaGFzaFtJUF9DVF9ESVJfUkVQTFldLnR1cGxlID0gcmVwbF90dXBsZTsKKwlpZiAoIXByb3RvY29sLT5uZXcoY29ubnRyYWNrLCBza2IpKSB7CisJCWttZW1fY2FjaGVfZnJlZShpcF9jb25udHJhY2tfY2FjaGVwLCBjb25udHJhY2spOworCQlyZXR1cm4gTlVMTDsKKwl9CisJLyogRG9uJ3Qgc2V0IHRpbWVyIHlldDogd2FpdCBmb3IgY29uZmlybWF0aW9uICovCisJaW5pdF90aW1lcigmY29ubnRyYWNrLT50aW1lb3V0KTsKKwljb25udHJhY2stPnRpbWVvdXQuZGF0YSA9ICh1bnNpZ25lZCBsb25nKWNvbm50cmFjazsKKwljb25udHJhY2stPnRpbWVvdXQuZnVuY3Rpb24gPSBkZWF0aF9ieV90aW1lb3V0OworCisJV1JJVEVfTE9DSygmaXBfY29ubnRyYWNrX2xvY2spOworCWV4cCA9IGZpbmRfZXhwZWN0YXRpb24odHVwbGUpOworCisJaWYgKGV4cCkgeworCQlERUJVR1AoImNvbm50cmFjazogZXhwZWN0YXRpb24gYXJyaXZlcyBjdD0lcCBleHA9JXBcbiIsCisJCQljb25udHJhY2ssIGV4cCk7CisJCS8qIFdlbGNvbWUsIE1yLiBCb25kLiAgV2UndmUgYmVlbiBleHBlY3RpbmcgeW91Li4uICovCisJCV9fc2V0X2JpdChJUFNfRVhQRUNURURfQklULCAmY29ubnRyYWNrLT5zdGF0dXMpOworCQljb25udHJhY2stPm1hc3RlciA9IGV4cC0+bWFzdGVyOworI2lmIENPTkZJR19JUF9ORl9DT05OVFJBQ0tfTUFSSworCQljb25udHJhY2stPm1hcmsgPSBleHAtPm1hc3Rlci0+bWFyazsKKyNlbmRpZgorCQluZl9jb25udHJhY2tfZ2V0KCZjb25udHJhY2stPm1hc3Rlci0+Y3RfZ2VuZXJhbCk7CisJCUNPTk5UUkFDS19TVEFUX0lOQyhleHB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QkgICAgICAgICpjdGluZm8gPSBJUF9DVF9FU1RBQkxJU0hFRDsKKwkJfSBlbHNlIGlmICh0ZXN0X2JpdChJUFNfRVhQRUNURURfQklULCAmY3QtPnN0YXR1cykpIHsKKwkJCURFQlVHUCgiaXBfY29ubnRyYWNrX2luOiByZWxhdGVkIHBhY2tldCBmb3IgJXBcbiIsCisJCQkgICAgICAgY3QpOworCQkJKmN0aW5mbyA9IElQX0NUX1JFTEFURUQ7CisJCX0gZWxzZSB7CisJCQlERUJVR1AoImlwX2Nvbm50cmFja19pbjogbmV3IHBhY2tldCBmb3IgJXBcbiIsCisJCQkgICAgICAgY3QpOworCQkJKmN0aW5mbyA9IElQX0NUX05FVzsKKwkJfQorCQkqc2V0X3JlcGx5ID0gMDsKKwl9CisJc2tiLT5uZmN0ID0gJmN0LT5jdF9nZW5lcmFsOworCXNrYi0+bmZjdGluZm8gPSAqY3RpbmZvOworCXJldHVybiBjdDsKK30KKworLyogTmV0ZmlsdGVyIGhvb2sgaXRzZWxmLiAqLwordW5zaWduZWQgaW50IGlwX2Nvbm50cmFja19pbih1bnNpZ25lZCBpbnQgaG9va251bSwKKwkJCSAgICAgc3RydWN0IHNrX2J1ZmYgKipwc2tiLAorCQkJICAgICBjb25zdCBzdHJ1Y3QgbmV0X2RldmljZSAqaW4sCisJCQkgICAgIGNvbnN0IHN0cnVjdCBuZXRfZGV2aWNlICpvdXQsCisJCQkgICAgIGludCAoKm9rZm4pKHN0cnVjdCBza19idWZmICopKQoreworCXN0cnVjdCBpcF9jb25udHJhY2sgKmN0OworCWVudW0gaXBfY29ubnRyYWNrX2luZm8gY3RpbmZvOworCXN0cnVjdCBpcF9jb25udHJhY2tfcHJvdG9jb2wgKnByb3RvOworCWludCBzZXRfcmVwbHk7CisJaW50IHJldDsKKworCS8qIFByZXZpb3VzbHkgc2VlbiAobG9vcGJhY2sgb3IgdW50cmFja2VkKT8gIElnbm9yZS4gKi8KKwlpZiAoKCpwc2tiKS0+bmZjdCkgewor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CXRoID0gc2tiX2hlYWRlcl9wb2ludGVyKHNrYiwgaXBoLT5paGwgKiA0LAorCQkJCXNpemVvZihfdGNwaCksICZfdGNwaCk7CisJQlVHX09OKHRoID09IE5VTEwpOworCQorCS8qIERvbid0IG5lZWQgbG9jayBoZXJlOiB0aGlzIGNvbm50cmFjayBub3QgaW4gY2lyY3VsYXRpb24geWV0ICovCisJbmV3X3N0YXRlCisJCT0gdGNwX2Nvbm50cmFja3NbMF1bZ2V0X2Nvbm50cmFja19pbmRleCh0aCldCisJCVtUQ1BfQ09OTlRSQUNLX05PTkVdOworCisJLyogSW52YWxpZDogZGVsZXRlIGNvbm50cmFjayAqLworCWlmIChuZXdfc3RhdGUgPj0gVENQX0NPTk5UUkFDS19NQVgpIHsKKwkJREVCVUdQKCJpcF9jdF90Y3A6IGludmFsaWQgbmV3IGRlbGV0aW5nLlxuIik7CisJCXJldHVybiAwOworCX0KKworCWlmIChuZXdfc3RhdGUgPT0gVENQX0NPTk5UUkFDS19TWU5fU0VOVCkgeworCQkvKiBTWU4gcGFja2V0ICovCisJCWNvbm50cmFjay0+cHJvdG8udGNwLnNlZW5bMF0udGRfZW5kID0KKwkJCXNlZ21lbnRfc2VxX3BsdXNfbGVuKG50b2hsKHRoLT5zZXEpLCBza2ItPmxlbiwKKwkJCQkJICAgICBpcGgsIHRoKTsKKwkJY29ubnRyYWNrLT5wcm90by50Y3Auc2VlblswXS50ZF9tYXh3aW4gPSBudG9ocyh0aC0+d2luZG93KTsKKwkJaWYgKGNvbm50cmFjay0+cHJvdG8udGNwLnNlZW5bMF0udGRfbWF4d2luID09IDApCisJCQljb25udHJhY2stPnByb3RvLnRjcC5zZWVuWzBdLnRkX21heHdpbiA9IDE7CisJCWNvbm50cmFjay0+cHJvdG8udGNwLnNlZW5bMF0udGRfbWF4ZW5kID0KKwkJCWNvbm50cmFjay0+cHJvdG8udGNwLnNlZW5bMF0udGRfZW5kOworCisJCXRjcF9vcHRpb25zKHNrYiwgaXBoLCB0a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WNrID0gdHVwbGVoYXNoX3RvX2N0cmFjayhoYXNoKTsKKwlzdHJ1Y3QgaXBfY29ubnRyYWNrX3Byb3RvY29sICpwcm90bzsKKworCU1VU1RfQkVfUkVBRF9MT0NLRUQoJmlwX2Nvbm50cmFja19sb2NrKTsKKwlJUF9ORl9BU1NFUlQoY29ubnRyYWNrKTsKKworCS8qIHdlIG9ubHkgd2FudCB0byBwcmludCBESVJfT1JJR0lOQUwgKi8KKwlpZiAoRElSRUNUSU9OKGhhc2gpKQorCQlyZXR1cm4gMDsKKworCXByb3RvID0gaXBfY3RfZmluZF9wcm90byhjb25udHJhY2stPnR1cGxlaGFzaFtJUF9DVF9ESVJfT1JJR0lOQUxdCisJCQkgICAgICAgLnR1cGxlLmRzdC5wcm90b251bSk7CisJSVBfTkZfQVNTRVJUKHByb3RvKTsKKworCWlmIChzZXFfcHJpbnRmKHMsICIlLThzICV1ICVsZCAiLAorCQkgICAgICBwcm90by0+bmFtZSwKKwkJICAgICAgY29ubnRyYWNrLT50dXBsZWhhc2hbSVBfQ1RfRElSX09SSUdJTkFMXS50dXBsZS5kc3QucHJvdG9udW0sCisJCSAgICAgIHRpbWVyX3BlbmRpbmcoJmNvbm50cmFjay0+dGltZW91dCkKKwkJICAgICAgPyAobG9uZykoY29ubnRyYWNrLT50aW1lb3V0LmV4cGlyZXMgLSBqaWZmaWVzKS9IWgorCQkgICAgICA6IDApICE9IDApCisJCXJldHVybiAtRU5PU1BDOworCisJaWYgKHByb3RvLT5wcmludF9jb25udHJhY2socywgY29ubnRyYWNrKSkKKwkJcmV0dXJuIC1FTk9TUEM7CisgIAorCWlmIChwcmludF90dXBsZShzLCAmY29ubnRyYWNrLT50dXBsZWhhc2hbSVBfQ1RfRElSX09SSUdJTkFMXS50dXBsZSwKKwkJCXByb3RvKSkKKwkJcmV0dXJuIC1FTk9TUEM7CisKKyAJaWYgKHNlcV9wcmludF9jb3VudGVycyhzLCAmY29ubnRyYWNrLT5jb3VudGVyc1tJUF9D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NzZXMgYXJlIG5vdCB0b28gdW5jb21tb24sIGFzIEFsYW4gQ294IHBvaW50cworCSAgIG91dCkgKi8KKwlpZiAobWFuaXAgIT0gSVBfTkFUX01BTklQX1NSQworCSAgICB8fCAoKCpwc2tiKS0+bmguaXBoLT5zYWRkciA9PSBjdC0+dHVwbGVoYXNoW2Rpcl0udHVwbGUuc3JjLmlwKSkgeworCQlpbnZlcnRfdHVwbGVwcigmdGFyZ2V0LCAmY3QtPnR1cGxlaGFzaFshZGlyXS50dXBsZSk7CisJCWlmICghbWFuaXBfcGt0KDAsIHBza2IsIDAsICZ0YXJnZXQsIG1hbmlwKSkKKwkJCXJldHVybiAwOworCX0KKworCXJldHVybiAxOworfQorCisvKiBQcm90b2NvbCByZWdpc3RyYXRpb24uICovCitpbnQgaXBfbmF0X3Byb3RvY29sX3JlZ2lzdGVyKHN0cnVjdCBpcF9uYXRfcHJvdG9jb2wgKnByb3RvKQoreworCWludCByZXQgPSAwOworCisJV1JJVEVfTE9DSygmaXBfbmF0X2xvY2spOworCWlmIChpcF9uYXRfcHJvdG9zW3Byb3RvLT5wcm90b251bV0gIT0gJmlwX25hdF91bmtub3duX3Byb3RvY29sKSB7CisJCXJldCA9IC1FQlVTWTsKKwkJZ290byBvdXQ7CisJfQorCWlwX25hdF9wcm90b3NbcHJvdG8tPnByb3RvbnVtXSA9IHByb3RvOworIG91dDoKKwlXUklURV9VTkxPQ0soJmlwX25hdF9sb2NrKTsKKwlyZXR1cm4gcmV0OworfQorCisvKiBOb29uZSBzdG9yZXMgdGhlIHByb3RvY29sIGFueXdoZXJlOyBzaW1wbHkgZGVsZXRlIGl0LiAqLwordm9pZCBpcF9uYXRfcHJvdG9jb2xfdW5yZWdpc3RlcihzdHJ1Y3QgaXBfbmF0X3Byb3RvY29sICpwcm90bykKK3sKKwlXUklURV9MT0NLKCZpcF9uYXRfbG9jayk7CisJaXBfbmF0X3Byb3Rvc1twcm90by0+cHJvdG9udW1dID0gJmlwX25hdF91bmtub3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vY2hlY2tzdW0uaD4KKyNpbmNsdWRlIDxuZXQvdWRwLmg+CisjaW5jbHVkZSA8YXNtL3VhY2Nlc3MuaD4KKworTU9EVUxFX0xJQ0VOU0UoIkdQTCIpOworTU9EVUxFX0FVVEhPUigiSmFtZXMgTW9ycmlzIDxqbW9ycmlzQGludGVyY29kZS5jb20uYXU+Iik7CitNT0RVTEVfREVTQ1JJUFRJT04oIkJhc2ljIFNOTVAgQXBwbGljYXRpb24gTGF5ZXIgR2F0ZXdheSIpOworCisjZGVmaW5lIFNOTVBfUE9SVCAxNjEKKyNkZWZpbmUgU05NUF9UUkFQX1BPUlQgMTYyCisjZGVmaW5lIE5PQ1QxKG4pICh1X2ludDhfdCApKChuKSAmIDB4ZmYpCisKK3N0YXRpYyBpbnQgZGVidWc7CitzdGF0aWMgREVGSU5FX1NQSU5MT0NLKHNubXBfbG9jayk7CisKKy8qIAorICogQXBwbGljYXRpb24gbGF5ZXIgYWRkcmVzcyBtYXBwaW5nIG1pbWljcyB0aGUgTkFUIG1hcHBpbmcsIGJ1dCAKKyAqIG9ubHkgZm9yIHRoZSBmaXJzdCBvY3RldCBpbiB0aGlzIGNhc2UgKGEgbW9yZSBmbGV4aWJsZSBzeXN0ZW0KKyAqIGNhbiBiZSBpbXBsZW1lbnRlZCBpZiBuZWVkZWQpLgorICovCitzdHJ1Y3Qgb2N0MV9tYXAKK3sKKwl1X2ludDhfdCBmcm9tOworCXVfaW50OF90IHRvOworfTsKKworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAorLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgKgorICogQmFzaWMgQVNOLjEgZGVjb2Rpbmcgcm91dGluZXMgKGd4c25tcCBhdXRob3IgRGlyayBXaXNzZSkKKyAqCisgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqK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Y3QgYXNuMV9jdHggKmN0eCwgCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1bnNpZ25lZCBpbnQgKmNscywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVuc2lnbmVkIGludCAqY29uLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdW5zaWduZWQgaW50ICp0YWcpCit7CisJdW5zaWduZWQgY2hhciBjaDsKKwkKKwlpZiAoIWFzbjFfb2N0ZXRfZGVjb2RlKGN0eCwgJmNoKSkKKwkJcmV0dXJuIDA7CisJCQorCSpjbHMgPSAoY2ggJiAweEMwKSA+PiA2OworCSpjb24gPSAoY2ggJiAweDIwKSA+PiA1OworCSp0YWcgPSAoY2ggJiAweDFGKTsKKwkKKwlpZiAoKnRhZyA9PSAweDFGKSB7CisJCWlmICghYXNuMV90YWdfZGVjb2RlKGN0eCwgdGFnKSkKKwkJCXJldHVybiAwOworCX0KKwlyZXR1cm4gMTsKK30KKworc3RhdGljIHVuc2lnbmVkIGNoYXIgYXNuMV9sZW5ndGhfZGVjb2RlKHN0cnVjdCBhc24xX2N0eCAqY3R4LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVuc2lnbmVkIGludCAqZGVmLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVuc2lnbmVkIGludCAqbGVuKQoreworCXVuc2lnbmVkIGNoYXIgY2gsIGNudDsKKwkKKwlpZiAoIWFzbjFfb2N0ZXRfZGVjb2RlKGN0eCwgJmNoKSkKKwkJcmV0dXJuIDA7CisJCQorCWlmIChjaCA9PSAweDgwKQorCQkqZGVmID0gMDsKKwllbHNlIHsKKwkJKmRlZiA9IDE7CisJCQorCQlpZiAoY2ggPCAweDgwKQorCQkJKmxlbiA9IGNoOworCQllbHNlIHsKKwkJCWNudCA9ICh1bnNpZ25lZCBjaGFyKSAoY2ggJiAweDdGKTsKKwkJCSpsZW4gPSAwOworCQkJCisJCQl3aGlsZSAoY250ID4gMCkgeworCQkJCWlmICghYXNuMV9vY3RldF9kZWNvZGUoY3R4LCAmY2gpKQorCQkJCQlyZXR1cm4gMDsKKwkJCQkqbGVuIDw8PSA4OworCQkJCSpsZW4gfD0gY2g7CisJCQkJY250LS07CisJCQl9CisJCX0KKwl9CisJcmV0dXJuIDE7Cit9CisKK3N0YXRpYyB1bnNpZ25lZCBjaGFyIGFzbjFfaGVhZGVyX2RlY29kZShzdHJ1Y3QgYXNuMV9jdHggKmN0eCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1bnNpZ25lZCBjaGFyICoqZW9jLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVuc2lnbmVkIGludCAqY2xzLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVuc2lnbmVkIGludCAqY29uLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVuc2lnbmVkIGludCAqdGFnKQoreworCXVuc2lnbmVkIGludCBkZWYsIGxlbjsKKwkKKwlpZiAoIWFzbjFfaWRfZGVjb2RlKGN0eCwgY2xzLCBjb24sIHRhZykpCisJCXJldHVybiAwOworCQkKKwlpZiAoIWFzbjFfbGVuZ3RoX2RlY29kZShjdHgsICZkZWYsICZsZW4pKQorCQlyZXR1cm4gMDsKKwkJCisJaWYgKGRlZikKKwkJKmVvYyA9IGN0eC0+cG9pbnRlciArIGxlbjsKKwllbHNlCisJCSplb2MgPSBOVUxMOworCXJldHVybiAxOworfQorCitzdGF0aWMgdW5zaWduZWQgY2hhciBhc24xX2VvY19kZWNvZGUoc3RydWN0IGFzbjFfY3R4ICpjdHgsIHVuc2lnbmVkIGNoYXIgKmVvYykKK3sKKwl1bnNpZ25lZCBjaGFyIGNoOworCQorCWlmIChlb2MgPT0gMCkgeworCQlpZiAoIWFzbjFfb2N0ZXRfZGVjb2RlKGN0eCwgJmNoKSkKKwkJCXJldHVybiAwOworCQkJCisJCWlmIChjaCAhPSAweDAwKSB7CisJCQljdHgtPmVycm9yID0gQVNOMV9FUlJfREVDX0VPQ19NSVNNQVRDSDsKKwkJCXJldHVybiAwOworCQl9CisJCQorCQlpZiAoIWFzbjFfb2N0ZXRfZGVjb2RlKGN0eCwgJmNoKSkKKwkJCXJldHVybiAwOworCQkJCisJCWlmIChjaCAhPSAweDAwKSB7CisJCQljdHgtPmVycm9yID0gQVNOMV9FUlJfREVDX0VPQ19NSVNNQVRDSDsKKwkJCXJldHVybiAwOworCQl9CisJCXJldHVybiAxOworCX0gZWxzZSB7CisJCWlmIChjdHgtPnBvaW50ZXIgIT0gZW9jKSB7CisJCQljdHgtPmVycm9yID0gQVNOMV9FUlJfREVDX0xFTkdUSF9NSVNNQVRDSDsKKwkJCXJldHVybiAwOworCQl9CisJCXJldHVybiAxOworCX0KK30KKworc3RhdGljIHVuc2lnbmVkIGNoYXIgYXNuMV9udWxsX2RlY29kZShzdHJ1Y3QgYXNuMV9jdHggKmN0eCwgdW5zaWduZWQgY2hhciAqZW9jKQoreworCWN0eC0+cG9pbnRlciA9IGVvYzsKKwlyZXR1cm4gMTsKK30KKworc3RhdGljIHVuc2lnbmVkIGNoYXIgYXNuMV9sb25nX2RlY29kZShzdHJ1Y3QgYXNuMV9jdHggKmN0eCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdW5zaWduZWQgY2hhciAqZW9jLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb25nICppbnRlZ2VyKQoreworCXVuc2lnbmVkIGNoYXIgY2g7CisJdW5zaWduZWQgaW50ICBsZW47CisJCisJaWYgKCFhc24xX29jdGV0X2RlY29kZShjdHgsICZjaCkpCisJCXJldHVybiAwOworCQkKKwkqaW50ZWdlciA9IChzaWduZWQgY2hhcikgY2g7CisJbGVuID0gMTsKKwkKKwl3aGlsZSAoY3R4LT5wb2ludGVyIDwgZW9jKSB7CisJCWlmICgrK2xlbiA+IHNpemVvZiAobG9uZykpIHsKKwkJCWN0eC0+ZXJyb3IgPSBBU04xX0VSUl9ERUNfQkFEVkFMVUU7CisJCQlyZXR1cm4gMDsKKwkJfQorCQkKKwkJaWYgKCFhc24xX29jdGV0X2RlY29kZShjdHgsICZjaCkpCisJCQlyZXR1cm4gMDsKKwkJCQorCQkqaW50ZWdlciA8PD0gODsKKwkJKmludGVnZXIgfD0gY2g7CisJfQorCXJldHVybiAxOworfQorCitzdGF0aWMgdW5zaWduZWQgY2hhciBhc24xX3VpbnRfZGVjb2RlKHN0cnVjdCBhc24xX2N0eCAqY3R4LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1bnNpZ25lZCBjaGFyICplb2MsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVuc2lnbmVkIGludCAqaW50ZWdlcikKK3sKKwl1bnNpZ25lZCBjaGFyIGNoOworCXVuc2lnbmVkIGludCAgbGVuOworCQorCWlmICghYXNuMV9vY3RldF9kZWNvZGUoY3R4LCAmY2gpKQorCQlyZXR1cm4gMDsKKwkJCisJKmludGVnZXIgPSBjaDsKKwlpZiAoY2ggPT0gMCkgbGVuID0gMDsKKwllbHNlIGxlbiA9IDE7CisJCisJd2hpbGUgKGN0eC0+cG9pbnRlciA8IGVvYykgeworCQlpZiAoKytsZW4gPiBzaXplb2YgKHVuc2lnbmVkIGludCkpIHsKKwkJCWN0eC0+ZXJyb3IgPSBBU04xX0VSUl9ERUNfQkFEVkFMVUU7CisJCQlyZXR1cm4gMDsKKwkJfQorCQkKKwkJaWYgKCFhc24xX29jdGV0X2RlY29kZShjdHgsICZjaCkpCisJCQlyZXR1cm4gMDsKKwkJCQorCQkqaW50ZWdlciA8PD0gODsKKwkJKmludGVnZXIgfD0gY2g7CisJfQorCXJldHVybiAxOworfQorCitzdGF0aWMgdW5zaWduZWQgY2hhciBhc24xX3Vsb25nX2RlY29kZShzdHJ1Y3QgYXNuMV9jdHggKmN0eCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVuc2lnbmVkIGNoYXIgKmVvYywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVuc2lnbmVkIGxvbmcgKmludGVnZXIpCit7CisJdW5zaWduZWQgY2hhciBjaDsKKwl1bnNpZ25lZCBpbnQgIGxlbjsKKwkKKwlpZiAoIWFzbjFfb2N0ZXRfZGVjb2RlKGN0eCwgJmNoKSkKKwkJcmV0dXJuIDA7CisJCQorCSppbnRlZ2VyID0gY2g7CisJaWYgKGNoID09IDApIGxlbiA9IDA7CisJZWxzZSBsZW4gPSAxOworCQorCXdoaWxlIChjdHgtPnBvaW50ZXIgPCBlb2MpIHsKKwkJaWYgKCsrbGVuID4gc2l6ZW9mICh1bnNpZ25lZCBsb25nKSkgeworCQkJY3R4LT5lcnJvciA9IEFTTjFfRVJSX0RFQ19CQURWQUxVRTsKKwkJCXJldHVybiAwOworCQl9CisJCQorCQlpZiAoIWFzbjFfb2N0ZXRfZGVjb2RlKGN0eCwgJmNoKSkKKwkJCXJldHVybiAwOworCQkJCisJCSppbnRlZ2VyIDw8PSA4OworCQkqaW50ZWdlciB8PSBjaDsKKwl9CisJcmV0dXJuIDE7Cit9CisKK3N0YXRpYyB1bnNpZ25lZCBjaGFyIGFzbjFfb2N0ZXRzX2RlY29kZShzdHJ1Y3QgYXNuMV9jdHggKmN0eCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1bnNpZ25lZCBjaGFyICplb2MsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdW5zaWduZWQgY2hhciAqKm9jdGV0cywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1bnNpZ25lZCBpbnQgKmxlbikKK3sKKwl1bnNpZ25lZCBjaGFyICpwdHI7CisJCisJKmxlbiA9IDA7CisJCisJKm9jdGV0cyA9IGttYWxsb2MoZW9jIC0gY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SEJPUkxPU1MJNQorI2RlZmluZSBTTk1QX1RSQVBfRU5UU1BFQ0lGSUMJCTYKKworLyogU05NUHYxIFR5cGVzICovCisjZGVmaW5lIFNOTVBfTlVMTCAgICAgICAgICAgICAgICAwCisjZGVmaW5lIFNOTVBfSU5URUdFUiAgICAgICAgICAgICAxICAgIC8qIGwgICovCisjZGVmaW5lIFNOTVBfT0NURVRTVFIgICAgICAgICAgICAyICAgIC8qIGMgICovCisjZGVmaW5lIFNOTVBfRElTUExBWVNUUiAgICAgICAgICAyICAgIC8qIGMgICovCisjZGVmaW5lIFNOTVBfT0JKRUNUSUQgICAgICAgICAgICAzICAgIC8qIHVsICovCisjZGVmaW5lIFNOTVBfSVBBRERSICAgICAgICAgICAgICA0ICAgIC8qIHVjICovCisjZGVmaW5lIFNOTVBfQ09VTlRFUiAgICAgICAgICAgICA1ICAgIC8qIHVsICovCisjZGVmaW5lIFNOTVBfR0FVR0UgICAgICAgICAgICAgICA2ICAgIC8qIHVsICovCisjZGVmaW5lIFNOTVBfVElNRVRJQ0tTICAgICAgICAgICA3ICAgIC8qIHVsICovCisjZGVmaW5lIFNOTVBfT1BBUVVFICAgICAgICAgICAgICA4ICAgIC8qIGMgICovCisKKy8qIEFkZGl0aW9uYWwgU05NUHYyIFR5cGVzICovCisjZGVmaW5lIFNOTVBfVUlOVEVHRVIgICAgICAgICAgICA1ICAgIC8qIHVsICovCisjZGVmaW5lIFNOTVBfQklUU1RSICAgICAgICAgICAgICA5ICAgIC8qIHVjICovCisjZGVmaW5lIFNOTVBfTlNBUCAgICAgICAgICAgICAgIDEwICAgIC8qIHVjICovCisjZGVmaW5lIFNOTVBfQ09VTlRFUjY0ICAgICAgICAgIDExICAgIC8qIHVsICovCisjZGVmaW5lIFNOTVBfTk9TVUNIT0JKRUNUICAgICAgIDEyCisjZGVmaW5lIFNOTVBfTk9TVUNISU5TVEFOQ0UgICAgIDEzCisjZGVmaW5lIFNOTVBfRU5ET0ZNSUJWSUVXICAgICAgI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yIGRhdGEgdHlwZXMgYW5kIGVycm9ycyAqLworCXtBU04xX1VOSSwgQVNOMV9CVFMsIFNOTVBfQklUU1RSfSwKKwl7QVNOMV9BUEwsIFNOTVBfQzY0LCBTTk1QX0NPVU5URVI2NH0sCisJe0FTTjFfQ1RYLCBTRVJSX05TTywgU05NUF9OT1NVQ0hPQkpFQ1R9LAorCXtBU04xX0NUWCwgU0VSUl9OU0ksIFNOTVBfTk9TVUNISU5TVEFOQ0V9LAorCXtBU04xX0NUWCwgU0VSUl9FT00sIFNOTVBfRU5ET0ZNSUJWSUVXfSwKKwl7MCwgICAgICAgMCwgICAgICAgLTF9Cit9OworCitzdGF0aWMgdW5zaWduZWQgY2hhciBzbm1wX3RhZ19jbHMyc3ludGF4KHVuc2lnbmVkIGludCB0YWcsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVuc2lnbmVkIGludCBjbHMsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVuc2lnbmVkIHNob3J0ICpzeW50YXgpCit7CisJc3RydWN0IHNubXBfY252ICpjbnY7CisJCisJY252ID0gc25tcF9jb252OworCQorCXdoaWxlIChjbnYtPnN5bnRheCAhPSAtMSkgeworCQlpZiAoY252LT50YWcgPT0gdGFnICYmIGNudi0+Y2xhc3MgPT0gY2xzKSB7CisJCQkqc3ludGF4ID0gY252LT5zeW50YXg7CisJCQlyZXR1cm4gMTsKKwkJfQorCQljbnYrKzsKKwl9CisJcmV0dXJuIDA7Cit9CisKK3N0YXRpYyB1bnNpZ25lZCBjaGFyIHNubXBfb2JqZWN0X2RlY29kZShzdHJ1Y3QgYXNuMV9jdHggKmN0eCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJ1Y3Qgc25tcF9vYmplY3QgKipvYmopCit7CisJdW5zaWduZWQgaW50IGNscywgY29uLCB0YWcsIGxlbiwgaWRsZW47CisJdW5zaWduZWQgc2hvcnQgdHlwZT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XggKz0gbmV3ICYgMHhGRkZGOworCWlmICh4ICYgMHgxMDAwMCkgeworCQl4Kys7CisJCXggJj0gMHhGRkZGOworCX0KKwkKKwl4ID1+IHggJiAweEZGRkY7CisJY3N1bVswXSA9IHggLyAyNTY7CisJY3N1bVsxXSA9IHggJiAweEZGOworfQorCisvKiAKKyAqIE1hbmdsZSBJUCBhZGRyZXNzLgorICogCS0gYmVnaW4gcG9pbnRzIHRvIHRoZSBzdGFydCBvZiB0aGUgc25tcCBtZXNzZ2FlCisgKiAgICAgIC0gYWRkciBwb2ludHMgdG8gdGhlIHN0YXJ0IG9mIHRoZSBhZGRyZXNzCisgKi8KK3N0YXRpYyBpbmxpbmUgdm9pZCBtYW5nbGVfYWRkcmVzcyh1bnNpZ25lZCBjaGFyICpiZWdpbiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1bnNpZ25lZCBjaGFyICphZGRyLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0cnVjdCBvY3QxX21hcCAqbWFwLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVfaW50MTZfdCAqY2hlY2spCit7CisJaWYgKG1hcC0+ZnJvbSA9PSBOT0NUMSgqYWRkcikpIHsKKwkJdV9pbnQzMl90IG9sZDsKKwkJCisJCWlmIChkZWJ1ZykKKwkJCW1lbWNweSgmb2xkLCAodW5zaWduZWQgY2hhciAqKWFkZHIsIHNpemVvZihvbGQpKTsKKwkJCQorCQkqYWRkciA9IG1hcC0+dG87CisJCQorCQkvKiBVcGRhdGUgVURQIGNoZWNrc3VtIGlmIGJlaW5nIHVzZWQgKi8KKwkJaWYgKCpjaGVjaykgeworCQkJdW5zaWduZWQgY2hhciBvZGQgPSAhKChhZGRyIC0gYmVnaW4pICUgMik7CisJCQkKKwkJCWZhc3RfY3N1bSgodW5zaWduZWQgY2hhciAqKWNoZWNrLAorCQkJICAgICAgICAgICZtYXAtPmZyb20sICZtYXAtPnRvLCBvZGQpOworCQkJICAgICAgICAgIAorCQl9CisJCQorCQlpZiAoZGVidWcpCisJCQlwcmludGsoS0VSTl9ERUJVRyAiYnNhbGc6IG1hcHBlZCAldS4ldS4ldS4ldSB0byAiCisJCQkgICAgICAgIiV1LiV1LiV1LiV1XG4iLCBOSVBRVUFEKG9sZCksIE5JUFFVQUQoKmFkZHIpKTsKKwl9Cit9CisKK3N0YXRpYyB1bnNpZ25lZCBjaGFyIHNubXBfdHJhcF9kZWNvZGUoc3RydWN0IGFzbjFfY3R4ICpjdHgsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cnVjdCBzbm1wX3YxX3RyYXAgKnRyYXAsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0cnVjdCBvY3QxX21hcCAqbWFwLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1X2ludDE2X3QgKmNoZWNrKQoreworCXVuc2lnbmVkIGludCBjbHMsIGNvbiwgdGFnLCBsZW47CisJdW5zaWduZWQgY2hhciAqZW5kOworCisJaWYgKCFhc24xX2hlYWRlcl9kZWNvZGUoY3R4LCAmZW5kLCAmY2xzLCAmY29uLCAmdGFnKSkKKwkJcmV0dXJuIDA7CisJCQorCWlmIChjbHMgIT0gQVNOMV9VTkkgfHwgY29uICE9IEFTTjFfUFJJIHx8IHRhZyAhPSBBU04xX09KSSkKKwkJcmV0dXJuIDA7CisJCisJaWYgKCFhc24xX29pZF9kZWNvZGUoY3R4LCBlbmQsICZ0cmFwLT5pZCwgJnRyYXAtPmlkX2xlbikpCisJCXJldHVybiAwOworCQkKKwlpZiAoIWFzbjFfaGVhZGVyX2RlY29kZShjdHgsICZlbmQsICZjbHMsICZjb24sICZ0YWcpKQorCQlnb3RvIGVycl9pZF9mcmVlOworCisJaWYgKCEoKGNscyA9PSBBU04xX0FQTCAmJiBjb24gPT0gQVNOMV9QUkkgJiYgdGFnID09IFNOTVBfSVBBKSB8f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aWYgKCFhc24xX2hlYWRlcl9kZWNvZGUoY3R4LCAmZW5kLCAmY2xzLCAmY29uLCAmdGFnKSkKKwkJZ290byBlcnJfYWRkcl9mcmVlOworCQkKKwlpZiAoISgoY2xzID09IEFTTjFfQVBMICYmIGNvbiA9PSBBU04xX1BSSSAmJiB0YWcgPT0gU05NUF9USVQpIHx8CisJICAgICAgKGNscyA9PSBBU04xX1VOSSAmJiBjb24gPT0gQVNOMV9QUkkgJiYgdGFnID09IEFTTjFfSU5UKSkpCisJCWdvdG8gZXJyX2FkZHJfZnJlZTsKKwkJCisJaWYgKCFhc24xX3Vsb25nX2RlY29kZShjdHgsIGVuZCwgJnRyYXAtPnRpbWUpKQorCQlnb3RvIGVycl9hZGRyX2ZyZWU7CisJCQorCXJldHVybiAxOworCitlcnJfaWRfZnJlZToKKwlrZnJlZSh0cmFwLT5pZCk7CisKK2Vycl9hZGRyX2ZyZWU6CisJa2ZyZWUoKHVuc2lnbmVkIGxvbmcgKil0cmFwLT5pcF9hZGRyZXNzKTsKKwkKKwlyZXR1cm4gMDsKK30KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgKgorICogTWlzYy4gcm91dGluZXMKKyAqCisgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisKK3N0YXRpYyB2b2lkIGhleF9kdW1wKHVuc2lnbmVkIGNoYXIgKmJ1Ziwgc2l6ZV90IGxlbikKK3sKKwlzaXplX3QgaTsKKwkKKwlmb3IgKGkgPSAwOyBpIDwgbGVuOyBpKyspIHsKKwkJaWYgKGkgJiYgIShpICUgMTYpKQorCQkJcHJpbnRrKCJcbiIpOworCQlwcmludGsoIiUwMnggIiwgKihidWYgKyBpKSk7CisJfQorCXByaW50aygiXG4iKTsKK30KKworLyoKKyAqIFBhcnNlIGFuZCBtYW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plY3RfZGVjb2RlKCZjdHgsIG9iaikpIHsKKwkJCWlmICgqb2JqKSB7CisJCQkJaWYgKCgqb2JqKS0+aWQpCisJCQkJCWtmcmVlKCgqb2JqKS0+aWQpOworCQkJCWtmcmVlKCpvYmopOworCQkJfQkKKwkJCWtmcmVlKG9iaik7CisJCQlyZXR1cm4gMDsKKwkJfQorCisJCWlmIChkZWJ1ZyA+IDEpIHsKKwkJCXByaW50ayhLRVJOX0RFQlVHICJic2FsZzogb2JqZWN0OiAiKTsKKwkJCWZvciAoaSA9IDA7IGkgPCAoKm9iaiktPmlkX2xlbjsgaSsrKSB7CisJCQkJaWYgKGkgPiAwKQorCQkJCQlwcmludGsoIi4iKTsKKwkJCQlwcmludGsoIiVsdSIsICgqb2JqKS0+aWRbaV0pOworCQkJfQorCQkJcHJpbnRrKCI6IHR5cGU9JXVcbiIsICgqb2JqKS0+dHlwZSk7CisJCQkKKwkJfQorCisJCWlmICgoKm9iaiktPnR5cGUgPT0gU05NUF9JUEFERFIpCisJCQltYW5nbGVfYWRkcmVzcyhjdHguYmVnaW4sIGN0eC5wb2ludGVyIC0gNCAsIG1hcCwgY2hlY2spOworCQkKKwkJa2ZyZWUoKCpvYmopLT5pZCk7CisJCWtmcmVlKCpvYmopOworCX0KKwlrZnJlZShvYmopOworCQorCWlmICghYXNuMV9lb2NfZGVjb2RlKCZjdHgsIGVvYykpCisJCXJldHVybiAwOworCQkKKwlyZXR1cm4gMTsKK30KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgKgorICogTkFUIHJvdXRpbmVzLgorICoKKyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKworLyogCisgKiBTTk1QIHRyYW5zbGF0aW9uIHJvdXRpbmUuCisgKi8KK3N0YXRpYyBpbnQgc25tcF90cmFuc2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KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgKgorICogTW9kdWxlIHN0dWZmLgorICoKKyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKyAKK3N0YXRpYyBpbnQgX19pbml0IGluaXQodm9pZCkKK3sKKwlpbnQgcmV0ID0gMDsKKworCXJldCA9IGlwX2Nvbm50cmFja19oZWxwZXJfcmVnaXN0ZXIoJnNubXBfaGVscGVyKTsKKwlpZiAocmV0IDwgMCkKKwkJcmV0dXJuIHJldDsKKwlyZXQgPSBpcF9jb25udHJhY2tfaGVscGVyX3JlZ2lzdGVyKCZzbm1wX3RyYXBfaGVscGVyKTsKKwlpZiAocmV0IDwgMCkgeworCQlpcF9jb25udHJhY2tfaGVscGVyX3VucmVnaXN0ZXIoJnNubXBfaGVscGVyKTsKKwkJcmV0dXJuIHJldDsKKwl9CisJcmV0dXJuIHJldDsKK30KKworc3RhdGljIHZvaWQgX19leGl0IGZpbmkodm9pZCkKK3sKKwlpcF9jb25udHJhY2tfaGVscGVyX3VucmVnaXN0ZXIoJnNubXBfaGVscGVyKTsKKwlpcF9jb25udHJhY2tfaGVscGVyX3VucmVnaXN0ZXIoJnNubXBfdHJhcF9oZWxwZXIpOworfQorCittb2R1bGVfaW5pdChpbml0KTsKK21vZHVsZV9leGl0KGZpbmkpOworCittb2R1bGVfcGFyYW0oZGVidWcsIGJvb2wsIDA2MDApOwpkaWZmIC0tZ2l0IGEvbmV0L2lwdjQvbmV0ZmlsdGVyL2lwX25hdF9zdGFuZGFsb25lLmMgYi9uZXQvaXB2NC9uZXRmaWx0ZXIvaXBfbmF0X3N0YW5kYWxvbmUuYwpuZXcgZmlsZSBtb2RlIDEwMDY0NAppbmRleCAwMDAwMDAwLi5kZWM0YTc0Ci0tLSAvZGV2L251bGwKKysrIGIvbmV0L2lwdjQvbmV0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aG9vayAldSBwb3MgJXUgJTA4WC5cbiIsCisJCQkJICAgICAgIGhvb2ssIHBvcywgZS0+Y29tZWZyb20pOworCQkJCXJldHVybiAwOworCQkJfQorCQkJZS0+Y29tZWZyb20KKwkJCQl8PSAoKDEgPDwgaG9vaykgfCAoMSA8PCBORl9JUF9OVU1IT09LUykpOworCisJCQkvKiBVbmNvbmRpdGlvbmFsIHJldHVybi9FTkQuICovCisJCQlpZiAoZS0+dGFyZ2V0X29mZnNldCA9PSBzaXplb2Yoc3RydWN0IGlwdF9lbnRyeSkKKwkJCSAgICAmJiAoc3RyY21wKHQtPnRhcmdldC51LnVzZXIubmFtZSwKKwkJCQkgICAgICAgSVBUX1NUQU5EQVJEX1RBUkdFVCkgPT0gMCkKKwkJCSAgICAmJiB0LT52ZXJkaWN0IDwgMAorCQkJICAgICYmIHVuY29uZGl0aW9uYWwoJmUtPmlwKSkgeworCQkJCXVuc2lnbmVkIGludCBvbGRwb3MsIHNpemU7CisKKwkJCQkvKiBSZXR1cm46IGJhY2t0cmFjayB0aHJvdWdoIHRoZSBsYXN0CisJCQkJICAgYmlnIGp1bXAuICovCisJCQkJZG8geworCQkJCQllLT5jb21lZnJvbSBePSAoMTw8TkZfSVBfTlVNSE9PS1MpOworI2lmZGVmIERFQlVHX0lQX0ZJUkVXQUxMX1VTRVIKKwkJCQkJaWYgKGUtPmNvbWVmcm9tCisJCQkJCSAgICAmICgxIDw8IE5GX0lQX05VTUhPT0tTKSkgeworCQkJCQkJZHVwcmludGYoIkJhY2sgdW5zZXQgIgorCQkJCQkJCSAib24gaG9vayAldSAiCisJCQkJCQkJICJydWxlICV1XG4iLAorCQkJCQkJCSBob29rLCBwb3MpOworCQkJCQl9CisjZW5kaWYKKwkJCQkJb2xkcG9zID0gcG9zOworCQkJCQlwb3MgPSBlLT5jb3VudGVycy5wY250OworCQkJCQllLT5jb3VudGVycy5wY250ID0gMDsKKworCQkJCQkvKiBXZSdyZSBhdCB0aGUgc3RhcnQuICovCisJ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YXIgKillIC0gYmFzZSA9PSBob29rX2VudHJpZXNbaF0pCisJCQluZXdpbmZvLT5ob29rX2VudHJ5W2hdID0gaG9va19lbnRyaWVzW2hdOworCQlpZiAoKHVuc2lnbmVkIGNoYXIgKillIC0gYmFzZSA9PSB1bmRlcmZsb3dzW2hdKQorCQkJbmV3aW5mby0+dW5kZXJmbG93W2hdID0gdW5kZXJmbG93c1toXTsKKwl9CisKKwkvKiBGSVhNRTogdW5kZXJmbG93cyBtdXN0IGJlIHVuY29uZGl0aW9uYWwsIHN0YW5kYXJkIHZlcmRpY3RzCisgICAgICAgICAgIDwgMCAobm90IElQVF9SRVRVUk4pLiAtLVJSICovCisKKwkvKiBDbGVhciBjb3VudGVycyBhbmQgY29tZWZyb20gKi8KKwllLT5jb3VudGVycyA9ICgoc3RydWN0IGlwdF9jb3VudGVycykgeyAwLCAwIH0pOworCWUtPmNvbWVmcm9tID0gMDsKKworCSgqaSkrKzsKKwlyZXR1cm4gMDsKK30KKworc3RhdGljIGlubGluZSBpbnQKK2NsZWFudXBfZW50cnkoc3RydWN0IGlwdF9lbnRyeSAqZSwgdW5zaWduZWQgaW50ICppKQoreworCXN0cnVjdCBpcHRfZW50cnlfdGFyZ2V0ICp0OworCisJaWYgKGkgJiYgKCppKS0tID09IDApCisJCXJldHVybiAxOworCisJLyogQ2xlYW51cCBhbGwgbWF0Y2hlcyAqLworCUlQVF9NQVRDSF9JVEVSQVRFKGUsIGNsZWFudXBfbWF0Y2gsIE5VTEwpOworCXQgPSBpcHRfZ2V0X3RhcmdldChlKTsKKwlpZiAodC0+dS5rZXJuZWwudGFyZ2V0LT5kZXN0cm95KQorCQl0LT51Lmtlcm5lbC50YXJnZXQtPmRlc3Ryb3kodC0+ZGF0YSwKKwkJCQkJICAgIHQtPnUudGFyZ2V0X3NpemUgLSBzaXplb2YoKnQpKTsKKwltb2R1bGVfcHV0KHQtPnUua2VybmVsLnRhcmdldC0+bWUpOworCXJldHVybiAwOworfQorCisvKiBDaGVja3MgYW5kIHRyYW5zbGF0ZXMgdGhlIHVzZXItc3VwcGxpZWQgdGFibGUgc2VnbWVudCAoaGVsZCBpbgorICAgbmV3aW5mbykgKi8KK3N0YXRpYyBpbnQKK3RyYW5zbGF0ZV90YWJsZShjb25zdCBjaGFyICpuYW1lLAorCQl1bnNpZ25lZCBpbnQgdmFsaWRfaG9va3MsCisJCXN0cnVjdCBpcHRfdGFibGVfaW5mbyAqbmV3aW5mbywKKwkJdW5zaWduZWQgaW50IHNpemUsCisJCXVuc2lnbmVkIGludCBudW1iZXIsCisJCWNvbnN0IHVuc2lnbmVkIGludCAqaG9va19lbnRyaWVzLAorCQljb25zdCB1bnNpZ25lZCBpbnQgKnVuZGVyZmxvd3MpCit7CisJdW5zaWduZWQgaW50IGk7CisJaW50IHJldDsKKworCW5ld2luZm8tPnNpemUgPSBzaXplOworCW5ld2luZm8tPm51bWJlciA9IG51bWJlcjsKKworCS8qIEluaXQgYWxsIGhvb2tzIHRvIGltcG9zc2libGUgdmFsdWUuICovCisJZm9yIChpID0gMDsgaSA8IE5GX0lQX05VTUhPT0tTOyBpKyspIHsKKwkJbmV3aW5mby0+aG9va19lbnRyeVtpXSA9IDB4RkZGRkZGRkY7CisJCW5ld2luZm8tPnVuZGVyZmxvd1tpXSA9IDB4RkZGRkZGRkY7CisJfQorCisJZHVwcmludGYoInRyYW5zbGF0ZV90YWJsZTogc2l6ZSAldVxuIiwgbmV3aW5mby0+c2l6ZSk7CisJaSA9IDA7CisJLyogV2FsayB0aHJvdWdoIGVudHJpZXMsIGNoZWNraW5nIG9mZnNldHMuICovCisJcmV0ID0gSVBUX0VOVFJZX0lURVJBVEUobmV3aW5mby0+ZW50cmllcywgbmV3aW5mby0+c2l6ZSwKKwkJCQljaGVja19lbnRyeV9zaXplX2FuZF9ob29rcywKKwkJCQluZXdpbmZvLAorCQkJCW5ld2luZm8tPmVudHJpZXMsCisJCQkJbmV3aW5mby0+ZW50cmllcyArIHNpemUsCisJCQkJaG9va19l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TsKKworCWlmIChyZXQgIT0gMCkgeworCQlJUFRfRU5UUllfSVRFUkFURShuZXdpbmZvLT5lbnRyaWVzLCBuZXdpbmZvLT5zaXplLAorCQkJCSAgY2xlYW51cF9lbnRyeSwgJmkpOworCQlyZXR1cm4gcmV0OworCX0KKworCS8qIEFuZCBvbmUgY29weSBmb3IgZXZlcnkgb3RoZXIgQ1BVICovCisJZm9yIChpID0gMTsgaSA8IG51bV9wb3NzaWJsZV9jcHVzKCk7IGkrKykgeworCQltZW1jcHkobmV3aW5mby0+ZW50cmllcyArIFNNUF9BTElHTihuZXdpbmZvLT5zaXplKSppLAorCQkgICAgICAgbmV3aW5mby0+ZW50cmllcywKKwkJICAgICAgIFNNUF9BTElHTihuZXdpbmZvLT5zaXplKSk7CisJfQorCisJcmV0dXJuIHJldDsKK30KKworc3RhdGljIHN0cnVjdCBpcHRfdGFibGVfaW5mbyAqCityZXBsYWNlX3RhYmxlKHN0cnVjdCBpcHRfdGFibGUgKnRhYmxlLAorCSAgICAgIHVuc2lnbmVkIGludCBudW1fY291bnRlcnMsCisJICAgICAgc3RydWN0IGlwdF90YWJsZV9pbmZvICpuZXdpbmZvLAorCSAgICAgIGludCAqZXJyb3IpCit7CisJc3RydWN0IGlwdF90YWJsZV9pbmZvICpvbGRpbmZvOworCisjaWZkZWYgQ09ORklHX05FVEZJTFRFUl9ERUJVRworCXsKKwkJc3RydWN0IGlwdF9lbnRyeSAqdGFibGVfYmFzZTsKKwkJdW5zaWduZWQgaW50IGk7CisKKwkJZm9yIChpID0gMDsgaSA8IG51bV9wb3NzaWJsZV9jcHVzKCk7IGkrKykgeworCQkJdGFibGVfYmFzZSA9CisJCQkJKHZvaWQgKiluZXdpbmZvLT5lbnRyaWVzCisJCQkJKyBUQUJMRV9PRkZTRVQobmV3aW5mbywgaSk7CisKKwkJCXRhYmxlX2Jhc2UtPmNvbWVmcm9tID0gMHhkZWFkNTdhYzsKKwkJfQorCX0KKyNlbmRpZgorCisJLyogRG8gdGh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29uZmlnLCB1X2ludDMyX3QgaGFzaCkKK3sKKwlpbnQgaTsKKworCVJFQURfTE9DSygmY2x1c3RlcmlwX2xvY2spOworCisJaWYgKGNvbmZpZy0+bnVtX2xvY2FsX25vZGVzID09IDApIHsKKwkJUkVBRF9VTkxPQ0soJmNsdXN0ZXJpcF9sb2NrKTsKKwkJcmV0dXJuIDA7CisJfQorCisJZm9yIChpID0gMDsgaSA8IGNvbmZpZy0+bnVtX2xvY2FsX25vZGVzOyBpKyspIHsKKwkJaWYgKGNvbmZpZy0+bG9jYWxfbm9kZXNbaV0gPT0gaGFzaCkgeworCQkJUkVBRF9VTkxPQ0soJmNsdXN0ZXJpcF9sb2NrKTsKKwkJCXJldHVybiAxOworCQl9CisJfQorCisJUkVBRF9VTkxPQ0soJmNsdXN0ZXJpcF9sb2NrKTsKKworCXJldHVybiAwOworfQorCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiogCisgKiBJUFRBQkxFUyBUQVJHRVQgCisgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisKK3N0YXRpYyB1bnNpZ25lZCBpbnQKK3RhcmdldChzdHJ1Y3Qgc2tfYnVmZiAqKnBza2IsCisgICAgICAgY29uc3Qgc3RydWN0IG5ldF9kZXZpY2UgKmluLAorICAgICAgIGNvbnN0IHN0cnVjdCBuZXRfZGV2aWNlICpvdXQsCisgICAgICAgdW5zaWduZWQgaW50IGhvb2tudW0sCisgICAgICAgY29uc3Qgdm9pZCAqdGFyZ2luZm8sCisgICAgICAgdm9pZCAqdXNlcmluZm8pCit7CisJY29uc3Qgc3RydWN0IGlwdF9jbHVzdGVyaXBfdGd0X2luZm8gKmNpcGluZm8gPSB0YXJnaW5mbzsKKwllbnVtIGlwX2Nvbm50cmFja19pbmZvIGN0aW5mbzsKKwlzdHJ1Y3QgaXBfY29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dGhlIGZpbGUsIHRoZSBvcGVuL2Nsb3NlCisJICogZnVuY3Rpb25zIGFyZSBhbHNvIGluY3JlbWVudGluZyB0aGUgcmVmY291bnQgb24gdGhlaXIgb3duICovCisjaWZkZWYgQ09ORklHX1BST0NfRlMKKwlyZW1vdmVfcHJvY19lbnRyeShjaXBpbmZvLT5jb25maWctPnBkZS0+bmFtZSwKKwkJCSAgY2lwaW5mby0+Y29uZmlnLT5wZGUtPnBhcmVudCk7CisjZW5kaWYKKwljbHVzdGVyaXBfY29uZmlnX3B1dChjaXBpbmZvLT5jb25maWcpOworfQorCitzdGF0aWMgc3RydWN0IGlwdF90YXJnZXQgY2x1c3RlcmlwX3RndCA9IHsgCisJLm5hbWUgPSAiQ0xVU1RFUklQIiwKKwkudGFyZ2V0ID0gJnRhcmdldCwgCisJLmNoZWNrZW50cnkgPSAmY2hlY2tlbnRyeSwgCisJLmRlc3Ryb3kgPSAmZGVzdHJveSwKKwkubWUgPSBUSElTX01PRFVMRQorfTsKKworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiogCisgKiBBUlAgTUFOR0xJTkcgQ09ERSAKKyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKworLyogaGFyZGNvZGVkIGZvciA0OGJpdCBldGhlcm5ldCBhbmQgMzJiaXQgaXB2NCBhZGRyZXNzZXMgKi8KK3N0cnVjdCBhcnBfcGF5bG9hZCB7CisJdV9pbnQ4X3Qgc3JjX2h3W0VUSF9BTEVOXTsKKwl1X2ludDMyX3Qgc3JjX2lwOworCXVfaW50OF90IGRzdF9od1tFVEhfQUxFTl07CisJdV9pbnQzMl90IGRzdF9pcDsKK30gX19hdHRyaWJ1dGVfXyAoKHBhY2tlZCkpOworCisjaWZkZWYgQ0xVU1RFUklQX0RFQlVHCitzdGF0aWMgdm9pZCBhcnB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IGhvb2tudW0sCisgICAgICAgY29uc3Qgdm9pZCAqdGFyZ2luZm8sCisgICAgICAgdm9pZCAqdXNlcmluZm8pCit7CisJY29uc3Qgc3RydWN0IGlwdF9jb25ubWFya190YXJnZXRfaW5mbyAqbWFya2luZm8gPSB0YXJnaW5mbzsKKwl1bnNpZ25lZCBsb25nIGRpZmY7CisJdW5zaWduZWQgbG9uZyBuZm1hcms7CisJdW5zaWduZWQgbG9uZyBuZXdtYXJrOworCisJZW51bSBpcF9jb25udHJhY2tfaW5mbyBjdGluZm87CisJc3RydWN0IGlwX2Nvbm50cmFjayAqY3QgPSBpcF9jb25udHJhY2tfZ2V0KCgqcHNrYiksICZjdGluZm8pOworCWlmIChjdCkgeworCSAgICBzd2l0Y2gobWFya2luZm8tPm1vZGUpIHsKKwkgICAgY2FzZSBJUFRfQ09OTk1BUktfU0VUOgorCQluZXdtYXJrID0gKGN0LT5tYXJrICYgfm1hcmtpbmZvLT5tYXNrKSB8IG1hcmtpbmZvLT5tYXJrOworCQlpZiAobmV3bWFyayAhPSBjdC0+bWFyaykKKwkJICAgIGN0LT5tYXJrID0gbmV3bWFyazsKKwkJYnJlYWs7CisJICAgIGNhc2UgSVBUX0NPTk5NQVJLX1NBVkU6CisJCW5ld21hcmsgPSAoY3QtPm1hcmsgJiB+bWFya2luZm8tPm1hc2spIHwgKCgqcHNrYiktPm5mbWFyayAmIG1hcmtpbmZvLT5tYXNrKTsKKwkJaWYgKGN0LT5tYXJrICE9IG5ld21hcmspCisJCSAgICBjdC0+bWFyayA9IG5ld21hcms7CisJCWJyZWFrOworCSAgICBjYXNlIElQVF9DT05OTUFSS19SRVNUT1JFOgorCQluZm1hcmsgPSAoKnBza2IpLT5uZm1hcms7CisJCWRpZmYgPSAoY3QtPm1hcmsgXiBuZm1hcmspICYgbWFya2luZm8tPm1hc2s7CisJCWlmIChkaWZmICE9IDApIHsKKwkJICAgICgqcHNrYiktPm5mbWFyayA9IG5mbWFyayBeIGRpZmY7CisJCSA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pcHRfbWFya190YXJnZXRfaW5mb192MSAqbWFya2luZm8gPSB0YXJnaW5mbzsKKwlpbnQgbWFyayA9IDA7CisKKwlzd2l0Y2ggKG1hcmtpbmZvLT5tb2RlKSB7CisJY2FzZSBJUFRfTUFSS19TRVQ6CisJCW1hcmsgPSBtYXJraW5mby0+bWFyazsKKwkJYnJlYWs7CisJCQorCWNhc2UgSVBUX01BUktfQU5EOgorCQltYXJrID0gKCpwc2tiKS0+bmZtYXJrICYgbWFya2luZm8tPm1hcms7CisJCWJyZWFrOworCQkKKwljYXNlIElQVF9NQVJLX09SOgorCQltYXJrID0gKCpwc2tiKS0+bmZtYXJrIHwgbWFya2luZm8tPm1hcms7CisJCWJyZWFrOworCX0KKworCWlmKCgqcHNrYiktPm5mbWFyayAhPSBtYXJrKSB7CisJCSgqcHNrYiktPm5mbWFyayA9IG1hcms7CisJCSgqcHNrYiktPm5mY2FjaGUgfD0gTkZDX0FMVEVSRUQ7CisJfQorCXJldHVybiBJUFRfQ09OVElOVUU7Cit9CisKKworc3RhdGljIGludAorY2hlY2tlbnRyeV92MChjb25zdCBjaGFyICp0YWJsZW5hbWUsCisJICAgICAgY29uc3Qgc3RydWN0IGlwdF9lbnRyeSAqZSwKKwkgICAgICB2b2lkICp0YXJnaW5mbywKKwkgICAgICB1bnNpZ25lZCBpbnQgdGFyZ2luZm9zaXplLAorCSAgICAgIHVuc2lnbmVkIGludCBob29rX21hc2spCit7CisJaWYgKHRhcmdpbmZvc2l6ZSAhPSBJUFRfQUxJR04oc2l6ZW9mKHN0cnVjdCBpcHRfbWFya190YXJnZXRfaW5mbykpKSB7CisJCXByaW50ayhLRVJOX1dBUk5JTkcgIk1BUks6IHRhcmdpbmZvc2l6ZSAldSAhPSAlWnVcbiIsCisJCSAgICAgICB0YXJnaW5mb3NpemUsCisJCSAgICAgICBJUFRfQUxJR04oc2l6ZW9mKHN0cnVjdCBpcHRfbWFya190YXJnZXRfaW5mbykpKTsKKwkJcmV0dXJuIDA7Cis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FRfT1dORVJfVUlEKSkKKwkJCXJldHVybiAwOworCX0KKworCWlmKGluZm8tPm1hdGNoICYgSVBUX09XTkVSX0dJRCkgeworCQlpZiAoKHNrYi0+c2stPnNrX3NvY2tldC0+ZmlsZS0+Zl9naWQgIT0gaW5mby0+Z2lkKSBeCisJCSAgICAhIShpbmZvLT5pbnZlcnQgJiBJUFRfT1dORVJfR0lEKSkKKwkJCXJldHVybiAwOworCX0KKworCWlmKGluZm8tPm1hdGNoICYgSVBUX09XTkVSX1BJRCkgeworCQlpZiAoIW1hdGNoX3BpZChza2IsIGluZm8tPnBpZCkgXgorCQkgICAgISEoaW5mby0+aW52ZXJ0ICYgSVBUX09XTkVSX1BJRCkpCisJCQlyZXR1cm4gMDsKKwl9CisKKwlpZihpbmZvLT5tYXRjaCAmIElQVF9PV05FUl9TSUQpIHsKKwkJaWYgKCFtYXRjaF9zaWQoc2tiLCBpbmZvLT5zaWQpIF4KKwkJICAgICEhKGluZm8tPmludmVydCAmIElQVF9PV05FUl9TSUQpKQorCQkJcmV0dXJuIDA7CisJfQorCisJaWYoaW5mby0+bWF0Y2ggJiBJUFRfT1dORVJfQ09NTSkgeworCQlpZiAoIW1hdGNoX2NvbW0oc2tiLCBpbmZvLT5jb21tKSBeCisJCSAgICAhIShpbmZvLT5pbnZlcnQgJiBJUFRfT1dORVJfQ09NTSkpCisJCQlyZXR1cm4gMDsKKwl9CisKKwlyZXR1cm4gMTsKK30KKworc3RhdGljIGludAorY2hlY2tlbnRyeShjb25zdCBjaGFyICp0YWJsZW5hbWUsCisgICAgICAgICAgIGNvbnN0IHN0cnVjdCBpcHRfaXAgKmlwLAorICAgICAgICAgICB2b2lkICptYXRjaGluZm8sCisgICAgICAgICAgIHVuc2lnbmVkIGludCBtYXRjaHNpemUsCisgICAgICAgICAgIHVuc2lnbmVkIGludCBob29rX21hc2spCit7CisgICAgICAgIGlmIChob29rX21hc2sKKyAgICAgICAgICAgICYgfigoMSA8PCBORl9JUF9MT0NBTF9P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gICAoISEobmZfYnJpZGdlLT5tYXNrICYgQlJORl9CUklER0VEKSBeCisJICAgICEoaW5mby0+aW52ZXJ0ICYgSVBUX1BIWVNERVZfT1BfQlJJREdFRCkpKQorCQlyZXR1cm4gTk9NQVRDSDsKKworCWlmICgoaW5mby0+Yml0bWFzayAmIElQVF9QSFlTREVWX09QX0lTSU4gJiYKKwkgICAgKCFuZl9icmlkZ2UtPnBoeXNpbmRldiBeICEhKGluZm8tPmludmVydCAmIElQVF9QSFlTREVWX09QX0lTSU4pKSkgfHwKKwkgICAgKGluZm8tPmJpdG1hc2sgJiBJUFRfUEhZU0RFVl9PUF9JU09VVCAmJgorCSAgICAoIW5mX2JyaWRnZS0+cGh5c291dGRldiBeICEhKGluZm8tPmludmVydCAmIElQVF9QSFlTREVWX09QX0lTT1VUKSkpKQorCQlyZXR1cm4gTk9NQVRDSDsKKworCWlmICghKGluZm8tPmJpdG1hc2sgJiBJUFRfUEhZU0RFVl9PUF9JTikpCisJCWdvdG8gbWF0Y2hfb3V0ZGV2OworCWluZGV2ID0gbmZfYnJpZGdlLT5waHlzaW5kZXYgPyBuZl9icmlkZ2UtPnBoeXNpbmRldi0+bmFtZSA6IG51bGxkZXZuYW1lOworCWZvciAoaSA9IDAsIHJldCA9IDA7IGkgPCBJRk5BTVNJWi9zaXplb2YodW5zaWduZWQgaW50KTsgaSsrKSB7CisJCXJldCB8PSAoKChjb25zdCB1bnNpZ25lZCBpbnQgKilpbmRldilbaV0KKwkJCV4gKChjb25zdCB1bnNpZ25lZCBpbnQgKilpbmZvLT5waHlzaW5kZXYpW2ldKQorCQkJJiAoKGNvbnN0IHVuc2lnbmVkIGludCAqKWluZm8tPmluX21hc2spW2ldOworCX0KKworCWlmICgocmV0ID09IDApIF4gIShpbmZvLT5pbnZlcnQgJiBJUFRfUEhZU0RFVl9PUF9JTikpCisJCXJldHVybiBOT01BVENIOworCittYXRjaF9vdXRkZXY6CisJaWYgKCEoaW5mby0+Yml0bWFzayAmIElQVF9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2RldmljZSAqb3V0LAorICAgICAgY29uc3Qgdm9pZCAqbWF0Y2hpbmZvLAorICAgICAgaW50IG9mZnNldCwKKyAgICAgIGludCAqaG90ZHJvcCkKK3sKKwljb25zdCBzdHJ1Y3QgaXB0X3JlYWxtX2luZm8gKmluZm8gPSBtYXRjaGluZm87CisJc3RydWN0IGRzdF9lbnRyeSAqZHN0ID0gc2tiLT5kc3Q7CisgICAgCisJcmV0dXJuIChpbmZvLT5pZCA9PSAoZHN0LT50Y2xhc3NpZCAmIGluZm8tPm1hc2spKSBeIGluZm8tPmludmVydDsKK30KKworc3RhdGljIGludCBjaGVjayhjb25zdCBjaGFyICp0YWJsZW5hbWUsCisgICAgICAgICAgICAgICAgIGNvbnN0IHN0cnVjdCBpcHRfaXAgKmlwLAorICAgICAgICAgICAgICAgICB2b2lkICptYXRjaGluZm8sCisgICAgICAgICAgICAgICAgIHVuc2lnbmVkIGludCBtYXRjaHNpemUsCisgICAgICAgICAgICAgICAgIHVuc2lnbmVkIGludCBob29rX21hc2spCit7CisJaWYgKGhvb2tfbWFzaworCSAgICAmIH4oKDEgPDwgTkZfSVBfUE9TVF9ST1VUSU5HKSB8ICgxIDw8IE5GX0lQX0ZPUldBUkQpIHwKKwkgICAgICAgICgxIDw8IE5GX0lQX0xPQ0FMX09VVCkgfCAoMSA8PCBORl9JUF9MT0NBTF9JTikpKSB7CisJCXByaW50aygiaXB0X3JlYWxtOiBvbmx5IHZhbGlkIGZvciBQT1NUX1JPVVRJTkcsIExPQ0FMX09VVCwgIgorCQkgICAgICAgIkxPQ0FMX0lOIG9yIEZPUldBUkQuXG4iKTsKKwkJcmV0dXJuIDA7CisJfQorCWlmIChtYXRjaHNpemUgIT0gSVBUX0FMSUdOKHNpemVvZihzdHJ1Y3QgaXB0X3JlYWxtX2luZm8pKSkgeworCQlwcmludGsoImlwdF9yZWFsbTogaW52YWxpZCBtYXRjaHNpemUuXG4iKTsKKwkJcmV0dXJuIDA7CisJfQorCXJldHVybiAxOwor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kJZXJyID0gMDsKKworb3V0OgorCWlmIChzaykgeworCQlpZiAoc2stPnNrX3N0YXRlID09IFRDUF9USU1FX1dBSVQpCisJCQl0Y3BfdHdfcHV0KChzdHJ1Y3QgdGNwX3R3X2J1Y2tldCopc2spOworCQllbHNlCisJCQlzb2NrX3B1dChzayk7CisJfQorCXJldHVybiBlcnI7Cit9CisKK3N0YXRpYyBpbnQgYml0c3RyaW5nX21hdGNoKGNvbnN0IHUzMiAqYTEsIGNvbnN0IHUzMiAqYTIsIGludCBiaXRzKQoreworCWludCB3b3JkcyA9IGJpdHMgPj4gNTsKKworCWJpdHMgJj0gMHgxZjsKKworCWlmICh3b3JkcykgeworCQlpZiAobWVtY21wKGExLCBhMiwgd29yZHMgPDwgMikpCisJCQlyZXR1cm4gMDsKKwl9CisJaWYgKGJpdHMpIHsKKwkJX191MzIgdzEsIHcyOworCQlfX3UzMiBtYXNrOworCisJCXcxID0gYTFbd29yZHNdOworCQl3MiA9IGEyW3dvcmRzXTsKKworCQltYXNrID0gaHRvbmwoKDB4ZmZmZmZmZmYpIDw8ICgzMiAtIGJpdHMpKTsKKworCQlpZiAoKHcxIF4gdzIpICYgbWFzaykKKwkJCXJldHVybiAwOworCX0KKworCXJldHVybiAxOworfQorCisKK3N0YXRpYyBpbnQgdGNwZGlhZ19iY19ydW4oY29uc3Qgdm9pZCAqYmMsIGludCBsZW4sCisJCQkgIGNvbnN0IHN0cnVjdCB0Y3BkaWFnX2VudHJ5ICplbnRyeSkKK3sKKwl3aGlsZSAobGVuID4gMCkgeworCQlpbnQgeWVzID0gMTsKKwkJY29uc3Qgc3RydWN0IHRjcGRpYWdfYmNfb3AgKm9wID0gYmM7CisKKwkJc3dpdGNoIChvcC0+Y29kZSkgeworCQljYXNlIFRDUERJQUdfQkNfTk9QOgorCQkJYnJlYWs7CisJCWNhc2UgVENQRElBR19CQ19KTVA6CisJCQl5ZXMgPSAwOworCQkJYnJlYWs7CisJCWNhc2UgVENQRElBR19CQ19TX0dF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c2tiOworICAgICAgICBzdHJ1Y3QgaWNtcDZoZHIgKmhkcjsKKwlfX3U4ICogb3B0OworICAgICAgICBpbnQgbGVuOworCWludCBlcnI7CisKKwluZGlzY19mbG93X2luaXQoJmZsLCBORElTQ19ST1VURVJfU09MSUNJVEFUSU9OLCBzYWRkciwgZGFkZHIpOworCisJZHN0ID0gbmRpc2NfZHN0X2FsbG9jKGRldiwgTlVMTCwgZGFkZHIsIGlwNl9vdXRwdXQpOworCWlmICghZHN0KQorCQlyZXR1cm47CisKKwllcnIgPSB4ZnJtX2xvb2t1cCgmZHN0LCAmZmwsIE5VTEwsIDApOworCWlmIChlcnIgPCAwKSB7CisJCWRzdF9yZWxlYXNlKGRzdCk7CisJCXJldHVybjsKKwl9CisKKwlsZW4gPSBzaXplb2Yoc3RydWN0IGljbXA2aGRyKTsKKwlpZiAoZGV2LT5hZGRyX2xlbikKKwkJbGVuICs9IG5kaXNjX29wdF9hZGRyX3NwYWNlKGRldik7CisKKyAgICAgICAgc2tiID0gc29ja19hbGxvY19zZW5kX3NrYihzaywgTUFYX0hFQURFUiArIGxlbiArIExMX1JFU0VSVkVEX1NQQUNFKGRldiksCisJCQkJICAxLCAmZXJyKTsKKwlpZiAoc2tiID09IE5VTEwpIHsKKwkJTkRfUFJJTlRLMChLRVJOX0VSUgorCQkJICAgIklDTVB2NiBSUzogJXMoKSBmYWlsZWQgdG8gYWxsb2NhdGUgYW4gc2tiLlxuIiwgCisJCQkgICBfX0ZVTkNUSU9OX18pOworCQlkc3RfcmVsZWFzZShkc3QpOworCQlyZXR1cm47CisJfQorCisJc2tiX3Jlc2VydmUoc2tiLCBMTF9SRVNFUlZFRF9TUEFDRShkZXYpKTsKKwlpcDZfbmRfaGRyKHNrLCBza2IsIGRldiwgc2FkZHIsIGRhZGRyLCBJUFBST1RPX0lDTVBWNiwgbGVuKTsKKworICAgICAgICBoZHIgPSAoc3RydWN0IGljbXA2aGRyICopc2tiX3B1dChza2IsIGxlbik7CisgICAgICAg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9ICJuZXQiLAorCQkubW9kZQkJPSAwNTU1LAorCQkuY2hpbGQJCT0gaXBxX2Rpcl90YWJsZQorCX0sCisJeyAuY3RsX25hbWUgPSAwIH0KK307CisKK3N0YXRpYyBpbnQKK2lwcV9nZXRfaW5mbyhjaGFyICpidWZmZXIsIGNoYXIgKipzdGFydCwgb2ZmX3Qgb2Zmc2V0LCBpbnQgbGVuZ3RoKQoreworCWludCBsZW47CisKKwlyZWFkX2xvY2tfYmgoJnF1ZXVlX2xvY2spOworCQorCWxlbiA9IHNwcmludGYoYnVmZmVyLAorCSAgICAgICAgICAgICAgIlBlZXIgUElEICAgICAgICAgIDogJWRcbiIKKwkgICAgICAgICAgICAgICJDb3B5IG1vZGUgICAgICAgICA6ICVodVxuIgorCSAgICAgICAgICAgICAgIkNvcHkgcmFuZ2UgICAgICAgIDogJXVcbiIKKwkgICAgICAgICAgICAgICJRdWV1ZSBsZW5ndGggICAgICA6ICV1XG4iCisJICAgICAgICAgICAgICAiUXVldWUgbWF4LiBsZW5ndGggOiAldVxuIgorCQkgICAgICAiUXVldWUgZHJvcHBlZCAgICAgOiAldVxuIgorCQkgICAgICAiTmV0ZmlsdGVyIGRyb3BwZWQgOiAldVxuIiwKKwkgICAgICAgICAgICAgIHBlZXJfcGlkLAorCSAgICAgICAgICAgICAgY29weV9tb2RlLAorCSAgICAgICAgICAgICAgY29weV9yYW5nZSwKKwkgICAgICAgICAgICAgIHF1ZXVlX3RvdGFsLAorCSAgICAgICAgICAgICAgcXVldWVfbWF4bGVuLAorCQkgICAgICBxdWV1ZV9kcm9wcGVkLAorCQkgICAgICBxdWV1ZV91c2VyX2Ryb3BwZWQpOworCisJcmVhZF91bmxvY2tfYmgoJnF1ZXVlX2xvY2spOworCQorCSpzdGFydCA9IGJ1ZmZlciArIG9mZnNldDsKKwlsZW4gLT0gb2Zmc2V0OworCWlmIChsZW4gPiBsZW5ndGgpCisJCWxlbiA9IGxlbmd0aDsKKwllbHNlIGlmIChsZW4gPCAw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4gTmVlZGVkIGZvciBtb2R1bGUgdXNhZ2UgY291bnQgKi8KKwl1bnNpZ25lZCBpbnQgaW5pdGlhbF9lbnRyaWVzOworCisJLyogRW50cnkgcG9pbnRzIGFuZCB1bmRlcmZsb3dzICovCisJdW5zaWduZWQgaW50IGhvb2tfZW50cnlbTkZfSVA2X05VTUhPT0tTXTsKKwl1bnNpZ25lZCBpbnQgdW5kZXJmbG93W05GX0lQNl9OVU1IT09LU107CisKKwkvKiBpcDZ0X2VudHJ5IHRhYmxlczogb25lIHBlciBDUFUgKi8KKwljaGFyIGVudHJpZXNbMF0gX19fX2NhY2hlbGluZV9hbGlnbmVkOworfTsKKworc3RhdGljIExJU1RfSEVBRChpcDZ0X3RhcmdldCk7CitzdGF0aWMgTElTVF9IRUFEKGlwNnRfbWF0Y2gpOworc3RhdGljIExJU1RfSEVBRChpcDZ0X3RhYmxlcyk7CisjZGVmaW5lIEFERF9DT1VOVEVSKGMsYixwKSBkbyB7IChjKS5iY250ICs9IChiKTsgKGMpLnBjbnQgKz0gKHApOyB9IHdoaWxlKDApCisKKyNpZmRlZiBDT05GSUdfU01QCisjZGVmaW5lIFRBQkxFX09GRlNFVCh0LHApIChTTVBfQUxJR04oKHQpLT5zaXplKSoocCkpCisjZWxzZQorI2RlZmluZSBUQUJMRV9PRkZTRVQodCxwKSAwCisjZW5kaWYKKworI2lmIDAKKyNkZWZpbmUgZG93bih4KSBkbyB7IHByaW50aygiRE9XTjoldToiICN4ICJcbiIsIF9fTElORV9fKTsgZG93bih4KTsgfSB3aGlsZSgwKQorI2RlZmluZSBkb3duX2ludGVycnVwdGlibGUoeCkgKHsgaW50IF9fcjsgcHJpbnRrKCJET1dOaToldToiICN4ICJcbiIsIF9fTElORV9fKTsgX19yID0gZG93bl9pbnRlcnJ1cHRpYmxlKHgpOyBpZiAoX19yICE9IDApIHByaW50aygiQUJPUlQtRE9XTmk6JXVcbiIsIF9fTElORV9fKTsgX19yOyB9KQorI2RlZmluZSB1cCh4KSBkbyB7IHByaW50aygiVVA6JXU6IiAjeCAiXG4iLCBfX0xJTkVfXyk7IHVwKHgpOyB9IHdoaWxlKDApCisjZW5kaWYKKworc3RhdGljIGludCBpcDZfbWFza2VkX2FkZHJjbXAoc3RydWN0IGluNl9hZGRyIGFkZHIxLCBzdHJ1Y3QgaW42X2FkZHIgbWFzaywKKwkJCSAgICAgIHN0cnVjdCBpbjZfYWRkciBhZGRyMikKK3sKKwlpbnQgaTsKKwlmb3IoIGkgPSAwOyBpIDwgMTY7IGkrKyl7CisJCWlmKChhZGRyMS5zNl9hZGRyW2ldICYgbWFzay5zNl9hZGRyW2ldKSAhPSAKKwkJICAgKGFkZHIyLnM2X2FkZHJbaV0gJiBtYXNrLnM2X2FkZHJbaV0pKQorCQkJcmV0dXJuIDE7CisJfQorCXJldHVybiAwOworfQorCisvKiBDaGVjayBmb3IgYW4gZXh0ZW5zaW9uICovCitpbnQgCitpcDZ0X2V4dF9oZHIodTggbmV4dGhkcikKK3sKKyAgICAgICAgcmV0dXJuICggKG5leHRoZHIgPT0gSVBQUk9UT19IT1BPUFRTKSAgIHx8CisgICAgICAgICAgICAgICAgIChuZXh0aGRyID09IElQUFJPVE9fUk9VVElORykgICB8fAorICAgICAgICAgICAgICAgICAobmV4dGhkciA9PSBJUFBST1RPX0ZSQUdNRU5UKSAgfHwKKyAgICAgICAgICAgICAgICAgKG5leHRoZHIgPT0gSVBQUk9UT19FU1ApICAgICAgIHx8CisgICAgICAgICAgICAgICAgIChuZXh0aGRyID09IElQUFJPVE9fQUgpICAgICAgICB8fAorICAgICAgICAgICAgICAgICAobmV4dGhkciA9PSBJUFBST1RPX05PTkUpICAgICAgfHwKKyAgICAgICAgICAgICAgICAgKG5leHRoZHIgPT0gSVBQUk9UT19EU1RPUFRTKSApOworfQorCisvKiBSZXR1cm5zIHdoZXRoZXIgbWF0Y2hlcyBydWxlIG9yIG5vdC4gKi8KK3N0YXRpYyBpbmxpbmUgaW50CitpcDZfcGFja2V0X21hdG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CQkgKiB3ZSB3aWxsIGNoYW5nZSB0aGUgcmV0dXJuIDAgdG8gMSovCisJCQlpZiAoKGN1cnJlbnRoZHIgPT0gSVBQUk9UT19OT05FKSB8fCAKKwkJCQkoY3VycmVudGhkciA9PSBJUFBST1RPX0VTUCkpCisJCQkJYnJlYWs7CisKKwkJCWhwID0gc2tiX2hlYWRlcl9wb2ludGVyKHNrYiwgcHRyLCBzaXplb2YoX2hkciksICZfaGRyKTsKKwkJCUJVR19PTihocCA9PSBOVUxMKTsKKworCQkJLyogU2l6ZSBjYWxjdWxhdGlvbiAqLworCSAgICAgICAgICAgICAgICBpZiAoY3VycmVudGhkciA9PSBJUFBST1RPX0ZSQUdNRU5UKSB7CisJCQkJZnAgPSBza2JfaGVhZGVyX3BvaW50ZXIoc2tiLAorCQkJCQkJICAgcHRyK29mZnNldG9mKHN0cnVjdCBmcmFnX2hkciwKKwkJCQkJCQkJZnJhZ19vZmYpLAorCQkJCQkJICAgc2l6ZW9mKF9mcmFnb2ZmKSwKKwkJCQkJCSAgICZfZnJhZ29mZik7CisJCQkJaWYgKGZwID09IE5VTEwpCisJCQkJCXJldHVybiAwOworCisJCQkJX2ZyYWdvZmYgPSBudG9ocygqZnApICYgfjB4NzsKKwkgICAgICAgICAgICAgICAgICAgICAgICBoZHJsZW4gPSA4OworCSAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGN1cnJlbnRoZHIgPT0gSVBQUk9UT19BSCkKKwkgICAgICAgICAgICAgICAgICAgICAgICBoZHJsZW4gPSAoaHAtPmhkcmxlbisyKTw8MjsKKwkgICAgICAgICAgICAgICAgZWxzZQorCSAgICAgICAgICAgICAgICAgICAgICAgIGhkcmxlbiA9IGlwdjZfb3B0bGVuKGhwKTsKKworCQkJY3VycmVudGhkciA9IGhwLT5uZXh0aGRyOworCSAgICAgICAgICAgICAgICBwdHIgKz0gaGRybGVuOworCQkJLyogcHRyIGlzIHRvbyBsYXJnZSAqLworCSAgICAgICAgICAgICAgICBpZiAo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B0aGUgdXNlci1zdXBwbGllZCB0YWJsZSBzZWdtZW50IChoZWxkIGluCisgICBuZXdpbmZvKSAqLworc3RhdGljIGludAordHJhbnNsYXRlX3RhYmxlKGNvbnN0IGNoYXIgKm5hbWUsCisJCXVuc2lnbmVkIGludCB2YWxpZF9ob29rcywKKwkJc3RydWN0IGlwNnRfdGFibGVfaW5mbyAqbmV3aW5mbywKKwkJdW5zaWduZWQgaW50IHNpemUsCisJCXVuc2lnbmVkIGludCBudW1iZXIsCisJCWNvbnN0IHVuc2lnbmVkIGludCAqaG9va19lbnRyaWVzLAorCQljb25zdCB1bnNpZ25lZCBpbnQgKnVuZGVyZmxvd3MpCit7CisJdW5zaWduZWQgaW50IGk7CisJaW50IHJldDsKKworCW5ld2luZm8tPnNpemUgPSBzaXplOworCW5ld2luZm8tPm51bWJlciA9IG51bWJlcjsKKworCS8qIEluaXQgYWxsIGhvb2tzIHRvIGltcG9zc2libGUgdmFsdWUuICovCisJZm9yIChpID0gMDsgaSA8IE5GX0lQNl9OVU1IT09LUzsgaSsrKSB7CisJCW5ld2luZm8tPmhvb2tfZW50cnlbaV0gPSAweEZGRkZGRkZGOworCQluZXdpbmZvLT51bmRlcmZsb3dbaV0gPSAweEZGRkZGRkZGOworCX0KKworCWR1cHJpbnRmKCJ0cmFuc2xhdGVfdGFibGU6IHNpemUgJXVcbiIsIG5ld2luZm8tPnNpemUpOworCWkgPSAwOworCS8qIFdhbGsgdGhyb3VnaCBlbnRyaWVzLCBjaGVja2luZyBvZmZzZXRzLiAqLworCXJldCA9IElQNlRfRU5UUllfSVRFUkFURShuZXdpbmZvLT5lbnRyaWVzLCBuZXdpbmZvLT5zaXplLAorCQkJCWNoZWNrX2VudHJ5X3NpemVfYW5kX2hvb2tzLAorCQkJCW5ld2luZm8sCisJCQkJbmV3aW5mby0+ZW50cmllcywKKwkJCQluZXdpbmZvLT5lbnRyaWVzICsgc2l6ZSwKKwkJCQlob29rX2VudHJpZXMsIHVuZGVyZmxvd3M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S8qIERvIHRoZSBzdWJzdGl0dXRpb24uICovCisJd3JpdGVfbG9ja19iaCgmdGFibGUtPmxvY2spOworCS8qIENoZWNrIGluc2lkZSBsb2NrOiBpcyB0aGUgb2xkIG51bWJlciBjb3JyZWN0PyAqLworCWlmIChudW1fY291bnRlcnMgIT0gdGFibGUtPnByaXZhdGUtPm51bWJlcikgeworCQlkdXByaW50ZigibnVtX2NvdW50ZXJzICE9IHRhYmxlLT5wcml2YXRlLT5udW1iZXIgKCV1LyV1KVxuIiwKKwkJCSBudW1fY291bnRlcnMsIHRhYmxlLT5wcml2YXRlLT5udW1iZXIpOworCQl3cml0ZV91bmxvY2tfYmgoJnRhYmxlLT5sb2NrKTsKKwkJKmVycm9yID0gLUVBR0FJTjsKKwkJcmV0dXJuIE5VTEw7CisJfQorCW9sZGluZm8gPSB0YWJsZS0+cHJpdmF0ZTsKKwl0YWJsZS0+cHJpdmF0ZSA9IG5ld2luZm87CisJbmV3aW5mby0+aW5pdGlhbF9lbnRyaWVzID0gb2xkaW5mby0+aW5pdGlhbF9lbnRyaWVzOworCXdyaXRlX3VubG9ja19iaCgmdGFibGUtPmxvY2spOworCisJcmV0dXJuIG9sZGluZm87Cit9CisKKy8qIEdldHMgY291bnRlcnMuICovCitzdGF0aWMgaW5saW5lIGludAorYWRkX2VudHJ5X3RvX2NvdW50ZXIoY29uc3Qgc3RydWN0IGlwNnRfZW50cnkgKmUsCisJCSAgICAgc3RydWN0IGlwNnRfY291bnRlcnMgdG90YWxbXSwKKwkJICAgICB1bnNpZ25lZCBpbnQgKmkpCit7CisJQUREX0NPVU5URVIodG90YWxbKmldLCBlLT5jb3VudGVycy5iY250LCBlLT5jb3VudGVycy5wY250KTsKKworCSgqaSkrKzsKKwlyZXR1cm4gMDsKK30KKworc3RhdGljIHZvaWQKK2dldF9jb3VudGVycyhjb25zdCBzdHJ1Y3QgaXA2dF90YWJsZV9pbmZvICp0LAorCSAgICAgc3RydWN0IGlwNnRfY291bnRlcnMgY291bn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gPSBpcDZ0X2ZpbmRfdGFibGVfbG9jayh0bXAubmFtZSwgJnJldCwgJmlwNnRfbXV0ZXgpOworCWlmICghdCkKKwkJZ290byBmcmVlX25ld2luZm9fY291bnRlcnNfdW50cmFuczsKKworCS8qIFlvdSBsaWVkISAqLworCWlmICh0bXAudmFsaWRfaG9va3MgIT0gdC0+dmFsaWRfaG9va3MpIHsKKwkJZHVwcmludGYoIlZhbGlkIGhvb2sgY3JhcDogJTA4WCB2cyAlMDhYXG4iLAorCQkJIHRtcC52YWxpZF9ob29rcywgdC0+dmFsaWRfaG9va3MpOworCQlyZXQgPSAtRUlOVkFMOworCQlnb3RvIGZyZWVfbmV3aW5mb19jb3VudGVyc191bnRyYW5zX3VubG9jazsKKwl9CisKKwkvKiBHZXQgYSByZWZlcmVuY2UgaW4gYWR2YW5jZSwgd2UncmUgbm90IGFsbG93ZWQgZmFpbCBsYXRlciAqLworCWlmICghdHJ5X21vZHVsZV9nZXQodC0+bWUpKSB7CisJCXJldCA9IC1FQlVTWTsKKwkJZ290byBmcmVlX25ld2luZm9fY291bnRlcnNfdW50cmFuc191bmxvY2s7CisJfQorCisJb2xkaW5mbyA9IHJlcGxhY2VfdGFibGUodCwgdG1wLm51bV9jb3VudGVycywgbmV3aW5mbywgJnJldCk7CisJaWYgKCFvbGRpbmZvKQorCQlnb3RvIHB1dF9tb2R1bGU7CisKKwkvKiBVcGRhdGUgbW9kdWxlIHVzYWdlIGNvdW50IGJhc2VkIG9uIG51bWJlciBvZiBydWxlcyAqLworCWR1cHJpbnRmKCJkb19yZXBsYWNlOiBvbGRudW09JXUsIGluaXRudW09JXUsIG5ld251bT0ldVxuIiwKKwkJb2xkaW5mby0+bnVtYmVyLCBvbGRpbmZvLT5pbml0aWFsX2VudHJpZXMsIG5ld2luZm8tPm51bWJlcik7CisJaWYgKChvbGRpbmZvLT5udW1iZXIgPiBvbGRpbmZvLT5pbml0aWFsX2VudHJpZXMpIHx8IAorCSAgICAobmV3aW5mby0+bnV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BORVhUSERSX0VTUCkKKwkJCWJyZWFrOworCisJCWhwID0gc2tiX2hlYWRlcl9wb2ludGVyKHNrYiwgcHRyLCBzaXplb2YoX2hkciksICZfaGRyKTsKKwkJQlVHX09OKGhwID09IE5VTEwpOworCisJCS8qIENhbGN1bGF0ZSB0aGUgaGVhZGVyIGxlbmd0aCAqLworCQlpZiAobmV4dGhkciA9PSBORVhUSERSX0ZSQUdNRU5UKQorCQkJaGRybGVuID0gODsKKwkJZWxzZSBpZiAobmV4dGhkciA9PSBORVhUSERSX0FVVEgpCisJCQloZHJsZW4gPSAoaHAtPmhkcmxlbisyKTw8MjsKKwkJZWxzZQorCQkJaGRybGVuID0gaXB2Nl9vcHRsZW4oaHApOworCisJCS8qIEFIIC0+IGV2YWx1YXRlICovCisJCWlmIChuZXh0aGRyID09IE5FWFRIRFJfQVVUSCkgeworCQkJdGVtcCB8PSBNQVNLX0FIOworCQkJYnJlYWs7CisJCX0KKworCQkKKwkJLyogc2V0IHRoZSBmbGFnICovCisJCXN3aXRjaCAobmV4dGhkcikgeworCQljYXNlIE5FWFRIRFJfSE9QOgorCQljYXNlIE5FWFRIRFJfUk9VVElORzoKKwkJY2FzZSBORVhUSERSX0ZSQUdNRU5UOgorCQljYXNlIE5FWFRIRFJfQVVUSDoKKwkJY2FzZSBORVhUSERSX0RFU1Q6CisJCQlicmVhazsKKwkJZGVmYXVsdDoKKwkJCURFQlVHUCgiaXB2Nl9haCBtYXRjaDogdW5rbm93biBuZXh0aGVhZGVyICV1XG4iLG5leHRoZHIpOworCQkJcmV0dXJuIDA7CisJCX0KKworCQluZXh0aGRyID0gaHAtPm5leHRoZHI7CisJCWxlbiAtPSBoZHJsZW47CisJCXB0ciArPSBoZHJsZW47CisJCWlmIChwdHIgPiBza2ItPmxlbikgeworCQkJREVCVUdQKCJpcHY2X2FoOiBuZXcgcG9pbnRlciB0b28gbGFyZ2UhIFxuIik7CisJCQlicmVhazsKKwkJfQorCX0KKworCS8qIEFIIGhlYWRlciBub3QgZm91bmQgKi8KKwlpZiAodGVtcCAhPSBNQVNLX0FIKQorCQlyZXR1cm4gMDsKKworCWlmIChsZW4gPCBzaXplb2Yoc3RydWN0IGlwX2F1dGhfaGRyKSl7CisJCSpob3Rkcm9wID0gMTsKKwkJcmV0dXJuIDA7CisJfQorCisJYWggPSBza2JfaGVhZGVyX3BvaW50ZXIoc2tiLCBwdHIsIHNpemVvZihfYWgpLCAmX2FoKTsKKwlCVUdfT04oYWggPT0gTlVMTCk7CisKKwlERUJVR1AoIklQdjYgQUggTEVOICV1ICV1ICIsIGhkcmxlbiwgYWgtPmhkcmxlbik7CisJREVCVUdQKCJSRVMgJTA0WCAiLCBhaC0+cmVzZXJ2ZWQpOworCURFQlVHUCgiU1BJICV1ICUwOFhcbiIsIG50b2hsKGFoLT5zcGkpLCBudG9obChhaC0+c3BpKSk7CisKKwlERUJVR1AoIklQdjYgQUggc3BpICUwMlggIiwKKwkgICAgICAgKHNwaV9tYXRjaChhaGluZm8tPnNwaXNbMF0sIGFoaW5mby0+c3Bpc1sxXSwKKwkgICAgICAgICAgICAgICAgICBudG9obChhaC0+c3BpKSwKKwkgICAgICAgICAgICAgICAgICAhIShhaGluZm8tPmludmZsYWdzICYgSVA2VF9BSF9JTlZfU1BJKSkpKTsKKwlERUJVR1AoImxlbiAlMDJYICUwNFggJTAyWCAiLAorCSAgICAgICBhaGluZm8tPmhkcmxlbiwgaGRybGVuLAorCSAgICAgICAoIWFoaW5mby0+aGRybGVuIHx8CisJICAgICAgICAoYWhpbmZvLT5oZHJsZW4gPT0gaGRybGVuKSBeCisJICAgICAgICAhIShhaGluZm8tPmludmZsYWdzICYgSVA2VF9BSF9JTlZfTEVOKSkpOworCURFQlVHUCgicmVzICUwMlggJTA0WCAlMDJYXG4iLAorCSAgICAgICBhaGluZm8tPmhkcnJlcywgYWgtPnJlc2VydmVkLAorCSAgICAgICAhKGFoaW5mby0+aGRycmVzICYmIGFoLT5yZXNlcnZlZCkpOworCisJcmV0dXJuIChhaCAhPSBOVUxMKQorCSAgICAgICAmJgorCSAgICAgICAoc3BpX21hdGNoKGFoaW5mby0+c3Bpc1swXSwgYWhpbmZvLT5zcGlzWzFdLAorCSAgICAgICAgICAgICAgICAgIG50b2hsKGFoLT5zcGkpLAorCSAgICAgICAgICAgICAgICAgICEhKGFoaW5mby0+aW52ZmxhZ3MgJiBJUDZUX0FIX0lOVl9TUEkpKSkKKwkgICAgICAgJiYKKwkgICAgICAgKCFhaGluZm8tPmhkcmxlbiB8fAorCSAgICAgICAgKGFoaW5mby0+aGRybGVuID09IGhkcmxlbikgXgorCSAgICAgICAgISEoYWhpbmZvLT5pbnZmbGFncyAmIElQNlRfQUhfSU5WX0xFTikpCisJICAgICAgICYmCisJICAgICAgICEoYWhpbmZvLT5oZHJyZXMgJiYgYWgtPnJlc2VydmVkKTsKK30KKworLyogQ2FsbGVkIHdoZW4gdXNlciB0cmllcyB0byBpbnNlcnQgYW4gZW50cnkgb2YgdGhpcyB0eXBlLiAqLworc3RhdGljIGludAorY2hlY2tlbnRyeShjb25zdCBjaGFyICp0YWJsZW5hbWUsCisgICAgICAgICAgY29uc3Qgc3RydWN0IGlwNnRfaXA2ICppcCwKKyAgICAgICAgICB2b2lkICptYXRjaGluZm8sCisgICAgICAgICAgdW5zaWduZWQgaW50IG1hdGNoaW5mb3NpemUsCisgICAgICAgICAgdW5zaWduZWQgaW50IGhvb2tfbWFzaykKK3sKKwljb25zdCBzdHJ1Y3QgaXA2dF9haCAqYWhpbmZvID0gbWF0Y2hpbmZvOworCisJaWYgKG1hdGNoaW5mb3NpemUgIT0gSVA2VF9BTElHTihzaXplb2Yoc3RydWN0IGlwNnRfYWgpKSkgeworCQlERUJVR1AoImlwNnRfYWg6IG1hdGNoc2l6ZSAldSAhPSAldVxuIiwKKwkJICAgICAgIG1hdGNoaW5mb3NpemUsIElQNlRfQUxJR04oc2l6ZW9mKHN0cnVjdCBpcDZ0X2FoKSkpOworCQlyZXR1cm4gMDsKKwl9C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IHVuc2lnbmVkIGludCBoZHJsZW4gPSAwOworICAgICAgIHVuc2lnbmVkIGludCByZXQgPSAwOworICAgICAgIHU4IF9vcHR0eXBlLCAqdHAgPSBOVUxMOworICAgICAgIHU4IF9vcHRsZW4sICpscCA9IE5VTEw7CisgICAgICAgdW5zaWduZWQgaW50IG9wdGxlbjsKKyAgICAgICAKKyAgICAgICAvKiB0eXBlIG9mIHRoZSAxc3QgZXh0aGRyICovCisgICAgICAgbmV4dGhkciA9IHNrYi0+bmguaXB2NmgtPm5leHRoZHI7CisgICAgICAgLyogcG9pbnRlciB0byB0aGUgMXN0IGV4dGhkciAqLworICAgICAgIHB0ciA9IHNpemVvZihzdHJ1Y3QgaXB2Nmhkcik7CisgICAgICAgLyogYXZhaWxhYmxlIGxlbmd0aCAqLworICAgICAgIGxlbiA9IHNrYi0+bGVuIC0gcHRyOworICAgICAgIHRlbXAgPSAwOworCisgICAgICAgIHdoaWxlIChpcDZ0X2V4dF9oZHIobmV4dGhkcikpIHsKKyAgICAgICAgICAgICAgIHN0cnVjdCBpcHY2X29wdF9oZHIgX2hkciwgKmhwOworCisgICAgICAgICAgICAgIERFQlVHUCgiaXB2Nl9vcHRzIGhlYWRlciBpdGVyYXRpb24gXG4iKTsKKworICAgICAgICAgICAgICAvKiBJcyB0aGVyZSBlbm91Z2ggc3BhY2UgZm9yIHRoZSBuZXh0IGV4dCBoZWFkZXI/ICovCisgICAgICAgICAgICAgICAgaWYgKGxlbiA8IChpbnQpc2l6ZW9mKHN0cnVjdCBpcHY2X29wdF9oZHIpKQorICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIDA7CisgICAgICAgICAgICAgIC8qIE5vIG1vcmUgZXh0aGRyIC0+IGV2YWx1YXRlICovCisgICAgICAgICAgICAgICAgaWYgKG5leHRoZHIgPT0gTkVYVEhEUl9OT05FKSB7CisgICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAvKiBFU1AgLT4gZXZhbHVhdGUgKi8KKyAgICAgICAgICAgICAgICBpZiAobmV4dGhkciA9PSBORVhUSERSX0VTUCkgeworICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgIH0KKworCSAgICAgIGhwID0gc2tiX2hlYWRlcl9wb2ludGVyKHNrYiwgcHRyLCBzaXplb2YoX2hkciksICZfaGRyKTsKKwkgICAgICBCVUdfT04oaHAgPT0gTlVMTCk7CisKKyAgICAgICAgICAgICAgLyogQ2FsY3VsYXRlIHRoZSBoZWFkZXIgbGVuZ3RoICovCisgICAgICAgICAgICAgICAgaWYgKG5leHRoZHIgPT0gTkVYVEhEUl9GUkFHTUVOVCkgeworICAgICAgICAgICAgICAgICAgICAgICAgaGRybGVuID0gODsKKyAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKG5leHRoZHIgPT0gTkVYVEhEUl9BVVRIKQorICAgICAgICAgICAgICAgICAgICAgICAgaGRybGVuID0gKGhwLT5oZHJsZW4rMik8PDI7CisgICAgICAgICAgICAgICAgZWxzZQorICAgICAgICAgICAgICAgICAgICAgICAgaGRybGVuID0gaXB2Nl9vcHRsZW4oaHApOworCisgICAgICAgICAgICAgIC8qIE9QVFMgLT4gZXZhbHVhdGUgKi8KKyNpZiBIT1BCWUhPUAorICAgICAgICAgICAgICAgIGlmIChuZXh0aGRyID09IE5FWFRIRFJfSE9QKSB7CisgICAgICAgICAgICAgICAgICAgICB0ZW1wIHw9IE1BU0tfSE9QT1BUUzsKKyNlbHNlCisgICAgICAgICAgICAgICAgaWYgKG5leHRoZHIgPT0gTkVYVEhEUl9ERVNUKSB7CisgICAgICAgICAgICAgICAgICAgICB0ZW1wIHw9IE1BU0tfRFNUT1BUUzsKKyNlbmRpZgorICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgIH0KKworCisgICAgICAgICAgICAgIC8qIHNldCB0aGUgZmxhZyAqLworICAgICAgICAgICAgICBzd2l0Y2ggKG5leHRoZHIpeworICAgICAgICAgICAgICAgICAgICAgY2FzZSBORVhUSERSX0hPUDoKKyAgICAgICAgICAgICAgICAgICAgIGNhc2UgTkVYVEhEUl9ST1VUSU5HOgorICAgICAgICAgICAgICAgICAgICAgY2FzZSBORVhUSERSX0ZSQUdNRU5UOgorICAgICAgICAgICAgICAgICAgICAgY2FzZSBORVhUSERSX0FVVEg6CisgICAgICAgICAgICAgICAgICAgICBjYXNlIE5FWFRIRFJfREVTVDoKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgREVCVUdQKCJpcHY2X29wdHMgbWF0Y2g6IHVua25vd24gbmV4dGhlYWRlciAldVxuIixuZXh0aGRyKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gMDsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgfQorCisgICAgICAgICAgICAgICAgbmV4dGhkciA9IGhwLT5uZXh0aGRyOworICAgICAgICAgICAgICAgIGxlbiAtPSBoZHJsZW47CisgICAgICAgICAgICAgICAgcHRyICs9IGhkcmxlbjsKKwkJaWYgKCBwdHIgPiBza2ItPmxlbiApIHsKKwkJCURFQlVHUCgiaXB2Nl9vcHRzOiBuZXcgcG9pbnRlciBpcyB0b28gbGFyZ2UhIFxuIik7CisJCQlicmVhazsKKwkJfQorICAgICAgICB9CisKKyAgICAgICAvKiBPUFRJT05TIGhlYWRlciBub3QgZm91bmQgKi8KKyNpZiBIT1BCWUhPUAorICAgICAgIGlmICggdGVtcCAhPSBNQVNLX0hPUE9QVFMgKSByZXR1cm4gMDsKKyNlbHNlCisgICAgICAgaWYgKCB0ZW1wICE9IE1BU0tfRFNUT1BUUyApIHJldHVybiAwOworI2VuZGlmCisKKyAgICAgICBpZiAobGVuIDwgKGludClzaXplb2Yoc3RydWN0IGlwdjZfb3B0X2hkcikpeworCSAgICAgICAqaG90ZHJvcCA9IDE7CisgICAgICAgCQlyZXR1cm4gMDsKKyAgICAgICB9CisKKyAgICAgICBpZiAobGVuIDwgaGRybGVuKXsKKwkgICAgICAgLyogUGFja2V0IHNtYWxsZXIgdGhhbiBpdCdzIGxlbmd0aCBmaWVsZCAqLworICAgICAgIAkJcmV0dXJuIDA7CisgICAgICAgfQorCisgICAgICAgb2ggPSBza2JfaGVhZGVyX3BvaW50ZXIoc2tiLCBwdHIsIHNpemVvZihfb3B0c2gpLCAmX29wdHNoKTsKKyAgICAgICBCVUdfT04ob2ggPT0gTlVMTCk7CisKKyAgICAgICBERUJVR1AoIklQdjYgT1BUUyBMRU4gJXUgJXUgIiwgaGRybGVuLCBvaC0+aGRybGVuKTsKKworICAgICAgIERFQlVHUCgibGVuICUwMlggJTA0WCAlMDJYICIsCisgICAgICAgCQlvcHRpbmZvLT5oZHJsZW4sIGhkcmxlbiwKKyAgICAgICAJCSghKG9wdGluZm8tPmZsYWdzICYgSVA2VF9PUFRTX0xFTikgfHwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICgob3B0aW5mby0+aGRybGVuID09IGhkcmxlbikgXgorICAgICAgICAgICAgICAgICAgICAgICAgICAgISEob3B0aW5mby0+aW52ZmxhZ3MgJiBJUDZUX09QVFNfSU5WX0xFTikpKSk7CisKKyAgICAgICByZXQgPSAob2ggIT0gTlVMTCkKKyAgICAgICAJCSYmCisJICAgICAgCSghKG9wdGluZm8tPmZsYWdzICYgSVA2VF9PUFRTX0xFTikgfHwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICgob3B0aW5mby0+aGRybGVuID09IGhkcmxlbikgXgorICAgICAgICAgICAgICAgICAgICAgICAgICAgISEob3B0aW5mby0+aW52ZmxhZ3MgJiBJUDZUX09QVFNfSU5WX0xFTikpKTsKKworICAgICAgIHB0ciArPSAyOworICAgICAgIGhkcmxlbiAtPSAyOworICAgICAgIGlmICggIShvcHRpbmZvLT5mbGFncyAmIElQNlRfT1B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VjdCBpcDZ0X2lwNiAqaXAsCisgICAgICAgICAgdm9pZCAqbWF0Y2hpbmZvLAorICAgICAgICAgIHVuc2lnbmVkIGludCBtYXRjaGluZm9zaXplLAorICAgICAgICAgIHVuc2lnbmVkIGludCBob29rX21hc2spCit7CisgICAgICAgY29uc3Qgc3RydWN0IGlwNnRfb3B0cyAqb3B0c2luZm8gPSBtYXRjaGluZm87CisKKyAgICAgICBpZiAobWF0Y2hpbmZvc2l6ZSAhPSBJUDZUX0FMSUdOKHNpemVvZihzdHJ1Y3QgaXA2dF9vcHRzKSkpIHsKKyAgICAgICAgICAgICAgREVCVUdQKCJpcDZ0X29wdHM6IG1hdGNoc2l6ZSAldSAhPSAldVxuIiwKKyAgICAgICAgICAgICAgICAgICAgICBtYXRjaGluZm9zaXplLCBJUDZUX0FMSUdOKHNpemVvZihzdHJ1Y3QgaXA2dF9vcHRzKSkpOworICAgICAgICAgICAgICByZXR1cm4gMDsKKyAgICAgICB9CisgICAgICAgaWYgKG9wdHNpbmZvLT5pbnZmbGFncyAmIH5JUDZUX09QVFNfSU5WX01BU0spIHsKKyAgICAgICAgICAgICAgREVCVUdQKCJpcDZ0X29wdHM6IHVua25vd24gZmxhZ3MgJVhcbiIsCisgICAgICAgICAgICAgICAgICAgICAgb3B0c2luZm8tPmludmZsYWdzKTsKKyAgICAgICAgICAgICAgcmV0dXJuIDA7CisgICAgICAgfQorCisgICAgICAgcmV0dXJuIDE7Cit9CisKK3N0YXRpYyBzdHJ1Y3QgaXA2dF9tYXRjaCBvcHRzX21hdGNoID0geworI2lmIEhPUEJZSE9QCisJLm5hbWUJCT0gImhiaCIsCisjZWxzZQorCS5uYW1lCQk9ICJkc3QiLAorI2VuZGlmCisJLm1hdGNoCQk9ICZtYXRjaCwKKwkuY2hlY2tlbnRyeQk9ICZjaGVja2VudHJ5LAorCS5tZQkJPSBUSElTX01PRFVMRSwKK307CisKK3N0YXRpYyBpbnQgX19pbml0IGluaXQodm9pZCkKK3sKKyAgICA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Yi0+bWFjLnJhdyA+PSBza2ItPmhlYWQKKyAgICAgICAgICAgICAgICAmJiAoc2tiLT5tYWMucmF3ICsgRVRIX0hMRU4pIDw9IHNrYi0+ZGF0YSkKKyAgICAgICAgICAgICAgICAmJiBvZmZzZXQgIT0gMCkgeworICAgICAgICAgICAgICAgICAgICAgICAgKmhvdGRyb3AgPSAxOworICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIDA7CisgICAgICAgICAgICAgICAgfQorICAgIAorICAgIG1lbXNldChldWk2NCwgMCwgc2l6ZW9mKGV1aTY0KSk7CisKKyAgICBpZiAoZXRoX2hkcihza2IpLT5oX3Byb3RvID09IG50b2hzKEVUSF9QX0lQVjYpKSB7CisgICAgICBpZiAoc2tiLT5uaC5pcHY2aC0+dmVyc2lvbiA9PSAweDYpIHsgCisgICAgICAgICBtZW1jcHkoZXVpNjQsIGV0aF9oZHIoc2tiKS0+aF9zb3VyY2UsIDMpOworICAgICAgICAgbWVtY3B5KGV1aTY0ICsgNSwgZXRoX2hkcihza2IpLT5oX3NvdXJjZSArIDMsIDMpOworCSBldWk2NFszXT0weGZmOworCSBldWk2NFs0XT0weGZlOworCSBldWk2NFswXSB8PSAweDAyOworCisJIGk9MDsKKwkgd2hpbGUgKChza2ItPm5oLmlwdjZoLT5zYWRkci5zNl9hZGRyWzgraV0gPT0KKwkJCSBldWk2NFtpXSkgJiYgKGk8OCkpIGkrKzsKKworCSBpZiAoIGkgPT0gOCApCisJIAlyZXR1cm4gMTsKKyAgICAgIH0KKyAgICB9CisKKyAgICByZXR1cm4gMDsKK30KKworc3RhdGljIGludAoraXA2dF9ldWk2NF9jaGVja2VudHJ5KGNvbnN0IGNoYXIgKnRhYmxlbmFtZSwKKwkJICAgY29uc3Qgc3RydWN0IGlwNnRfaXA2ICppcCwKKwkJICAgdm9pZCAqbWF0Y2hpbmZvLAorCQkgICB1bnNpZ25lZCBpbnQgbWF0Y2hzaXplLAorCQkgICB1bnNpZ25lZCBpbnQgaG9va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J5IHRoZSByYW5nZSwgMCBvdGhlcndpc2UgKi8KK3N0YXRpYyBpbmxpbmUgaW50CitpZF9tYXRjaCh1X2ludDMyX3QgbWluLCB1X2ludDMyX3QgbWF4LCB1X2ludDMyX3QgaWQsIGludCBpbnZlcnQpCit7CisgICAgICAgaW50IHI9MDsKKyAgICAgICBERUJVR1AoImZyYWcgaWRfbWF0Y2g6JWMgMHgleCA8PSAweCV4IDw9IDB4JXgiLGludmVydD8gJyEnOicgJywKKyAgICAgICAgICAgICAgbWluLGlkLG1heCk7CisgICAgICAgcj0oaWQgPj0gbWluICYmIGlkIDw9IG1heCkgXiBpbnZlcnQ7CisgICAgICAgREVCVUdQKCIgcmVzdWx0ICVzXG4iLHI/ICJQQVNTIiA6ICJGQUlMRUQiKTsKKyAgICAgICByZXR1cm4gcjsKK30KKworc3RhdGljIGludAorbWF0Y2goY29uc3Qgc3RydWN0IHNrX2J1ZmYgKnNrYiwKKyAgICAgIGNvbnN0IHN0cnVjdCBuZXRfZGV2aWNlICppbiwKKyAgICAgIGNvbnN0IHN0cnVjdCBuZXRfZGV2aWNlICpvdXQsCisgICAgICBjb25zdCB2b2lkICptYXRjaGluZm8sCisgICAgICBpbnQgb2Zmc2V0LAorICAgICAgdW5zaWduZWQgaW50IHByb3RvZmYsCisgICAgICBpbnQgKmhvdGRyb3ApCit7CisgICAgICAgc3RydWN0IGZyYWdfaGRyIF9mcmFnLCAqZmggPSBOVUxMOworICAgICAgIGNvbnN0IHN0cnVjdCBpcDZ0X2ZyYWcgKmZyYWdpbmZvID0gbWF0Y2hpbmZvOworICAgICAgIHVuc2lnbmVkIGludCB0ZW1wOworICAgICAgIGludCBsZW47CisgICAgICAgdTggbmV4dGhkcjsKKyAgICAgICB1bnNpZ25lZCBpbnQgcHRyOworICAgICAgIHVuc2lnbmVkIGludCBoZHJsZW4gPSAwOworCisgICAgICAgLyogdHlwZSBvZiB0aGUgMXN0IGV4dGhkciAqLworICAgICAgIG5leHRoZHIgPSBza2ItPm5oLmlwdjZoLT5uZXh0aGRyOworICAgICAgIC8qIHBvaW50ZXIgdG8gdGhlIDFzdCBleHRoZHIgKi8KKyAgICAgICBwdHIgPSBzaXplb2Yoc3RydWN0IGlwdjZoZHIpOworICAgICAgIC8qIGF2YWlsYWJsZSBsZW5ndGggKi8KKyAgICAgICBsZW4gPSBza2ItPmxlbiAtIHB0cjsKKyAgICAgICB0ZW1wID0gMDsKKworICAgICAgICB3aGlsZSAoaXA2dF9leHRfaGRyKG5leHRoZHIpKSB7CisgICAgICAgICAgICAgICBzdHJ1Y3QgaXB2Nl9vcHRfaGRyIF9oZHIsICpocDsKKworICAgICAgICAgICAgICBERUJVR1AoImlwdjZfZnJhZyBoZWFkZXIgaXRlcmF0aW9uIFxuIik7CisKKyAgICAgICAgICAgICAgLyogSXMgdGhlcmUgZW5vdWdoIHNwYWNlIGZvciB0aGUgbmV4dCBleHQgaGVhZGVyPyAqLworICAgICAgICAgICAgICAgIGlmIChsZW4gPCAoaW50KXNpemVvZihzdHJ1Y3QgaXB2Nl9vcHRfaGRyKSkKKyAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAwOworICAgICAgICAgICAgICAvKiBObyBtb3JlIGV4dGhkciAtPiBldmFsdWF0ZSAqLworICAgICAgICAgICAgICAgIGlmIChuZXh0aGRyID09IE5FWFRIRFJfTk9ORSkgeworICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgLyogRVNQIC0+IGV2YWx1YXRlICovCisgICAgICAgICAgICAgICAgaWYgKG5leHRoZHIgPT0gTkVYVEhEUl9FU1ApIHsKKyAgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICB9CisKKwkgICAgICBocCA9IHNrYl9oZWFkZXJfcG9pbnRlcihza2IsIHB0ciwgc2l6ZW9mKF9oZHIpLCAmX2hkcik7CisJICAgICAgQlVHX09OKGhwID09IE5VTEwpOworCisgICAgICAgICAgICAgIC8qIENhbGN1bGF0ZSB0aGUgaGVhZGVyIGxlbmd0aCAqLworICAgICAgICAgICAgICAgIGlmIChuZXh0aGRyID09IE5FWFRIRFJfRlJBR01FTlQpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIGhkcmxlbiA9IDg7CisgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChuZXh0aGRyID09IE5FWFRIRFJfQVVUSCkKKyAgICAgICAgICAgICAgICAgICAgICAgIGhkcmxlbiA9IChocC0+aGRybGVuKzIpPDwyOworICAgICAgICAgICAgICAgIGVsc2UKKyAgICAgICAgICAgICAgICAgICAgICAgIGhkcmxlbiA9IGlwdjZfb3B0bGVuKGhwKTsKKworICAgICAgICAgICAgICAvKiBGUkFHIC0+IGV2YWx1YXRlICovCisgICAgICAgICAgICAgICAgaWYgKG5leHRoZHIgPT0gTkVYVEhEUl9GUkFHTUVOVCkgeworICAgICAgICAgICAgICAgICAgICAgdGVtcCB8PSBNQVNLX0ZSQUdNRU5UOworICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgIH0KKworCisgICAgICAgICAgICAgIC8qIHNldCB0aGUgZmxhZyAqLworICAgICAgICAgICAgICBzd2l0Y2ggKG5leHRoZHIpeworICAgICAgICAgICAgICAgICAgICAgY2FzZSBORVhUSERSX0hPUDoKKyAgICAgICAgICAgICAgICAgICAgIGNhc2UgTkVYVEhEUl9ST1VUSU5HOgorICAgICAgICAgICAgICAgICAgICAgY2FzZSBORVhUSERSX0ZSQUdNRU5UOgorICAgICAgICAgICAgICAgICAgICAgY2FzZSBORVhUSERSX0FVVEg6CisgICAgICAgICAgICAgICAgICAgICBjYXNlIE5FWFRIRFJfREVTVDoKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgREVCVUdQKCJpcHY2X2ZyYWcgbWF0Y2g6IHVua25vd24gbmV4dGhlYWRlciAldVxuIixuZXh0aGRyKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gMDsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgfQorCisgICAgICAgICAgICAgICAgbmV4dGhkciA9IGhwLT5uZXh0aGRyOworICAgICAgICAgICAgICAgIGxlbiAtPSBoZHJsZW47CisgICAgICAgICAgICAgICAgcHRyICs9IGhkcmxlbjsKKwkJaWYgKCBwdHIgPiBza2ItPmxlbiApIHsKKwkJCURFQlVHUCgiaXB2Nl9mcmFnOiBuZXcgcG9pbnRlciB0b28gbGFyZ2UhIFxuIik7CisJCQlicmVhazsKKwkJfQorICAgICAgICB9CisKKyAgICAgICAvKiBGUkFHIGhlYWRlciBub3QgZm91bmQgKi8KKyAgICAgICBpZiAoIHRlbXAgIT0gTUFTS19GUkFHTUVOVCApIHJldHVybiAwOworCisgICAgICAgaWYgKGxlbiA8IHNpemVvZihzdHJ1Y3QgZnJhZ19oZHIpKXsKKwkgICAgICAgKmhvdGRyb3AgPSAxOworICAgICAgIAkJcmV0dXJuIDA7CisgICAgICAgfQorCisgICAgICAgZmggPSBza2JfaGVhZGVyX3BvaW50ZXIoc2tiLCBwdHIsIHNpemVvZihfZnJhZyksICZfZnJhZyk7CisgICAgICAgQlVHX09OKGZoID09IE5VTEwpOworCisgICAgICAgREVCVUdQKCJJTkZPICUwNFggIiwgZmgtPmZyYWdfb2ZmKTsKKyAgICAgICBERUJVR1AoIk9GRlNFVCAlMDRYICIsIG50b2hzKGZoLT5mcmFnX29mZikgJiB+MHg3KTsKKyAgICAgICBERUJVR1AoIlJFUyAlMDJYICUwNFgiLCBmaC0+cmVzZXJ2ZWQsIG50b2hzKGZoLT5mcmFnX29mZikgJiAweDYpOworICAgICAgIERFQlVHUCgiTUYgJTA0WCAiLCBmaC0+ZnJhZ19vZmYgJiBodG9ucyhJUDZfTUYpKTsKKyAgICAgICBERUJVR1AoIklEICV1ICUwOF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dfb2ZmKSAmIElQNl9NRikpOworfQorCisvKiBDYWxsZWQgd2hlbiB1c2VyIHRyaWVzIHRvIGluc2VydCBhbiBlbnRyeSBvZiB0aGlzIHR5cGUuICovCitzdGF0aWMgaW50CitjaGVja2VudHJ5KGNvbnN0IGNoYXIgKnRhYmxlbmFtZSwKKyAgICAgICAgICBjb25zdCBzdHJ1Y3QgaXA2dF9pcDYgKmlwLAorICAgICAgICAgIHZvaWQgKm1hdGNoaW5mbywKKyAgICAgICAgICB1bnNpZ25lZCBpbnQgbWF0Y2hpbmZvc2l6ZSwKKyAgICAgICAgICB1bnNpZ25lZCBpbnQgaG9va19tYXNrKQoreworICAgICAgIGNvbnN0IHN0cnVjdCBpcDZ0X2ZyYWcgKmZyYWdpbmZvID0gbWF0Y2hpbmZvOworCisgICAgICAgaWYgKG1hdGNoaW5mb3NpemUgIT0gSVA2VF9BTElHTihzaXplb2Yoc3RydWN0IGlwNnRfZnJhZykpKSB7CisgICAgICAgICAgICAgIERFQlVHUCgiaXA2dF9mcmFnOiBtYXRjaHNpemUgJXUgIT0gJXVcbiIsCisgICAgICAgICAgICAgICAgICAgICAgbWF0Y2hpbmZvc2l6ZSwgSVA2VF9BTElHTihzaXplb2Yoc3RydWN0IGlwNnRfZnJhZykpKTsKKyAgICAgICAgICAgICAgcmV0dXJuIDA7CisgICAgICAgfQorICAgICAgIGlmIChmcmFnaW5mby0+aW52ZmxhZ3MgJiB+SVA2VF9GUkFHX0lOVl9NQVNLKSB7CisgICAgICAgICAgICAgIERFQlVHUCgiaXA2dF9mcmFnOiB1bmtub3duIGZsYWdzICVYXG4iLAorICAgICAgICAgICAgICAgICAgICAgIGZyYWdpbmZvLT5pbnZmbGFncyk7CisgICAgICAgICAgICAgIHJldHVybiAwOworICAgICAgIH0KKworICAgICAgIHJldHVybiAxOworfQorCitzdGF0aWMgc3RydWN0IGlwNnRfbWF0Y2ggZnJhZ19tYXRjaCA9IHsKKwkubmFtZQkJPSAiZnJhZyIsCisJLm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KyAqICAJMQktPiBjYW4gY2hhbmdlIHRoZSByb3V0aW5nCisgKiAgKFR5cGUgJiAweDFGKSBUeXBlCisgKiAgICAgIDAJLT4gUGFkMSAob25seSAxIGJ5dGUhKQorICogICAgICAxCS0+IFBhZE4gTEVOR1RIIGluZm8gKHRvdGFsIGxlbmd0aCA9IGxlbmd0aCArIDIpCisgKiAgICAgIEMwIHwgMgktPiBKVU1CTyA0IHggeCB4IHggKCB4eHh4ID4gNjRrICkKKyAqICAgICAgNQktPiBSVEFMRVJUIDIgeCB4CisgKi8KKworc3RhdGljIGludAorbWF0Y2goY29uc3Qgc3RydWN0IHNrX2J1ZmYgKnNrYiwKKyAgICAgIGNvbnN0IHN0cnVjdCBuZXRfZGV2aWNlICppbiwKKyAgICAgIGNvbnN0IHN0cnVjdCBuZXRfZGV2aWNlICpvdXQsCisgICAgICBjb25zdCB2b2lkICptYXRjaGluZm8sCisgICAgICBpbnQgb2Zmc2V0LAorICAgICAgdW5zaWduZWQgaW50IHByb3RvZmYsCisgICAgICBpbnQgKmhvdGRyb3ApCit7CisgICAgICAgc3RydWN0IGlwdjZfb3B0X2hkciBfb3B0c2gsICpvaDsKKyAgICAgICBjb25zdCBzdHJ1Y3QgaXA2dF9vcHRzICpvcHRpbmZvID0gbWF0Y2hpbmZvOworICAgICAgIHVuc2lnbmVkIGludCB0ZW1wOworICAgICAgIHVuc2lnbmVkIGludCBsZW47CisgICAgICAgdTggbmV4dGhkcjsKKyAgICAgICB1bnNpZ25lZCBpbnQgcHRyOworICAgICAgIHVuc2lnbmVkIGludCBoZHJsZW4gPSAwOworICAgICAgIHVuc2lnbmVkIGludCByZXQgPSAwOworICAgICAgIHU4IF9vcHR0eXBlLCAqdHAgPSBOVUxMOworICAgICAgIHU4IF9vcHRsZW4sICpscCA9IE5VTEw7CisgICAgICAgdW5zaWduZWQgaW50IG9wdGxlbjsKKyAgICAgICAKKyAgICAgICAvKiB0eXBlIG9mIHRoZSAxc3QgZXh0aGRyICovCisgICAgICAgbmV4dGhkciA9IHNrYi0+bmguaXB2NmgtPm5leHRoZHI7CisgICAgICAgLyogcG9pbnRlciB0byB0aGUgMXN0IGV4dGhkciAqLworICAgICAgIHB0ciA9IHNpemVvZihzdHJ1Y3QgaXB2Nmhkcik7CisgICAgICAgLyogYXZhaWxhYmxlIGxlbmd0aCAqLworICAgICAgIGxlbiA9IHNrYi0+bGVuIC0gcHRyOworICAgICAgIHRlbXAgPSAwOworCisgICAgICAgIHdoaWxlIChpcDZ0X2V4dF9oZHIobmV4dGhkcikpIHsKKyAgICAgICAgICAgICAgIHN0cnVjdCBpcHY2X29wdF9oZHIgX2hkciwgKmhwOworCisgICAgICAgICAgICAgIERFQlVHUCgiaXB2Nl9vcHRzIGhlYWRlciBpdGVyYXRpb24gXG4iKTsKKworICAgICAgICAgICAgICAvKiBJcyB0aGVyZSBlbm91Z2ggc3BhY2UgZm9yIHRoZSBuZXh0IGV4dCBoZWFkZXI/ICovCisgICAgICAgICAgICAgICAgaWYgKGxlbiA8IChpbnQpc2l6ZW9mKHN0cnVjdCBpcHY2X29wdF9oZHIpKQorICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIDA7CisgICAgICAgICAgICAgIC8qIE5vIG1vcmUgZXh0aGRyIC0+IGV2YWx1YXRlICovCisgICAgICAgICAgICAgICAgaWYgKG5leHRoZHIgPT0gTkVYVEhEUl9OT05FKSB7CisgICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAvKiBFU1AgLT4gZXZhbHVhdGUgKi8KKyAgICAgICAgICAgICAgICBpZiAobmV4dGhkciA9PSBORVhUSERSX0VTUCkgeworICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgIH0KKworCSAgICAgIGhwID0gc2tiX2hlYWRlcl9wb2ludGVyKHNrYiwgcHRyLCBzaXplb2YoX2hkciksICZfaGRyKTsKKwkgICAgICBCVUdfT04oaHAgPT0gTlVMTCk7CisKKyAgICAgICAgICAgICAgLyogQ2FsY3VsYXRlIHRoZSBoZWFkZXIgbGVuZ3RoICovCisgICAgICAgICAgICAgICAgaWYgKG5leHRoZHIgPT0gTkVYVEhEUl9GUkFHTUVOVCkgeworICAgICAgICAgICAgICAgICAgICAgICAgaGRybGVuID0gODsKKyAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKG5leHRoZHIgPT0gTkVYVEhEUl9BVVRIKQorICAgICAgICAgICAgICAgICAgICAgICAgaGRybGVuID0gKGhwLT5oZHJsZW4rMik8PDI7CisgICAgICAgICAgICAgICAgZWxzZQorICAgICAgICAgICAgICAgICAgICAgICAgaGRybGVuID0gaXB2Nl9vcHRsZW4oaHApOworCisgICAgICAgICAgICAgIC8qIE9QVFMgLT4gZXZhbHVhdGUgKi8KKyNpZiBIT1BCWUhPUAorICAgICAgICAgICAgICAgIGlmIChuZXh0aGRyID09IE5FWFRIRFJfSE9QKSB7CisgICAgICAgICAgICAgICAgICAgICB0ZW1wIHw9IE1BU0tfSE9QT1BUUzsKKyNlbHNlCisgICAgICAgICAgICAgICAgaWYgKG5leHRoZHIgPT0gTkVYVEhEUl9ERVNUKSB7CisgICAgICAgICAgICAgICAgICAgICB0ZW1wIHw9IE1BU0tfRFNUT1BUUzsKKyNlbmRpZgorICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgIH0KKworCisgICAgICAgICAgICAgIC8qIHNldCB0aGUgZmxhZyAqLworICAgICAgICAgICAgICBzd2l0Y2ggKG5leHRoZHIpeworICAgICAgICAgICAgICAgICAgICAgY2FzZSBORVhUSERSX0hPUDoKKyAgICAgICAgICAgICAgICAgICAgIGNhc2UgTkVYVEhEUl9ST1VUSU5HOgorICAgICAgICAgICAgICAgICAgICAgY2FzZSBORVhUSERSX0ZSQUdNRU5UOgorICAgICAgICAgICAgICAgICAgICAgY2FzZSBORVhUSERSX0FVVEg6CisgICAgICAgICAgICAgICAgICAgICBjYXNlIE5FWFRIRFJfREVTVDoKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgREVCVUdQKCJpcHY2X29wdHMgbWF0Y2g6IHVua25vd24gbmV4dGhlYWRlciAldVxuIixuZXh0aGRyKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gMDsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgfQorCisgICAgICAgICAgICAgICAgbmV4dGhkciA9IGhwLT5uZXh0aGRyOworICAgICAgICAgICAgICAgIGxlbiAtPSBoZHJsZW47CisgICAgICAgICAgICAgICAgcHRyICs9IGhkcmxlbjsKKwkJaWYgKCBwdHIgPiBza2ItPmxlbiApIHsKKwkJCURFQlVHUCgiaXB2Nl9vcHRzOiBuZXcgcG9pbnRlciBpcyB0b28gbGFyZ2UhIFxuIik7CisJCQlicmVhazsKKwkJfQorICAgICAgICB9CisKKyAgICAgICAvKiBPUFRJT05TIGhlYWRlciBub3QgZm91bmQgKi8KKyNpZiBIT1BCWUhPUAorICAgICAgIGlmICggdGVtcCAhPSBNQVNLX0hPUE9QVFMgKSByZXR1cm4gMDsKKyNlbHNlCisgICAgICAgaWYgKCB0ZW1wICE9IE1BU0tfRFNUT1BUUyApIHJldHVybiAwOworI2VuZGlmCisKKyAgICAgICBpZiAobGVuIDwgKGludClzaXplb2Yoc3RydWN0IGlwdjZfb3B0X2hkcikpeworCSAgICAgICAqaG90ZHJvcCA9IDE7CisgICAgICAgCQlyZXR1cm4gMDsKKyAgICAgICB9CisKKyAgICAgICBpZiAobGVuIDwgaGRybGVuKXsKKwkgICAgICAgLyogUGFja2V0IHNtYWxsZXIgdGhhbiBpdCdzIGxlbmd0aCBmaWVsZCAqLworICAgICAgIAkJcmV0dXJuIDA7CisgICAgICAgfQorCisgICAgICAgb2ggPSBza2JfaGVhZGVyX3BvaW50ZXIoc2tiLCBwdHIsIHNpemVvZihfb3B0c2gpLCAmX29wdHNoKTsKKyAgICAgICBCVUdfT04ob2ggPT0gTlVMTCk7CisKKyAgICAgICBERUJVR1AoIklQdjYgT1BUUyBMRU4gJXUgJXUgIiwgaGRybGVuLCBvaC0+aGRybGVuKTsKKworICAgICAgIERFQlVHUCgibGVuICUwMlggJTA0WCAlMDJYICIsCisgICAgICAgCQlvcHRpbmZvLT5oZHJsZW4sIGhkcmxlbiwKKyAgICAgICAJCSghKG9wdGluZm8tPmZsYWdzICYgSVA2VF9PUFRTX0xFTikgfHwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICgob3B0aW5mby0+aGRybGVuID09IGhkcmxlbikgXgorICAgICAgICAgICAgICAgICAgICAgICAgICAgISEob3B0aW5mby0+aW52ZmxhZ3MgJiBJUDZUX09QVFNfSU5WX0xFTikpKSk7CisKKyAgICAgICByZXQgPSAob2ggIT0gTlVMTCkKKyAgICAgICAJCSYmCisJICAgICAgCSghKG9wdGluZm8tPmZsYWdzICYgSVA2VF9PUFRTX0xFTikgfHwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICgob3B0aW5mby0+aGRybGVuID09IGhkcmxlbikgXgorICAgICAgICAgICAgICAgICAgICAgICAgICAgISEob3B0aW5mby0+aW52ZmxhZ3MgJiBJUDZUX09QVFNfSU5WX0xFTikpKTsKKworICAgICAgIHB0ciArPSAyOworICAgICAgIGhkcmxlbiAtPSAyOworICAgICAgIGlmICggIShvcHRpbmZvLT5mbGFncyAmIElQNlRfT1BUU19PUFRTKSApeworCSAgICAgICByZXR1cm4gcmV0OworCX0gZWxzZSBpZiAob3B0aW5mby0+ZmxhZ3MgJiBJUDZUX09QVFNfTlNUUklDVCkgeworCQlERUJVR1AoIk5vdCBzdHJpY3QgLSBub3QgaW1wbGVtZW50ZWQiKTsKKwl9IGVsc2UgeworCQlERUJVR1AoIlN0cmljdCAiKTsKKwkJREVCVUdQKCIjJWQgIixvcHRpbmZvLT5vcHRzbn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VNLX05PTkU7CisJCQlicmVhazsKKwkJfQorCQkvKiBFU1AgLT4gZXZhbHVhdGUgKi8KKyAgICAgICAgICAgICAgICBpZiAobmV4dGhkciA9PSBORVhUSERSX0VTUCkgeworCQkJdGVtcCB8PSBNQVNLX0VTUDsKKwkJCWJyZWFrOworCQl9CisKKwkJaHAgPSBza2JfaGVhZGVyX3BvaW50ZXIoc2tiLCBwdHIsIHNpemVvZihfaGRyKSwgJl9oZHIpOworCQlCVUdfT04oaHAgPT0gTlVMTCk7CisKKwkJLyogQ2FsY3VsYXRlIHRoZSBoZWFkZXIgbGVuZ3RoICovCisgICAgICAgICAgICAgICAgaWYgKG5leHRoZHIgPT0gTkVYVEhEUl9GUkFHTUVOVCkgeworICAgICAgICAgICAgICAgICAgICAgICAgaGRybGVuID0gODsKKyAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKG5leHRoZHIgPT0gTkVYVEhEUl9BVVRIKQorICAgICAgICAgICAgICAgICAgICAgICAgaGRybGVuID0gKGhwLT5oZHJsZW4rMik8PDI7CisgICAgICAgICAgICAgICAgZWxzZQorICAgICAgICAgICAgICAgICAgICAgICAgaGRybGVuID0gaXB2Nl9vcHRsZW4oaHApOworCisJCS8qIHNldCB0aGUgZmxhZyAqLworCQlzd2l0Y2ggKG5leHRoZHIpeworCQkJY2FzZSBORVhUSERSX0hPUDoKKwkJCQl0ZW1wIHw9IE1BU0tfSE9QT1BUUzsKKwkJCQlicmVhazsKKwkJCWNhc2UgTkVYVEhEUl9ST1VUSU5HOgorCQkJCXRlbXAgfD0gTUFTS19ST1VUSU5HOworCQkJCWJyZWFrOworCQkJY2FzZSBORVhUSERSX0ZSQUdNRU5UOgorCQkJCXRlbXAgfD0gTUFTS19GUkFHTUVOVDsKKwkJCQlicmVhazsKKwkJCWNhc2UgTkVYVEhEUl9BVVRIOgorCQkJCXRlbXAgfD0gTUFTS19BSDsKKwkJCQlicmVhazsKKwkJCWNhc2UgTkVYVEhEUl9ERVNUOgorCQkJCX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Zm8tPnVpZCkgXgorCQkgICAgISEoaW5mby0+aW52ZXJ0ICYgSVA2VF9PV05FUl9VSUQpKQorCQkJcmV0dXJuIDA7CisJfQorCisJaWYoaW5mby0+bWF0Y2ggJiBJUDZUX09XTkVSX0dJRCkgeworCQlpZigoc2tiLT5zay0+c2tfc29ja2V0LT5maWxlLT5mX2dpZCAhPSBpbmZvLT5naWQpIF4KKwkJICAgICEhKGluZm8tPmludmVydCAmIElQNlRfT1dORVJfR0lEKSkKKwkJCXJldHVybiAwOworCX0KKworCWlmKGluZm8tPm1hdGNoICYgSVA2VF9PV05FUl9QSUQpIHsKKwkJaWYgKCFtYXRjaF9waWQoc2tiLCBpbmZvLT5waWQpIF4KKwkJICAgICEhKGluZm8tPmludmVydCAmIElQNlRfT1dORVJfUElEKSkKKwkJCXJldHVybiAwOworCX0KKworCWlmKGluZm8tPm1hdGNoICYgSVA2VF9PV05FUl9TSUQpIHsKKwkJaWYgKCFtYXRjaF9zaWQoc2tiLCBpbmZvLT5zaWQpIF4KKwkJICAgICEhKGluZm8tPmludmVydCAmIElQNlRfT1dORVJfU0lEKSkKKwkJCXJldHVybiAwOworCX0KKworCXJldHVybiAxOworfQorCitzdGF0aWMgaW50CitjaGVja2VudHJ5KGNvbnN0IGNoYXIgKnRhYmxlbmFtZSwKKyAgICAgICAgICAgY29uc3Qgc3RydWN0IGlwNnRfaXA2ICppcCwKKyAgICAgICAgICAgdm9pZCAqbWF0Y2hpbmZvLAorICAgICAgICAgICB1bnNpZ25lZCBpbnQgbWF0Y2hzaXplLAorICAgICAgICAgICB1bnNpZ25lZCBpbnQgaG9va19tYXNrKQoreworICAgICAgICBpZiAoaG9va19tYXNrCisgICAgICAgICAgICAmIH4oKDEgPDwgTkZfSVA2X0xPQ0FMX09VVCkgfCAoMSA8PCBORl9JUDZfUE9TVF9ST1VUSU5HKSkpIHsKKyAgICAgICAgICAgICAgICBwcmludGsoImlwNnRfb3duZXI6IG9ubHkgdmFsaWQgZm9yIExPQ0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y3QgbmV0X2RldmljZSAqaW4sCisgICAgICBjb25zdCBzdHJ1Y3QgbmV0X2RldmljZSAqb3V0LAorICAgICAgY29uc3Qgdm9pZCAqbWF0Y2hpbmZvLAorICAgICAgaW50IG9mZnNldCwKKyAgICAgIHVuc2lnbmVkIGludCBwcm90b2ZmLAorICAgICAgaW50ICpob3Rkcm9wKQoreworICAgICAgIHN0cnVjdCBpcHY2X3J0X2hkciBfcm91dGUsICpyaCA9IE5VTEw7CisgICAgICAgY29uc3Qgc3RydWN0IGlwNnRfcnQgKnJ0aW5mbyA9IG1hdGNoaW5mbzsKKyAgICAgICB1bnNpZ25lZCBpbnQgdGVtcDsKKyAgICAgICB1bnNpZ25lZCBpbnQgbGVuOworICAgICAgIHU4IG5leHRoZHI7CisgICAgICAgdW5zaWduZWQgaW50IHB0cjsKKyAgICAgICB1bnNpZ25lZCBpbnQgaGRybGVuID0gMDsKKyAgICAgICB1bnNpZ25lZCBpbnQgcmV0ID0gMDsKKyAgICAgICBzdHJ1Y3QgaW42X2FkZHIgKmFwLCBfYWRkcjsKKworICAgICAgIC8qIHR5cGUgb2YgdGhlIDFzdCBleHRoZHIgKi8KKyAgICAgICBuZXh0aGRyID0gc2tiLT5uaC5pcHY2aC0+bmV4dGhkcjsKKyAgICAgICAvKiBwb2ludGVyIHRvIHRoZSAxc3QgZXh0aGRyICovCisgICAgICAgcHRyID0gc2l6ZW9mKHN0cnVjdCBpcHY2aGRyKTsKKyAgICAgICAvKiBhdmFpbGFibGUgbGVuZ3RoICovCisgICAgICAgbGVuID0gc2tiLT5sZW4gLSBwdHI7CisgICAgICAgdGVtcCA9IDA7CisKKyAgICAgICAgd2hpbGUgKGlwNnRfZXh0X2hkcihuZXh0aGRyKSkgeworICAgICAgICAgICAgICAgc3RydWN0IGlwdjZfb3B0X2hkciBfaGRyLCAqaHA7CisKKyAgICAgICAgICAgICAgREVCVUdQKCJpcHY2X3J0IGhlYWRlciBpdGVyYXRpb24gXG4iKTsKKworICAgICAgICAgICAgICAvKiBJcyB0aGVyZSBlbm91Z2ggc3BhY2UgZm9yIHRoZSBuZXh0IGV4dCBoZWFkZXI/ICovCisgICAgICAgICAgICAgICAgaWYgKGxlbiA8IChpbnQpc2l6ZW9mKHN0cnVjdCBpcHY2X29wdF9oZHIpKQorICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIDA7CisgICAgICAgICAgICAgIC8qIE5vIG1vcmUgZXh0aGRyIC0+IGV2YWx1YXRlICovCisgICAgICAgICAgICAgICAgaWYgKG5leHRoZHIgPT0gTkVYVEhEUl9OT05FKSB7CisgICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAvKiBFU1AgLT4gZXZhbHVhdGUgKi8KKyAgICAgICAgICAgICAgICBpZiAobmV4dGhkciA9PSBORVhUSERSX0VTUCkgeworICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgIH0KKworCSAgICAgIGhwID0gc2tiX2hlYWRlcl9wb2ludGVyKHNrYiwgcHRyLCBzaXplb2YoX2hkciksICZfaGRyKTsKKwkgICAgICBCVUdfT04oaHAgPT0gTlVMTCk7CisKKyAgICAgICAgICAgICAgLyogQ2FsY3VsYXRlIHRoZSBoZWFkZXIgbGVuZ3RoICovCisgICAgICAgICAgICAgICAgaWYgKG5leHRoZHIgPT0gTkVYVEhEUl9GUkFHTUVOVCkgeworICAgICAgICAgICAgICAgICAgICAgICAgaGRybGVuID0gODsKKyAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKG5leHRoZHIgPT0gTkVYVEhEUl9BVVRIKQorICAgICAgICAgICAgICAgICAgICAgICAgaGRybGVuID0gKGhwLT5oZHJsZW4rMik8PDI7CisgICAgICAgICAgICAgICAgZWxzZQorICAgICAgICAgICAgICAgICAgICAgICAgaGRybGVuID0gaXB2Nl9vcHRsZW4oaHApOworCisgICAgICAgICAgICAgIC8qIFJPVVRJTkcgLT4gZXZhbHVhdGUgKi8KKyAgICAgICAgICAgICAgICBpZiAobmV4dGhkciA9PSBORVhUSERSX1JPVVRJTkcpIHsKKyAgICAgICAgICAgICAgICAgICAgIHRlbXAgfD0gTUFTS19ST1VUSU5HOworICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgIH0KKworCisgICAgICAgICAgICAgIC8qIHNldCB0aGUgZmxhZyAqLworICAgICAgICAgICAgICBzd2l0Y2ggKG5leHRoZHIpeworICAgICAgICAgICAgICAgICAgICAgY2FzZSBORVhUSERSX0hPUDoKKyAgICAgICAgICAgICAgICAgICAgIGNhc2UgTkVYVEhEUl9ST1VUSU5HOgorICAgICAgICAgICAgICAgICAgICAgY2FzZSBORVhUSERSX0ZSQUdNRU5UOgorICAgICAgICAgICAgICAgICAgICAgY2FzZSBORVhUSERSX0FVVEg6CisgICAgICAgICAgICAgICAgICAgICBjYXNlIE5FWFRIRFJfREVTVDoKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgREVCVUdQKCJpcHY2X3J0IG1hdGNoOiB1bmtub3duIG5leHRoZWFkZXIgJXVcbiIsbmV4dGhkcik7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIDA7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgIH0KKworICAgICAgICAgICAgICAgIG5leHRoZHIgPSBocC0+bmV4dGhkcjsKKyAgICAgICAgICAgICAgICBsZW4gLT0gaGRybGVuOworICAgICAgICAgICAgICAgIHB0ciArPSBoZHJsZW47CisJCWlmICggcHRyID4gc2tiLT5sZW4gKSB7CisJCQlERUJVR1AoImlwdjZfcnQ6IG5ldyBwb2ludGVyIGlzIHRvbyBsYXJnZSEgXG4iKTsKKwkJCWJyZWFrOworCQl9CisgICAgICAgIH0KKworICAgICAgIC8qIFJPVVRJTkcgaGVhZGVyIG5vdCBmb3VuZCAqLworICAgICAgIGlmICggdGVtcCAhPSBNQVNLX1JPVVRJTkcgKSByZXR1cm4gMDsKKworICAgICAgIGlmIChsZW4gPCAoaW50KXNpemVvZihzdHJ1Y3QgaXB2Nl9ydF9oZHIpKXsKKwkgICAgICAgKmhvdGRyb3AgPSAxOworICAgICAgIAkJcmV0dXJuIDA7CisgICAgICAgfQorCisgICAgICAgaWYgKGxlbiA8IGhkcmxlbil7CisJICAgICAgIC8qIFBja2V0IHNtYWxsZXIgdGhhbiBpdHMgbGVuZ3RoIGZpZWxkICovCisgICAgICAgCQlyZXR1cm4gMDsKKyAgICAgICB9CisKKyAgICAgICByaCA9IHNrYl9oZWFkZXJfcG9pbnRlcihza2IsIHB0ciwgc2l6ZW9mKF9yb3V0ZSksICZfcm91dGUpOworICAgICAgIEJVR19PTihyaCA9PSBOVUxMKTsKKworICAgICAgIERFQlVHUCgiSVB2NiBSVCBMRU4gJXUgJXUgIiwgaGRybGVuLCByaC0+aGRybGVuKTsKKyAgICAgICBERUJVR1AoIlRZUEUgJTA0WCAiLCByaC0+dHlwZSk7CisgICAgICAgREVCVUdQKCJTR1NfTEVGVCAldSAlMDJYXG4iLCByaC0+c2VnbWVudHNfbGVmdCwgcmgtPnNlZ21lbnRzX2xlZnQpOworCisgICAgICAgREVCVUdQKCJJUHY2IFJUIHNlZ3NsZWZ0ICUwMlggIiwKKyAgICAgICAJCShzZWdzbGVmdF9tYXRjaChydGluZm8tPnNlZ3NsZWZ0WzBdLCBydGluZm8tPnNlZ3NsZWZ0WzFdLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgcmgtPnNlZ21lbnRzX2xlZnQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAhIShydGluZm8tPmludmZsYWdzICYgSVA2VF9SVF9JTlZfU0dTKSkpKTsKKyAgICAgICBERUJVR1AoInR5cGUgJTAyWCAlMDJYICUwMlggIiwKKyAgICAgICAJCXJ0aW5mby0+cnRfdHlwZSwgcmgtPnR5cGUsIAorICAgICAgIAkJKCEocnRpbmZvLT5mbGFncyAmIElQNlRfUlRfVFlQKSB8fAorICAgICAgICAgICAgICAgICAgICAgICAgICAgKChydGluZm8tPnJ0X3R5cGUgPT0gcmgtPnR5cGUpIF4KKyAgICAgICAgICAgICAgICAgICAgICAgICAgICEhKHJ0aW5mby0+aW52ZmxhZ3MgJiBJUDZUX1JUX0lOVl9UWVApKSkpOworICAgICAgIERFQlVHUCgibGVuICUwMlggJTA0WCAlMDJYICIsCisgICAgICAgCQlydGluZm8tPmhkcmxlbiwgaGRybGVuLAorICAgICAgIAkJKCEocnRpbmZvLT5mbGFncyAmIElQNlRfUlRfTEVOKSB8fAorICAgICAgICAgICAgICAgICAgICAgICAgICAgKChydGluZm8tPmhkcmxlbiA9PSBoZHJsZW4pIF4KKyAgICAgICAgICAgICAgICAgICAgICAgICAgICEhKHJ0aW5mby0+aW52ZmxhZ3MgJiBJUDZUX1JUX0lOVl9MRU4pKSkpOworICAgICAgIERFQlVHUCgicmVzICUwMlggJTAyWCAlMDJYICIsIAorICAgICAgIAkJKHJ0aW5mby0+ZmxhZ3MgJiBJUDZUX1JUX1JFUyksICgoc3RydWN0IHJ0MF9oZHIgKilyaCktPmJpdG1hcCwKKyAgICAgICAJCSEoKHJ0aW5mby0+ZmxhZ3MgJiBJUDZUX1JUX1JFUykgJiYgKCgoc3RydWN0IHJ0MF9oZHIgKilyaCktPmJpdG1hcCkpKTsKKworICAgICAgIHJldCA9IChyaCAhPSBOVUxMKQorICAgICAgIAkJJiYKKyAgICAgICAJCShzZWdzbGVmdF9tYXRjaChydGluZm8tPnNlZ3NsZWZ0WzBdLCBydGluZm8tPnNlZ3NsZWZ0WzFdLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgcmgtPnNlZ21lbnRzX2xlZnQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAhIShydGluZm8tPmludmZsYWdzICYgSVA2VF9SVF9JTlZfU0dTKSkpCisJCSYmCisJICAgICAgCSghK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pcDZ0X3J0OiBtYXRjaHNpemUgJXUgIT0gJXVcbiIsCisgICAgICAgICAgICAgICAgICAgICAgbWF0Y2hpbmZvc2l6ZSwgSVA2VF9BTElHTihzaXplb2Yoc3RydWN0IGlwNnRfcnQpKSk7CisgICAgICAgICAgICAgIHJldHVybiAwOworICAgICAgIH0KKyAgICAgICBpZiAocnRpbmZvLT5pbnZmbGFncyAmIH5JUDZUX1JUX0lOVl9NQVNLKSB7CisgICAgICAgICAgICAgIERFQlVHUCgiaXA2dF9ydDogdW5rbm93biBmbGFncyAlWFxuIiwKKyAgICAgICAgICAgICAgICAgICAgICBydGluZm8tPmludmZsYWdzKTsKKyAgICAgICAgICAgICAgcmV0dXJuIDA7CisgICAgICAgfQorICAgICAgIGlmICggKHJ0aW5mby0+ZmxhZ3MgJiAoSVA2VF9SVF9SRVN8SVA2VF9SVF9GU1RfTUFTSykpICYmIAorCQkgICAgICAgKCEocnRpbmZvLT5mbGFncyAmIElQNlRfUlRfVFlQKSB8fCAKKwkJICAgICAgIChydGluZm8tPnJ0X3R5cGUgIT0gMCkgfHwgCisJCSAgICAgICAocnRpbmZvLT5pbnZmbGFncyAmIElQNlRfUlRfSU5WX1RZUCkpICkgeworCSAgICAgIERFQlVHUCgiYC0tcnQtdHlwZSAwJyByZXF1aXJlZCBiZWZvcmUgYC0tcnQtMC0qJyIpOworICAgICAgICAgICAgICByZXR1cm4gMDsKKyAgICAgICB9CisKKyAgICAgICByZXR1cm4gMTsKK30KKworc3RhdGljIHN0cnVjdCBpcDZ0X21hdGNoIHJ0X21hdGNoID0geworCS5uYW1lCQk9ICJydCIsCisJLm1hdGNoCQk9ICZtYXRjaCwKKwkuY2hlY2tlbnRyeQk9ICZjaGVja2VudHJ5LAorCS5tZQkJPSBUSElTX01PRFVMRSwKK307CisKK3N0YXRpYyBpbnQgX19pbml0IGluaXQodm9pZCkKK3sKKyAgICAgICByZXR1cm4gaXA2dF9yZWdpc3Rlcl9tYXRjaCgmcnRfbWF0Y2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CisKKwlkZWZhdWx0OgorCQlyZXR1cm4gLUVOT1BST1RPT1BUOworCX0KKworCWxlbiA9IG1pbl90KHVuc2lnbmVkIGludCwgc2l6ZW9mKGludCksIGxlbik7CisKKwlpZiAocHV0X3VzZXIobGVuLCBvcHRsZW4pKQorCQlyZXR1cm4gLUVGQVVMVDsKKwlpZiAoY29weV90b191c2VyKG9wdHZhbCwmdmFsLGxlbikpCisJCXJldHVybiAtRUZBVUxUOworCXJldHVybiAwOworfQorCitzdGF0aWMgaW50IHJhd3Y2X2lvY3RsKHN0cnVjdCBzb2NrICpzaywgaW50IGNtZCwgdW5zaWduZWQgbG9uZyBhcmcpCit7CisJc3dpdGNoKGNtZCkgeworCQljYXNlIFNJT0NPVVRROgorCQl7CisJCQlpbnQgYW1vdW50ID0gYXRvbWljX3JlYWQoJnNrLT5za193bWVtX2FsbG9jKTsKKwkJCXJldHVybiBwdXRfdXNlcihhbW91bnQsIChpbnQgX191c2VyICopYXJnKTsKKwkJfQorCQljYXNlIFNJT0NJTlE6CisJCXsKKwkJCXN0cnVjdCBza19idWZmICpza2I7CisJCQlpbnQgYW1vdW50ID0gMDsKKworCQkJc3Bpbl9sb2NrX2lycSgmc2stPnNrX3JlY2VpdmVfcXVldWUubG9jayk7CisJCQlza2IgPSBza2JfcGVlaygmc2stPnNrX3JlY2VpdmVfcXVldWUpOworCQkJaWYgKHNrYiAhPSBOVUxMKQorCQkJCWFtb3VudCA9IHNrYi0+dGFpbCAtIHNrYi0+aC5yYXc7CisJCQlzcGluX3VubG9ja19pcnEoJnNrLT5za19yZWNlaXZlX3F1ZXVlLmxvY2spOworCQkJcmV0dXJuIHB1dF91c2VyKGFtb3VudCwgKGludCBfX3VzZXIgKilhcmcpOworCQl9CisKKwkJZGVmYXVsdDoKKwkJCXJldHVybiAtRU5PSU9DVExDTUQ7CisJfQorfQorCitzdGF0aWMgdm9pZCByYXd2Nl9jbG9zZShzdHJ1Y3Qgc29jayAqc2ssIGxvbmcgdGltZW91dC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AgID0gaXB4X3NlcV9pbnRlcmZhY2Vfb3BlbiwKKwkucmVhZCAgICAgICAgICAgPSBzZXFfcmVhZCwKKwkubGxzZWVrICAgICAgICAgPSBzZXFfbHNlZWssCisJLnJlbGVhc2UgICAgICAgID0gc2VxX3JlbGVhc2UsCit9OworCitzdGF0aWMgc3RydWN0IGZpbGVfb3BlcmF0aW9ucyBpcHhfc2VxX3JvdXRlX2ZvcHMgPSB7CisJLm93bmVyCQk9IFRISVNfTU9EVUxFLAorCS5vcGVuICAgICAgICAgICA9IGlweF9zZXFfcm91dGVfb3BlbiwKKwkucmVhZCAgICAgICAgICAgPSBzZXFfcmVhZCwKKwkubGxzZWVrICAgICAgICAgPSBzZXFfbHNlZWssCisJLnJlbGVhc2UgICAgICAgID0gc2VxX3JlbGVhc2UsCit9OworCitzdGF0aWMgc3RydWN0IGZpbGVfb3BlcmF0aW9ucyBpcHhfc2VxX3NvY2tldF9mb3BzID0geworCS5vd25lcgkJPSBUSElTX01PRFVMRSwKKwkub3BlbiAgICAgICAgICAgPSBpcHhfc2VxX3NvY2tldF9vcGVuLAorCS5yZWFkICAgICAgICAgICA9IHNlcV9yZWFkLAorCS5sbHNlZWsgICAgICAgICA9IHNlcV9sc2VlaywKKwkucmVsZWFzZSAgICAgICAgPSBzZXFfcmVsZWFzZSwKK307CisKK3N0YXRpYyBzdHJ1Y3QgcHJvY19kaXJfZW50cnkgKmlweF9wcm9jX2RpcjsKKworaW50IF9faW5pdCBpcHhfcHJvY19pbml0KHZvaWQpCit7CisJc3RydWN0IHByb2NfZGlyX2VudHJ5ICpwOworCWludCByYyA9IC1FTk9NRU07CisgICAgICAgCisJaXB4X3Byb2NfZGlyID0gcHJvY19ta2RpcigiaXB4IiwgcHJvY19uZXQpOworCisJaWYgKCFpcHhfcHJvY19kaXIpCisJCWdvdG8gb3V0OworCXAgPSBjcmVhdGVfcHJvY19lbnRyeSgiaW50ZXJmYWNlIiwgU19JUlVHTywgaXB4X3Byb2NfZGlyKTs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aXRmX2RlbXV4X3NvY2tldChzdHJ1Y3QgaXB4X2ludGVyZmFjZSAqaW50cmZjLAorCQkJICAgICAgIHN0cnVjdCBza19idWZmICpza2IsIGludCBjb3B5KTsKK2V4dGVybiBpbnQgaXB4aXRmX2RlbXV4X3NvY2tldChzdHJ1Y3QgaXB4X2ludGVyZmFjZSAqaW50cmZjLAorCQkJICAgICAgIHN0cnVjdCBza19idWZmICpza2IsIGludCBjb3B5KTsKK2V4dGVybiBpbnQgaXB4aXRmX3NlbmQoc3RydWN0IGlweF9pbnRlcmZhY2UgKmludHJmYywgc3RydWN0IHNrX2J1ZmYgKnNrYiwKKwkJICAgICAgIGNoYXIgKm5vZGUpOworZXh0ZXJuIHN0cnVjdCBpcHhfaW50ZXJmYWNlICppcHhpdGZfZmluZF91c2luZ19uZXQoX191MzIgbmV0KTsKKworc3RydWN0IGlweF9yb3V0ZSAqaXB4cnRyX2xvb2t1cChfX3UzMiBuZXQpCit7CisJc3RydWN0IGlweF9yb3V0ZSAqcjsKKworCXJlYWRfbG9ja19iaCgmaXB4X3JvdXRlc19sb2NrKTsKKwlsaXN0X2Zvcl9lYWNoX2VudHJ5KHIsICZpcHhfcm91dGVzLCBub2RlKQorCQlpZiAoci0+aXJfbmV0ID09IG5ldCkgeworCQkJaXB4cnRyX2hvbGQocik7CisJCQlnb3RvIHVubG9jazsKKwkJfQorCXIgPSBOVUxMOwordW5sb2NrOgorCXJlYWRfdW5sb2NrX2JoKCZpcHhfcm91dGVzX2xvY2spOworCXJldHVybiByOworfQorCisvKgorICogQ2FsbGVyIG11c3QgaG9sZCBhIHJlZmVyZW5jZSB0byBpbnRyZmMKKyAqLworaW50IGlweHJ0cl9hZGRfcm91dGUoX191MzIgbmV0d29yaywgc3RydWN0IGlweF9pbnRlcmZhY2UgKmludHJmYywKKwkJICAgICB1bnNpZ25lZCBjaGFyICpub2RlKQoreworCXN0cnVjdCBpcHhfcm91dGUgKnJ0OworCWludCByYzsKKworCS8qIEdldCBhIHJ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TEzMDcgVVNBCisgKgorICogICAgIExpbnV4LUlyREEgbm93IHN1cHBvcnRzIGZvdXIgZGlmZmVyZW50IHR5cGVzIG9mIElyREEgc29ja2V0czoKKyAqCisgKiAgICAgbyBTT0NLX1NUUkVBTTogICAgVGlueVRQIGNvbm5lY3Rpb25zIHdpdGggU0FSIGRpc2FibGVkLiBUaGUKKyAqICAgICAgICAgICAgICAgICAgICAgICBtYXggU0RVIHNpemUgaXMgMCBmb3IgY29ubi4gb2YgdGhpcyB0eXBlCisgKiAgICAgbyBTT0NLX1NFUVBBQ0tFVDogVGlueVRQIGNvbm5lY3Rpb25zIHdpdGggU0FSIGVuYWJsZWQuIFRUUCBtYXkKKyAqICAgICAgICAgICAgICAgICAgICAgICBmcmFnbWVudCB0aGUgbWVzc2FnZXMsIGJ1dCB3aWxsIHByZXNlcnZlCisgKiAgICAgICAgICAgICAgICAgICAgICAgdGhlIG1lc3NhZ2UgYm91bmRhcmllcworICogICAgIG8gU09DS19ER1JBTTogICAgIElSREFQUk9UT19VTklUREFUQTogVGlueVRQIGNvbm5lY3Rpb25zIHdpdGggVW5pdGRhdGEKKyAqICAgICAgICAgICAgICAgICAgICAgICAodW5yZWxpYWJsZSkgdHJhbnNmZXJzCisgKiAgICAgICAgICAgICAgICAgICAgICAgSVJEQVBST1RPX1VMVFJBOiBDb25uZWN0aW9ubGVzcyBhbmQgdW5yZWxpYWJsZSBkYXRhCisgKgorICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworCisjaW5jbHVkZSA8bGludXgvY29uZmlnLmg+CisjaW5jbHVkZSA8bGludXgvbW9kdWxlLmg+CisjaW5jbHVkZSA8bGludXgvdHlwZXMuaD4KKyNpbmNsdWRlIDxsaW51eC9zb2NrZXQuaD4KKyNpbmNsdWRlIDxsaW51eC9zb2NraW9zLmg+CisjaW5jbHVkZSA8bGludXgvaW5pdC5oPgorI2luY2x1ZGUgPGxpbn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ZWxmID0gKHN0cnVjdCBpcmNvbW1fY2IgKikgaGFzaGJpbl9sb2NrX2ZpbmQoaXJjb21tLCBsaW5lLCBOVUxMKTsKKyAgICAgICAgaWYgKCFzZWxmKSB7CisJCUlSREFfREVCVUcoMiwgIiVzKCksIGRpZG4ndCBmaW5kIG15c2VsZlxuIiwgX19GVU5DVElPTl9fICk7CisgICAgICAgICAgICAgICAgcmV0dXJuOworCX0KKworICAgICAgICBJUkRBX0FTU0VSVChzZWxmICE9IE5VTEwsIHJldHVybjspOworCUlSREFfQVNTRVJUKHNlbGYtPm1hZ2ljID09IElSQ09NTV9NQUdJQywgcmV0dXJuOyk7CisKKwlzZWxmLT5wa3RfY291bnQtLTsKKworICAgICAgICBpZiAoKHNlbGYtPnBrdF9jb3VudCA8IDIpICYmIChzZWxmLT5mbG93X3N0YXR1cyA9PSBGTE9XX1NUT1ApKSB7CisgICAgICAgICAgICAgICAgSVJEQV9ERUJVRygyLCAiJXMoKSwgYXNraW5nIFRUWSB0byBzdGFydCBhZ2FpbiFcbiIsIF9fRlVOQ1RJT05fXyApOworICAgICAgICAgICAgICAgIHNlbGYtPmZsb3dfc3RhdHVzID0gRkxPV19TVEFSVDsKKyAgICAgICAgICAgICAgICBpZiAoc2VsZi0+bm90aWZ5LmZsb3dfaW5kaWNhdGlvbikKKyAgICAgICAgICAgICAgICAgICAgICAgIHNlbGYtPm5vdGlmeS5mbG93X2luZGljYXRpb24oc2VsZi0+bm90aWZ5Lmluc3RhbmNlLCAKKwkJCQkJCSAgICAgc2VsZiwgRkxPV19TVEFSVCk7CisgICAgICAgIH0KK30KKyAgICAKKy8qCisgKiBGdW5jdGlvbiBpcmNvbW1fbG1wX2RhdGFfcmVxdWVzdCAoc2VsZiwgdXNlcmRhdGEpCisgKgorICogICAgU2VuZCBkYXRhIGZyYW1lIHRvIHBlZXIgZGV2aWNlCisgKgorICovCitzdGF0aWMgaW50IGlyY29tbV9sbXBfZGF0YV9yZXF1ZXN0KHN0cnVjdCB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orICogRnVuY3Rpb24gaXJjb21tX2xtcF9jb25uZWN0X2NvbmZpcm0gKGluc3RhbmNlLCBzYXAsIHFvcywgbWF4X3NkdV9zaXplLCAKKyAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWF4X2hlYWRlcl9zaXplLCBza2IpCisgKgorICogICAgQ29ubmVjdGlvbiBoYXMgYmVlbiBjb25maXJtZWQgYnkgcGVlciBkZXZpY2UKKyAqCisgKi8KK3N0YXRpYyB2b2lkIGlyY29tbV9sbXBfY29ubmVjdF9jb25maXJtKHZvaWQgKmluc3RhbmNlLCB2b2lkICpzYXAsCisJCQkJICAgICAgIHN0cnVjdCBxb3NfaW5mbyAqcW9zLCAKKwkJCQkgICAgICAgX191MzIgbWF4X3NlZ19zaXplLCAKKwkJCQkgICAgICAgX191OCBtYXhfaGVhZGVyX3NpemUsCisJCQkJICAgICAgIHN0cnVjdCBza19idWZmICpza2IpCit7CisJc3RydWN0IGlyY29tbV9jYiAqc2VsZiA9IChzdHJ1Y3QgaXJjb21tX2NiICopIGluc3RhbmNlOworCXN0cnVjdCBpcmNvbW1faW5mbyBpbmZvOworCisJSVJEQV9ERUJVRygwLCAiJXMoKVxuIiwgX19GVU5DVElPTl9fICk7CisKKwlJUkRBX0FTU0VSVChzZWxmICE9IE5VTEwsIHJldHVybjspOworCUlSREFfQVNTRVJUKHNlbGYtPm1hZ2ljID09IElSQ09NTV9NQUdJQywgcmV0dXJuOyk7CisJSVJEQV9BU1NFUlQoc2tiICE9IE5VTEwsIHJldHVybjspOworCUlSREFfQVNTRVJUKHFvcyAhPSBOVUxMLCByZXR1cm47KTsKKworCWluZm8ubWF4X2RhdGFfc2l6ZSA9IG1heF9zZWdfc2l6ZTsKKwlpbmZvLm1heF9oZWFkZXJfc2l6ZSA9IG1heF9oZWFkZXJfc2l6ZTsKKwlpbmZvLnFvcyA9IHFvczsKKworCWlyY29tbV9kb19ldmVudChzZWxmLCBJUkNPTU1fTE1QX0NPTk5FQ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TAwNjQ0CmluZGV4IDAwMDAwMDAuLjVkMWU2MTEKLS0tIC9kZXYvbnVsbAorKysgYi9uZXQvaXJkYS9pcmNvbW0vaXJjb21tX3R0eS5jCkBAIC0wLDAgKzEsMTQwNSBAQAorLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorICogICAgICAgICAgICAgICAgCisgKiBGaWxlbmFtZTogICAgICBpcmNvbW1fdHR5LmMKKyAqIFZlcnNpb246ICAgICAgIDEuMAorICogRGVzY3JpcHRpb246ICAgSXJDT01NIHNlcmlhbCBUVFkgZHJpdmVyCisgKiBTdGF0dXM6ICAgICAgICBFeHBlcmltZW50YWwuCisgKiBBdXRob3I6ICAgICAgICBEYWcgQnJhdHRsaSA8ZGFnYkBjcy51aXQubm8+CisgKiBDcmVhdGVkIGF0OiAgICBTdW4gSnVuICA2IDIxOjAwOjU2IDE5OTkKKyAqIE1vZGlmaWVkIGF0OiAgIFdlZCBGZWIgMjMgMDA6MDk6MDIgMjAwMAorICogTW9kaWZpZWQgYnk6ICAgRGFnIEJyYXR0bGkgPGRhZ2JAY3MudWl0Lm5vPgorICogU291cmNlczogICAgICAgc2VyaWFsLmMgYW5kIHByZXZpb3VzIElyQ09NTSB3b3JrIGJ5IFRha2FoaWRlIEhpZ3VjaGkKKyAqIAorICogICAgIENvcHlyaWdodCAoYykgMTk5OS0yMDAwIERhZyBCcmF0dGxpLCBBbGwgUmlnaHRzIFJlc2VydmVkLgorICogICAgIENvcHlyaWdodCAoYykgMjAwMC0yMDAzIEplYW4gVG91cnJpbGhlcyA8anRAaHBsLmhwLmNvbT4KKyAqICAgICAKKyAqICAgICBUaGlzIHByb2dyYW0gaXMgZnJlZSBzb2Z0d2FyZTsgeW91IGNhbiByZWRpc3RyaWJ1dGUgaXQgYW5kL29yIAorICogICAgIG1vZGlmeSBpdCB1bmRlciB0aGUgdGVybXMgb2YgdGhlIEdOVSBHZW5lcmFs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0YXRlXSk7CisKKwlyZXQgKz0gc3ByaW50ZihidWYrcmV0LCAiU2VydmljZSB0eXBlOiAiKTsKKwlpZiAoc2VsZi0+c2VydmljZV90eXBlICYgSVJDT01NXzlfV0lSRSkKKwkJcmV0ICs9IHNwcmludGYoYnVmK3JldCwgIjlfV0lSRSIpOworCWVsc2UgaWYgKHNlbGYtPnNlcnZpY2VfdHlwZSAmIElSQ09NTV8zX1dJUkUpCisJCXJldCArPSBzcHJpbnRmKGJ1ZityZXQsICIzX1dJUkUiKTsKKwllbHNlIGlmIChzZWxmLT5zZXJ2aWNlX3R5cGUgJiBJUkNPTU1fM19XSVJFX1JBVykKKwkJcmV0ICs9IHNwcmludGYoYnVmK3JldCwgIjNfV0lSRV9SQVciKTsKKwllbHNlCisJCXJldCArPSBzcHJpbnRmKGJ1ZityZXQsICJObyBjb21tb24gc2VydmljZSB0eXBlIVxuIik7CisgICAgICAgIHJldCArPSBzcHJpbnRmKGJ1ZityZXQsICJcbiIpOworCisJcmV0ICs9IHNwcmludGYoYnVmK3JldCwgIlBvcnQgbmFtZTogJXNcbiIsIHNlbGYtPnNldHRpbmdzLnBvcnRfbmFtZSk7CisKKwlyZXQgKz0gc3ByaW50ZihidWYrcmV0LCAiRFRFIHN0YXR1czogIik7CQorICAgICAgICBpZiAoc2VsZi0+c2V0dGluZ3MuZHRlICYgSVJDT01NX1JUUykKKyAgICAgICAgICAgICAgICByZXQgKz0gc3ByaW50ZihidWYrcmV0LCAiUlRTfCIpOworICAgICAgICBpZiAoc2VsZi0+c2V0dGluZ3MuZHRlICYgSVJDT01NX0RUUikKKyAgICAgICAgICAgICAgICByZXQgKz0gc3ByaW50ZihidWYrcmV0LCAiRFRSfCIpOworCWlmIChzZWxmLT5zZXR0aW5ncy5kdGUpCisJCXJldC0tOyAvKiByZW1vdmUgdGhlIGxhc3QgfCAqLworICAgICAgICByZXQgKz0gc3ByaW50ZihidWYrcmV0LCAiXG4iKTsKKworCXJldCArPSBzcHJpbnRmKG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bV90dHlfY2IgKikgaGFzaGJpbl9nZXRfZmlyc3QoaXJjb21tX3R0eSk7CisJd2hpbGUgKChzZWxmICE9IE5VTEwpICYmIChjb3VudCA8IDQwMDApKSB7CisJCWlmIChzZWxmLT5tYWdpYyAhPSBJUkNPTU1fVFRZX01BR0lDKQorCQkJYnJlYWs7CisKKyAgICAgICAgICAgICAgICBsID0gaXJjb21tX3R0eV9saW5lX2luZm8oc2VsZiwgYnVmICsgY291bnQpOworICAgICAgICAgICAgICAgIGNvdW50ICs9IGw7CisgICAgICAgICAgICAgICAgaWYgKGNvdW50K2JlZ2luID4gb2Zmc2V0K2xlbikKKyAgICAgICAgICAgICAgICAgICAgICAgIGdvdG8gZG9uZTsKKyAgICAgICAgICAgICAgICBpZiAoY291bnQrYmVnaW4gPCBvZmZzZXQpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIGJlZ2luICs9IGNvdW50OworICAgICAgICAgICAgICAgICAgICAgICAgY291bnQgPSAwOworICAgICAgICAgICAgICAgIH0KKwkJCQkKKwkJc2VsZiA9IChzdHJ1Y3QgaXJjb21tX3R0eV9jYiAqKSBoYXNoYmluX2dldF9uZXh0KGlyY29tbV90dHkpOworICAgICAgICB9CisgICAgICAgICplb2YgPSAxOworZG9uZToKKwlzcGluX3VubG9ja19pcnFyZXN0b3JlKCZpcmNvbW1fdHR5LT5oYl9zcGlubG9jaywgZmxhZ3MpOworCisgICAgICAgIGlmIChvZmZzZXQgPj0gY291bnQrYmVnaW4pCisgICAgICAgICAgICAgICAgcmV0dXJuIDA7CisgICAgICAgICpzdGFydCA9IGJ1ZiArIChvZmZzZXQtYmVnaW4pOworICAgICAgICByZXR1cm4gKChsZW4gPCBiZWdpbitjb3VudC1vZmZzZXQpID8gbGVuIDogYmVnaW4rY291bnQtb2Zmc2V0KTsKK30KKyNlbmRpZiAvKiBDT05GSUdfUFJPQ19GUyAqLworCitNT0RVTEVfQVVUSE9SKCJEYWcgQnJhdHRsaSA8ZGFnYkBjcy51aX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PSB7IElBU19NSVNTSU5HLCAwLCAwLCAwLCB7MH19OworCisvKgorICogRnVuY3Rpb24gc3RybmR1cCAoc3RyLCBtYXgpCisgKgorICogICAgTXkgb3duIGtlcm5lbCB2ZXJzaW9uIG9mIHN0cm5kdXAhCisgKgorICogRmFzdGVyLCBjaGVjayBib3VuZGFyeS4uLiBKZWFuIElJCisgKi8KK3N0YXRpYyBjaGFyICpzdHJuZHVwKGNoYXIgKnN0ciwgaW50IG1heCkKK3sKKwljaGFyICpuZXdfc3RyOworCWludCBsZW47CisKKwkvKiBDaGVjayBzdHJpbmcgKi8KKwlpZiAoc3RyID09IE5VTEwpCisJCXJldHVybiBOVUxMOworCS8qIENoZWNrIGxlbmd0aCwgdHJ1bmNhdGUgKi8KKwlsZW4gPSBzdHJsZW4oc3RyKTsKKwlpZihsZW4gPiBtYXgpCisJCWxlbiA9IG1heDsKKworCS8qIEFsbG9jYXRlIG5ldyBzdHJpbmcgKi8KKyAgICAgICAgbmV3X3N0ciA9IGttYWxsb2MobGVuICsgMSwgR0ZQX0FUT01JQyk7CisgICAgICAgIGlmIChuZXdfc3RyID09IE5VTEwpIHsKKwkJSVJEQV9XQVJOSU5HKCIlczogVW5hYmxlIHRvIGttYWxsb2MhXG4iLCBfX0ZVTkNUSU9OX18pOworCQlyZXR1cm4gTlVMTDsKKwl9CisKKwkvKiBDb3B5IGFuZCB0cnVuY2F0ZSAqLworCW1lbWNweShuZXdfc3RyLCBzdHIsIGxlbik7CisJbmV3X3N0cltsZW5dID0gJ1wwJzsKKworCXJldHVybiBuZXdfc3RyOworfQorCisvKgorICogRnVuY3Rpb24gaWFzX25ld19vYmplY3QgKG5hbWUsIGlkKQorICoKKyAqICAgIENyZWF0ZSBhIG5ldyBJQVMgb2JqZWN0CisgKgorICovCitzdHJ1Y3QgaWFzX29iamVjdCAqaXJpYXNfbmV3X29iamVjdCggY2hhciAqbmFtZSwgaW50IGlkKQoreworICAgICAgICBzdHJ1Y3QgaWFzX29iamVjdCA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SA8bmV0L2lyZGEvdGltZXIuaD4KKyNpbmNsdWRlIDxuZXQvaXJkYS9pcm1vZC5oPgorI2luY2x1ZGUgPG5ldC9pcmRhL2lyaWFwLmg+CisjaW5jbHVkZSA8bmV0L2lyZGEvaXJsbXAuaD4KKyNpbmNsdWRlIDxuZXQvaXJkYS9pcnR0cC5oPgorCisjaW5jbHVkZSA8bmV0L2lyZGEvaXJsYW5fY29tbW9uLmg+CisjaW5jbHVkZSA8bmV0L2lyZGEvaXJsYW5fY2xpZW50Lmg+CisjaW5jbHVkZSA8bmV0L2lyZGEvaXJsYW5fZXZlbnQuaD4KKworc3RhdGljIGludCBpcmxhbl9jbGllbnRfc3RhdGVfaWRsZSAoc3RydWN0IGlybGFuX2NiICpzZWxmLCBJUkxBTl9FVkVOVCBldmVudCwgCisJCQkJICAgIHN0cnVjdCBza19idWZmICpza2IpOworc3RhdGljIGludCBpcmxhbl9jbGllbnRfc3RhdGVfcXVlcnkoc3RydWN0IGlybGFuX2NiICpzZWxmLCBJUkxBTl9FVkVOVCBldmVudCwgCisJCQkJICAgIHN0cnVjdCBza19idWZmICpza2IpOworc3RhdGljIGludCBpcmxhbl9jbGllbnRfc3RhdGVfY29ubiAoc3RydWN0IGlybGFuX2NiICpzZWxmLCBJUkxBTl9FVkVOVCBldmVudCwgCisJCQkJICAgIHN0cnVjdCBza19idWZmICpza2IpOworc3RhdGljIGludCBpcmxhbl9jbGllbnRfc3RhdGVfaW5mbyAoc3RydWN0IGlybGFuX2NiICpzZWxmLCBJUkxBTl9FVkVOVCBldmVudCwgCisJCQkJICAgIHN0cnVjdCBza19idWZmICpza2IpOworc3RhdGljIGludCBpcmxhbl9jbGllbnRfc3RhdGVfbWVkaWEoc3RydWN0IGlybGFuX2NiICpzZWxmLCBJUkxBTl9FVkVOVCBldmVudCwgCisJCQkJICAgIHN0cnVjdCBza19idWZmICpza2IpOworc3RhdGljIGludCBpcmxhbl9jbGllbnRfc3RhdGVfb3BlbiAoc3RydWN0IGlybGFuX2NiICpzZWxmLCBJUkxBTl9FVkVOVCBldmVudCwgCisJCQkJICAgIHN0cnVjdCBza19idWZmICpza2IpOworc3RhdGljIGludCBpcmxhbl9jbGllbnRfc3RhdGVfd2FpdCAoc3RydWN0IGlybGFuX2NiICpzZWxmLCBJUkxBTl9FVkVOVCBldmVudCwgCisJCQkJICAgIHN0cnVjdCBza19idWZmICpza2IpOworc3RhdGljIGludCBpcmxhbl9jbGllbnRfc3RhdGVfYXJiICAoc3RydWN0IGlybGFuX2NiICpzZWxmLCBJUkxBTl9FVkVOVCBldmVudCwgCisJCQkJICAgIHN0cnVjdCBza19idWZmICpza2IpOworc3RhdGljIGludCBpcmxhbl9jbGllbnRfc3RhdGVfZGF0YSAoc3RydWN0IGlybGFuX2NiICpzZWxmLCBJUkxBTl9FVkVOVCBldmVudCwgCisJCQkJICAgIHN0cnVjdCBza19idWZmICpza2IpOworc3RhdGljIGludCBpcmxhbl9jbGllbnRfc3RhdGVfY2xvc2Uoc3RydWN0IGlybGFuX2NiICpzZWxmLCBJUkxBTl9FVkVOVCBldmVudCwgCisJCQkJICAgIHN0cnVjdCBza19idWZmICpza2IpOworc3RhdGljIGludCBpcmxhbl9jbGllbnRfc3RhdGVfc3luYyAoc3RydWN0IGlybGFuX2NiICpzZWxmLCBJUkxBTl9FVkVOVCBldmVudCwgCisJCQkJICAgIHN0cnVjdCBza19idWZmICpza2IpOworCitzdGF0aWMgaW50ICgqc3RhdGVbXSkoc3RydWN0IGlybGFuX2NiICosIElSTEFOX0VWRU5UIGV2ZW50LCBzdHJ1Y3Qgc2tfYnVmZiAqKSA9Cit7IAorCWlybGFuX2NsaWVudF9zdGF0ZV9pZGxlLAorCWlybGFuX2NsaWVudF9zdGF0ZV9xdWVyeSwKKwlpcmxhbl9jbGllbnRfc3RhdGVfY29ubiwKKwlpcmxhbl9jbGllbnRfc3RhdGVfaW5mbywKKwlpcmxhbl9jbGllbnRfc3RhdGVfbWVkaWEsCisJaXJsYW5fY2xpZ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Tl9JRExFKTsKKwkJYnJlYWs7CisJZGVmYXVsdDoKKwkJSVJEQV9ERUJVRygyLCAiJXMoKSwgVW5rbm93biBldmVudCAlZFxuIiwgX19GVU5DVElPTl9fICwgZXZlbnQpOworCQlicmVhazsKKwl9CisJaWYgKHNrYikKKwkJZGV2X2tmcmVlX3NrYihza2IpOworCQorCXJldHVybiAwOworfQorCisvKgorICogRnVuY3Rpb24gaXJsYW5fY2xpZW50X3N0YXRlX2Nsb3NlIChzZWxmLCBldmVudCwgc2tiLCBpbmZvKQorICoKKyAqICAgIAorICoKKyAqLworc3RhdGljIGludCBpcmxhbl9jbGllbnRfc3RhdGVfY2xvc2Uoc3RydWN0IGlybGFuX2NiICpzZWxmLCBJUkxBTl9FVkVOVCBldmVudCwgCisJCQkJICAgIHN0cnVjdCBza19idWZmICpza2IpIAoreworCUlSREFfREVCVUcoMiwgIiVzKClcbiIsIF9fRlVOQ1RJT05fXyApOworCisJaWYgKHNrYikKKwkJZGV2X2tmcmVlX3NrYihza2IpOworCisJcmV0dXJuIDA7Cit9CisKKy8qCisgKiBGdW5jdGlvbiBpcmxhbl9jbGllbnRfc3RhdGVfc3luYyAoc2VsZiwgZXZlbnQsIHNrYiwgaW5mbykKKyAqCisgKiAgICAKKyAqCisgKi8KK3N0YXRpYyBpbnQgaXJsYW5fY2xpZW50X3N0YXRlX3N5bmMoc3RydWN0IGlybGFuX2NiICpzZWxmLCBJUkxBTl9FVkVOVCBldmVudCwgCisJCQkJICAgc3RydWN0IHNrX2J1ZmYgKnNrYikgCit7CisJSVJEQV9ERUJVRygyLCAiJXMoKVxuIiwgX19GVU5DVElPTl9fICk7CisJCisJaWYgKHNrYikKKwkJZGV2X2tmcmVlX3NrYihza2IpOworCQorCXJldHVybiAwOworfQorCisKKworCisKKworCisKKworCisKKworCmRpZmYgLS1naXQgYS9uZXQvaXJkYS9pcmxhbi9pcmxhbl9jb21tb24uYyBiL25ldC9pcmRhL2lybGFuL2lybGFuX2NvbW1vbi5jC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pbiB0aGUgZ2l2ZW4gaGludCBiaXRzLiBUaGlzCisgKiAgICBmdW5jdGlvbiBhc3N1bWVzIHRoYXQgdGhlIGhpbnQgYml0cyBoYXZlIHRoZSBzaXplIG9mIHR3byBieXRlcyBvbmx5CisgKi8KK19fdTggKmlybG1wX2hpbnRfdG9fc2VydmljZShfX3U4ICpoaW50KQoreworCV9fdTggKnNlcnZpY2U7CisJaW50IGkgPSAwOworCisJLyoKKwkgKiBBbGxvY2F0ZSBhcnJheSB0byBzdG9yZSBzZXJ2aWNlcyBpbi4gMTYgZW50cmllcyBzaG91bGQgYmUgc2FmZQorCSAqIHNpbmNlIHdlIGN1cnJlbnRseSBvbmx5IHN1cHBvcnQgMiBoaW50IGJ5dGVzCisJICovCisJc2VydmljZSA9IGttYWxsb2MoMTYsIEdGUF9BVE9NSUMpOworCWlmICghc2VydmljZSkgeworCQlJUkRBX0RFQlVHKDEsICIlcygpLCBVbmFibGUgdG8ga21hbGxvYyFcbiIsIF9fRlVOQ1RJT05fXyk7CisJCXJldHVybiBOVUxMOworCX0KKworCWlmICghaGludFswXSkgeworCQlJUkRBX0RFQlVHKDEsICI8Tm9uZT5cbiIpOworCQlrZnJlZShzZXJ2aWNlKTsKKwkJcmV0dXJuIE5VTEw7CisJfQorCWlmIChoaW50WzBdICYgSElOVF9QTlApCisJCUlSREFfREVCVUcoMSwgIlBuUCBDb21wYXRpYmxlICIpOworCWlmIChoaW50WzBdICYgSElOVF9QREEpCisJCUlSREFfREVCVUcoMSwgIlBEQS9QYWxtdG9wICIpOworCWlmIChoaW50WzBdICYgSElOVF9DT01QVVRFUikKKwkJSVJEQV9ERUJVRygxLCAiQ29tcHV0ZXIgIik7CisJaWYgKGhpbnRbMF0gJiBISU5UX1BSSU5URVIpIHsKKwkJSVJEQV9ERUJVRygxLCAiUHJpbnRlciAiKTsKKwkJc2VydmljZVtpKytdID0gU19QUklOVEVSOworCX0KKwlpZiAoaGludFswXSAmIEhJTlRfTU9ERU0pCisJCUl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ZGljYXRpb24gKi8KKwkJZGVsX3RpbWVyKCAmc2VsZi0+d2F0Y2hkb2dfdGltZXIpOworCisJCWlybG1wX25leHRfbHNhcF9zdGF0ZShzZWxmLCBMU0FQX0RJU0NPTk5FQ1RFRCk7CisKKwkJcmVhc29uID0gaXJsbXBfY29udmVydF9sYXBfcmVhc29uKHNlbGYtPmxhcC0+cmVhc29uKTsKKworCQlpcmxtcF9kaXNjb25uZWN0X2luZGljYXRpb24oc2VsZiwgcmVhc29uLCBOVUxMKTsKKwkJYnJlYWs7CisJZGVmYXVsdDoKKwkJSVJEQV9ERUJVRygwLCAiJXMoKSwgVW5rbm93biBldmVudCAlcyBvbiBMU0FQICUjMDJ4XG4iLAorCQkJICAgX19GVU5DVElPTl9fLCBpcmxtcF9ldmVudFtldmVudF0sIHNlbGYtPnNsc2FwX3NlbCk7CisJCWJyZWFrOworCX0KKwlyZXR1cm4gcmV0OworfQpkaWZmIC0tZ2l0IGEvbmV0L2lyZGEvaXJsbXBfZnJhbWUuYyBiL25ldC9pcmRhL2lybG1wX2ZyYW1lLmMKbmV3IGZpbGUgbW9kZSAxMDA2NDQKaW5kZXggMDAwMDAwMC4uOTFjZDI2OAotLS0gL2Rldi9udWxsCisrKyBiL25ldC9pcmRhL2lybG1wX2ZyYW1lLmMKQEAgLTAsMCArMSw0OTEgQEAKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyAqICAgICAgICAgICAgICAgIAorICogRmlsZW5hbWU6ICAgICAgaXJsbXBfZnJhbWUuYworICogVmVyc2lvbjogICAgICAgMC45CisgKiBEZXNjcmlwdGlvbjogICBJckxNUCBmcmFtZSBpbXBsZW1lbnRhdGlvbgorICogU3RhdHVzOiAgICAgICAgRXhwZXJpbWVudGFsLgorICogQXV0aG9yOiAgICAgICAgRGFnIEJyYXR0bGkgPGRhZ2JAY3MudWl0Lm5vPgorICogQ3JlYXRlZCBhdDogICAg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DAsICIlcygpLCBmb3VuZCBubyBtYXRjaGluZyBMU0FQIVxuIiwgX19GVU5DVElPTl9fKTsKKwl9Cit9CisjZW5kaWYgLyogQ09ORklHX0lSREFfVUxUUkEgKi8KKworLyoKKyAqIEZ1bmN0aW9uIGlybG1wX2xpbmtfZGlzY29ubmVjdF9pbmRpY2F0aW9uIChyZWFzb24sIHVzZXJkYXRhKQorICoKKyAqICAgIElyTEFQIGhhcyBkaXNjb25uZWN0ZWQgCisgKgorICovCit2b2lkIGlybG1wX2xpbmtfZGlzY29ubmVjdF9pbmRpY2F0aW9uKHN0cnVjdCBsYXBfY2IgKmxhcCwgCisJCQkJICAgICAgc3RydWN0IGlybGFwX2NiICppcmxhcCwgCisJCQkJICAgICAgTEFQX1JFQVNPTiByZWFzb24sIAorCQkJCSAgICAgIHN0cnVjdCBza19idWZmICpza2IpCit7CisJSVJEQV9ERUJVRygyLCAiJXMoKVxuIiwgX19GVU5DVElPTl9fKTsKKworCUlSREFfQVNTRVJUKGxhcCAhPSBOVUxMLCByZXR1cm47KTsKKwlJUkRBX0FTU0VSVChsYXAtPm1hZ2ljID09IExNUF9MQVBfTUFHSUMsIHJldHVybjspOworCisJbGFwLT5yZWFzb24gPSByZWFzb247CisJbGFwLT5kYWRkciA9IERFVl9BRERSX0FOWTsKKworICAgICAgICAvKiBGSVhNRTogbXVzdCBkbyBzb21ldGhpbmcgd2l0aCB0aGUgc2tiIGlmIGFueSAqLworCQorCS8qCisJICogIEluZm9ybSBzdGF0aW9uIHN0YXRlIG1hY2hpbmUKKwkgKi8KKwlpcmxtcF9kb19sYXBfZXZlbnQobGFwLCBMTV9MQVBfRElTQ09OTkVDVF9JTkRJQ0FUSU9OLCBOVUxMKTsKK30KKworLyoKKyAqIEZ1bmN0aW9uIGlybG1wX2xpbmtfY29ubmVjdF9pbmRpY2F0aW9uIChxb3MpCisgKgorICogICAgSW5jb21pbmcgTEFQIGNvbm5lY3Rpb24hCisgKgorICovCit2b2lkIGlybG1wX2x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ocmV0LCBkYmcsIGFyZ3MuLi4pIFwKKwl7REVYSVQoZGJnLCAiOiAiIGFyZ3MpO1wKKwlyZXR1cm4gcmV0OyB9CisKKy8qIEV4aXQgYSBmdW5jdGlvbiBvbiBmYWlsZWQgY29uZGl0aW9uICovCisjZGVmaW5lIERBQk9SVChjb25kLCByZXQsIGRiZywgYXJncy4uLikgXAorCXtpZihjb25kKSB7XAorCQlERVJST1IoZGJnLCBhcmdzKTtcCisJCXJldHVybiByZXQ7IH19CisKKy8qIEludmFsaWQgYXNzZXJ0aW9uLCBwcmludCBvdXQgYW4gZXJyb3IgYW5kIGV4aXQuLi4gKi8KKyNkZWZpbmUgREFTU0VSVChjb25kLCByZXQsIGRiZywgYXJncy4uLikgXAorCXtpZigoREVCVUdfQVNTRVJUKSAmJiAhKGNvbmQpKSB7XAorCQlERVJST1IoZGJnLCAiSW52YWxpZCBhc3NlcnRpb246ICIgYXJncyk7XAorCQlyZXR1cm4gcmV0OyB9fQorCisvKioqKioqKioqKioqKioqKioqKioqKioqIENPTlNUQU5UUyAmIE1BQ1JPUyAqKioqKioqKioqKioqKioqKioqKioqKiovCisKKy8qIFBhcmFub2lhICovCisjZGVmaW5lIElSTkVUX01BR0lDCTB4QjAwNzU0CisKKy8qIE51bWJlciBvZiBjb250cm9sIGV2ZW50cyBpbiB0aGUgY29udHJvbCBjaGFubmVsIGJ1ZmZlci4uLiAqLworI2RlZmluZSBJUk5FVF9NQVhfRVZFTlRTCTgJLyogU2hvdWxkIGJlIG1vcmUgdGhhbiBlbm91Z2guLi4gKi8KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiBUWVBFUyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisKKy8qCisgKiBUaGlzIGlzIHRoZSBtYWluIHN0cnVjdHVyZSB3aGVyZSB3ZSBzdG9yZSBhbGwgdGhlIGRhdGEgcGVydGFpbmluZyB0bworICogb25lIGluc3RhbmNlIG9mIGlybmV0LgorICogTm90ZSA6IG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DY0NAppbmRleCAwMDAwMDAwLi5mMmZlY2QzCi0tLSAvZGV2L251bGwKKysrIGIvbmV0L2lyZGEvaXJuZXQvaXJuZXRfaXJkYS5oCkBAIC0wLDAgKzEsMTg2IEBACisvKgorICoJSXJORVQgcHJvdG9jb2wgbW9kdWxlIDogU3luY2hyb25vdXMgUFBQIG92ZXIgYW4gSXJEQSBzb2NrZXQuCisgKgorICoJCUplYW4gSUkgLSBIUEwgYDAwIC0gPGp0QGhwbC5ocC5jb20+CisgKgorICogVGhpcyBmaWxlIGNvbnRhaW5zIGFsbCBkZWZpbml0aW9ucyBhbmQgZGVjbGFyYXRpb25zIG5lY2Vzc2FyeSBmb3IgdGhlCisgKiBJUkRBIHBhcnQgb2YgdGhlIElyTkVUIG1vZHVsZSAoZGVhbGluZyB3aXRoIElyVFRQLCBJcklBUyBhbmQgY28pLgorICogVGhpcyBmaWxlIGlzIGEgcHJpdmF0ZSBoZWFkZXIsIHNvIG90aGVyIG1vZHVsZXMgZG9uJ3Qgd2FudCB0byBrbm93CisgKiB3aGF0J3MgaW4gdGhlcmUuLi4KKyAqLworCisjaWZuZGVmIElSTkVUX0lSREFfSAorI2RlZmluZSBJUk5FVF9JUkRBX0gKKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqIElOQ0xVREVTICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworLyogUGxlYXNlIGFkZCBvdGhlciBoZWFkZXJzIGluIGlybmV0LmggKi8KKworI2luY2x1ZGUgImlybmV0LmgiCQkvKiBNb2R1bGUgZ2xvYmFsIGluY2x1ZGUgKi8KKworLyoqKioqKioqKioqKioqKioqKioqKioqKiBDT05TVEFOVFMgJiBNQUNST1MgKioqKioqKioqKioqKioqKioqKioqKioqLworCisvKgorICogTmFtZSBvZiB0aGUgc2VydmljZSAoc29ja2V0IG5hbWUpIHVzZWQgYnkgSXJORVQKKyAqLworLyogSUFTIG9iamVjdCBuYW1lIChvciBwYXJ0IG9mIGl0KSAqLworI2RlZmluZSBJUk5FVF9TRVJWSUNFX05BTUUJIklyTmV0djEiCisvKiBJQVMgYXR0cmlidXRlICovCisjZGVmaW5lIElSTkVUX0lBU19WQUxVRQkJIklyREE6VGlueVRQOkxzYXBTZWwiCisvKiBMTVAgbm90aWZ5IG5hbWUgZm9yIGNsaWVudCAob25seSBmb3IgL3Byb2MvbmV0L2lyZGEvaXJsbXApICovCisjZGVmaW5lIElSTkVUX05PVElGWV9OQU1FCSJJck5FVCBzb2NrZXQiCisvKiBMTVAgbm90aWZ5IG5hbWUgZm9yIHNlcnZlciAob25seSBmb3IgL3Byb2MvbmV0L2lyZGEvaXJsbXApICovCisjZGVmaW5lIElSTkVUX05PVElGWV9OQU1FX1NFUlYJIklyTkVUIHNlcnZlciIKKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiBUWVBFUyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisKKy8qCisgKiBUaGlzIGlzIHRoZSBtYWluIHN0cnVjdHVyZSB3aGVyZSB3ZSBzdG9yZSBhbGwgdGhlIGRhdGEgcGVydGFpbmluZyB0bworICogdGhlIElyTkVUIHNlcnZlciAobGlzdGVuIGZvciBjb25uZWN0aW9uIHJlcXVlc3RzKSBhbmQgdGhlIHJvb3QKKyAqIG9mIHRoZSBJck5FVCBzb2NrZXQgbGlzdAorICovCit0eXBlZGVmIHN0cnVjdCBpcm5ldF9yb290Cit7CisgIGlybmV0X3NvY2tldAkJczsJCS8qIFRvIHByZXRlbmQgd2UgYXJlIGEgY2xpZW50Li4uICovCisKKyAgLyogR2VuZXJpYyBzdHVmZiAqLworICBpbnQJCQltYWdpYzsJCS8qIFBhcmFub2lhICovCisgIGludAkJCXJ1bm5pbmc7CS8qIEFyZSB3ZSBvcGVyYXRpb25hbCA/ICovCisKKyAgLyogTGluayBsaXN0IG9mIGFsbCBJck5FVCBpbnN0YW5jZXMgb3BlbmVkICovCisgIGhhc2hiaW5fdCAqCQlsaXN0OworICBzcGlubG9ja190CQlzcGlubG9jazsJLyogU2VyaWFsaXplIGFjY2VzcyB0byB0aGUgbGlzdCAqLworICAvKiBOb3RlIDogdGhlIHdheSBoYXNoYmluIGhhcyBiZWVuIGRlc2lnbmVkIGlzIGFic29sdXRlbHkgbm90CisgICAqIHJlZW50cmFudCwgYmV3YXJlLi4uIFNvLCB3ZSBibGluZGx5IHByb3RlY3QgYWxsIHdpdGggc3BpbmxvY2sgKi8KKworICAvKiBIYW5kbGUgZm9yIHRoZSBoaW50IGJpdCBhZHZlcnRpc2VkIGluIElyTE1QICovCisgIHZvaWQgKgkJc2tleTsKKworICAvKiBTZXJ2ZXIgc29ja2V0IHBhcnQgKi8KKyAgc3RydWN0IGlhc19vYmplY3QgKglpYXNfb2JqOwkvKiBPdXIgc2VydmljZSBuYW1lICsgbHNhcCBpbiBJQVMgKi8KKworfSBpcm5ldF9yb290OworCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqIFBST1RPVFlQRVMgKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKworLyogLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0gQ09OVFJPTCBDSEFOTkVMIC0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tICovCitzdGF0aWMgdm9pZAorCWlybmV0X3Bvc3RfZXZlbnQoaXJuZXRfc29ja2V0ICosCisJCQkgaXJuZXRfZXZlbnQsCisJCQkgX191MzIsCisJCQkgX191MzIsCisJCQkgY2hhciAqLAorCQkJIF9fdTE2KTsKKy8qIC0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tIElSREEgU1VCUk9VVElORVMgLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0gKi8KK3N0YXRpYyBpbmxpbmUgaW50CisJaXJuZXRfb3Blbl90c2FwKGlybmV0X3NvY2tldCAqKTsKK3N0YXRpYyBpbmxpbmUgX191OAorCWlybmV0X2lhc190b190c2FwKGlybmV0X3NvY2tldCAqLAorCQkJICBpbnQsCisJCQkgIHN0cnVjdCBpYXNfdmFsdWUgK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gY291bnQpOworCisgIC8qIENoZWNrIGZvciBvdmVyZmxvdy4uLiAqLworICBEQUJPUlQoY291bnQgPj0gSVJORVRfTUFYX0NPTU1BTkQsIC1FTk9NRU0sCisJIENUUkxfRVJST1IsICJUb28gbXVjaCBkYXRhICEhIVxuIik7CisKKyAgLyogR2V0IHRoZSBkYXRhIGluIHRoZSBkcml2ZXIgKi8KKyAgaWYoY29weV9mcm9tX3VzZXIoY29tbWFuZCwgYnVmLCBjb3VudCkpCisgICAgeworICAgICAgREVSUk9SKENUUkxfRVJST1IsICJJbnZhbGlkIHVzZXIgc3BhY2UgcG9pbnRlci5cbiIpOworICAgICAgcmV0dXJuIC1FRkFVTFQ7CisgICAgfQorCisgIC8qIFNhZmUgdGVybWluYXRlIHRoZSBzdHJpbmcgKi8KKyAgY29tbWFuZFtjb3VudF0gPSAnXDAnOworICBERUJVRyhDVFJMX0lORk8sICJDb21tYW5kIGxpbmUgcmVjZWl2ZWQgaXMgYGAlcycnICglWmQpLlxuIiwKKwljb21tYW5kLCBjb3VudCk7CisKKyAgLyogQ2hlY2sgZXZlcnkgY29tbWFuZHMgaW4gdGhlIGNvbW1hbmQgbGluZSAqLworICBuZXh0ID0gY29tbWFuZDsKKyAgd2hpbGUobmV4dCAhPSBOVUxMKQorICAgIHsKKyAgICAgIC8qIExvb2sgYXQgdGhlIG5leHQgY29tbWFuZCAqLworICAgICAgc3RhcnQgPSBuZXh0OworCisgICAgICAvKiBTY3JhcCB3aGl0ZXNwYWNlcyBiZWZvcmUgdGhlIGNvbW1hbmQgKi8KKyAgICAgIHdoaWxlKGlzc3BhY2UoKnN0YXJ0KSkKKwlzdGFydCsrOworCisgICAgICAvKiAnLCcgaXMgb3VyIGNvbW1hbmQgc2VwYXJhdG9yICovCisgICAgICBuZXh0ID0gc3RyY2hyKHN0YXJ0LCAnLCcpOworICAgICAgaWYobmV4dCkKKwl7CisJICAqbmV4dCA9ICdcMCc7CQkJLyogVGVybWluYXRlIGNvbW1hbmQgKi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RJQkxFOworICBmb3IoOzspCisgICAgeworICAgICAgLyogSWYgdGhlcmUgaXMgdW5yZWFkIGV2ZW50cyAqLworICAgICAgcmV0ID0gMDsKKyAgICAgIGlmKGFwLT5ldmVudF9pbmRleCAhPSBpcm5ldF9ldmVudHMuaW5kZXgpCisJYnJlYWs7CisgICAgICByZXQgPSAtRUFHQUlOOworICAgICAgaWYoZmlsZS0+Zl9mbGFncyAmIE9fTk9OQkxPQ0spCisJYnJlYWs7CisgICAgICByZXQgPSAtRVJFU1RBUlRTWVM7CisgICAgICBpZihzaWduYWxfcGVuZGluZyhjdXJyZW50KSkKKwlicmVhazsKKyAgICAgIC8qIFlpZWxkIGFuZCB3YWl0IHRvIGJlIHdva2VuIHVwICovCisgICAgICBzY2hlZHVsZSgpOworICAgIH0KKyAgY3VycmVudC0+c3RhdGUgPSBUQVNLX1JVTk5JTkc7CisgIHJlbW92ZV93YWl0X3F1ZXVlKCZpcm5ldF9ldmVudHMucndhaXQsICZ3YWl0KTsKKworICAvKiBEaWQgd2UgZ290IGl0ID8gKi8KKyAgaWYocmV0ICE9IDApCisgICAgeworICAgICAgLyogTm8sIHJldHVybiB0aGUgZXJyb3IgY29kZSAqLworICAgICAgREVYSVQoQ1RSTF9UUkFDRSwgIiAtIHJldCAlWmRcbiIsIHJldCk7CisgICAgICByZXR1cm4gcmV0OworICAgIH0KKworICAvKiBXaGljaCBldmVudCBpcyBpdCA/ICovCisgIHN3aXRjaChpcm5ldF9ldmVudHMubG9nW2FwLT5ldmVudF9pbmRleF0uZXZlbnQpCisgICAgeworICAgIGNhc2UgSVJORVRfRElTQ09WRVI6CisgICAgICBzcHJpbnRmKGV2ZW50LCAiRGlzY292ZXJlZCAlMDh4ICglcykgYmVoaW5kICUwOHgge2hpbnRzICUwMlgtJTAyWH1cbiIsCisJICAgICAgaXJuZXRfZXZlbnRzLmxvZ1thcC0+ZXZlbnRfaW5kZXhdLmRhZGRyLAorCSAgICAgIGlybmV0X2V2ZW50cy5sb2d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AorCSAgICAgIGlybmV0X2V2ZW50cy5sb2dbYXAtPmV2ZW50X2luZGV4XS5kYWRkciwKKwkgICAgICBpcm5ldF9ldmVudHMubG9nW2FwLT5ldmVudF9pbmRleF0ubmFtZSwKKwkgICAgICBpcm5ldF9ldmVudHMubG9nW2FwLT5ldmVudF9pbmRleF0udW5pdCk7CisgICAgICBicmVhazsKKyAgICBjYXNlIElSTkVUX0RJU0NPTk5FQ1RfRlJPTToKKyAgICAgIHNwcmludGYoZXZlbnQsICJEaXNjb25uZWN0aW9uIGZyb20gJTA4eCAoJXMpIG9uIHBwcCVkXG4iLAorCSAgICAgIGlybmV0X2V2ZW50cy5sb2dbYXAtPmV2ZW50X2luZGV4XS5kYWRkciwKKwkgICAgICBpcm5ldF9ldmVudHMubG9nW2FwLT5ldmVudF9pbmRleF0ubmFtZSwKKwkgICAgICBpcm5ldF9ldmVudHMubG9nW2FwLT5ldmVudF9pbmRleF0udW5pdCk7CisgICAgICBicmVhazsKKyAgICBjYXNlIElSTkVUX0RJU0NPTk5FQ1RfVE86CisgICAgICBzcHJpbnRmKGV2ZW50LCAiRGlzY29ubmVjdGVkIHRvICUwOHggKCVzKVxuIiwKKwkgICAgICBpcm5ldF9ldmVudHMubG9nW2FwLT5ldmVudF9pbmRleF0uZGFkZHIsCisJICAgICAgaXJuZXRfZXZlbnRzLmxvZ1thcC0+ZXZlbnRfaW5kZXhdLm5hbWUpOworICAgICAgYnJlYWs7CisgICAgZGVmYXVsdDoKKyAgICAgIHNwcmludGYoZXZlbnQsICJCdWdcbiIpOworICAgIH0KKyAgLyogSW5jcmVtZW50IG91ciBldmVudCBpbmRleCAqLworICBhcC0+ZXZlbnRfaW5kZXggPSAoYXAtPmV2ZW50X2luZGV4ICsgMSkgJSBJUk5FVF9NQVhfRVZFTlRTOworCisgIERFQlVHKENUUkxfSU5GTywgIkV2ZW50IGlzIDolcyIsIGV2ZW50KTsKKworICAvKiBDb3B5IGl0IHRvIHRoZSB1c2VyICovCisgIGl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U19FUlJPUiwgIkNhbid0IHNldHVwIFBQUCBjaGFubmVsLi4uXG4iKTsKKwl9CisgICAgICBlbHNlCisJeworCSAgLyogSW4gdGhlb3J5LCBzaG91bGQgYmUgTl9UVFkgKi8KKwkgIERFQlVHKEZTX0lORk8sICJFeGl0aW5nIFBQUCBkaXNjaXBsaW5lLlxuIik7CisJICAvKiBEaXNjb25uZWN0IGZyb20gdGhlIGdlbmVyaWMgUFBQIGxheWVyICovCisJICBpZihhcC0+cHBwX29wZW4pCisJICAgIHsKKwkgICAgICBhcC0+cHBwX29wZW4gPSAwOworCSAgICAgIHBwcF91bnJlZ2lzdGVyX2NoYW5uZWwoJmFwLT5jaGFuKTsKKwkgICAgfQorCSAgZWxzZQorCSAgICBERVJST1IoRlNfRVJST1IsICJDaGFubmVsIG5vdCByZWdpc3RlcmVkICFcbiIpOworCSAgZXJyID0gMDsKKwl9CisgICAgICBicmVhazsKKworICAgICAgLyogUXVlcnkgUFBQIGNoYW5uZWwgYW5kIHVuaXQgbnVtYmVyICovCisgICAgY2FzZSBQUFBJT0NHQ0hBTjoKKyAgICAgIGlmKCFhcC0+cHBwX29wZW4pCisJYnJlYWs7CisgICAgICBpZihwdXRfdXNlcihwcHBfY2hhbm5lbF9pbmRleCgmYXAtPmNoYW4pLCAoaW50IF9fdXNlciAqKWFyZ3ApKQorCWJyZWFrOworICAgICAgREVCVUcoRlNfSU5GTywgIlF1ZXJ5IGNoYW5uZWwuXG4iKTsKKyAgICAgIGVyciA9IDA7CisgICAgICBicmVhazsKKyAgICBjYXNlIFBQUElPQ0dVTklUOgorICAgICAgaWYoIWFwLT5wcHBfb3BlbikKKwlicmVhazsKKyAgICAgIGlmKHB1dF91c2VyKHBwcF91bml0X251bWJlcigmYXAtPmNoYW4pLCAoaW50IF9fdXNlciAqKWFyZ3ApKQorCWJyZWFrOworICAgICAgREVCVUcoRlNfSU5GTywgIlF1ZXJ5IHVuaXQgbnVtYmVyLlxuIik7CisgICAgICBlcnIgPSAwO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lYWs7CisgICAgICBlcnIgPSAwOworICAgICAgYnJlYWs7CisgICAgICAvKiBTZXQgdGVybWlvcyAqLworICAgIGNhc2UgVENTRVRTRjoKKyAgICAgIERFQlVHKEZTX0lORk8sICJTZXQgdGVybWlvcy5cbiIpOworICAgICAgaWYodXNlcl90ZXJtaW9zX3RvX2tlcm5lbF90ZXJtaW9zKCZhcC0+dGVybWlvcywgKHN0cnVjdCB0ZXJtaW9zIF9fdXNlciAqKWFyZ3ApKQorCWJyZWFrOworICAgICAgZXJyID0gMDsKKyAgICAgIGJyZWFrOworCisgICAgICAvKiBTZXQgRFRSL1JUUyAqLworICAgIGNhc2UgVElPQ01CSVM6IAorICAgIGNhc2UgVElPQ01CSUM6CisgICAgICAvKiBTZXQgZXhjbHVzaXZlL25vbi1leGNsdXNpdmUgbW9kZSAqLworICAgIGNhc2UgVElPQ0VYQ0w6CisgICAgY2FzZSBUSU9DTlhDTDoKKyAgICAgIERFQlVHKEZTX0lORk8sICJUVFkgY29tcGF0aWJpbGl0eS5cbiIpOworICAgICAgZXJyID0gMDsKKyAgICAgIGJyZWFrOworCisgICAgY2FzZSBUQ0dFVEE6CisgICAgICBERUJVRyhGU19JTkZPLCAiVENHRVRBXG4iKTsKKyAgICAgIGJyZWFrOworCisgICAgY2FzZSBUQ0ZMU0g6CisgICAgICBERUJVRyhGU19JTkZPLCAiVENGTFNIXG4iKTsKKyAgICAgIC8qIE5vdGUgOiB0aGlzIHdpbGwgZmx1c2ggYnVmZmVycyBpbiBQUFAsIHNvIGl0ICptdXN0KiBiZSBkb25lCisgICAgICAgKiBXZSBzaG91bGQgYWxzbyB3b3JyeSB0aGF0IHdlIGRvbid0IGFjY2VwdCBqdW5rIGhlcmUgYW5kIHRoYXQKKyAgICAgICAqIHdlIGdldCByaWQgb2Ygb3VyIG93biBidWZmZXJzICovCisjaWZkZWYgRkxVU0hfVE9fUFBQCisgICAgICBwcHBfb3V0cHV0X3dha2V1cCgmYXAtPmNoYW4pOworI2VuZGlmIC8qIEZMVVNIX1RPX1BQUCAqLworICAgICAgZXJyID0gMDsKKyAgICAgIGJyZWFrOworCisgICAgY2FzZSBGSU9OUkVBRDoKKyAgICAgIERFQlVHKEZTX0lORk8sICJGSU9OUkVBRFxuIik7CisgICAgICB2YWwgPSAwOworICAgICAgaWYocHV0X3VzZXIodmFsLCAoaW50IF9fdXNlciAqKWFyZ3ApKQorCWJyZWFrOworICAgICAgZXJyID0gMDsKKyAgICAgIGJyZWFrOworCisgICAgZGVmYXVsdDoKKyAgICAgIERFUlJPUihGU19FUlJPUiwgIlVuc3VwcG9ydGVkIGlvY3RsICgweCVYKVxuIiwgY21kKTsKKyAgICAgIGVyciA9IC1FTk9JT0NUTENNRDsKKyAgICB9CisKKyAgREVYSVQoRlNfVFJBQ0UsICIgLSBlcnIgPSAweCVYXG4iLCBlcnIpOworICByZXR1cm4gZXJyOworfQorCisvKioqKioqKioqKioqKioqKioqKioqKioqKiogUFBQIENBTExCQUNLUyAqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKy8qCisgKiBUaGlzIGFyZSB0aGUgZnVuY3Rpb25zIHRoYXQgdGhlIGdlbmVyaWMgUFBQIGRyaXZlciBpbiB0aGUga2VybmVsCisgKiB3aWxsIGNhbGwgdG8gY29tbXVuaWNhdGUgdG8gdXMuCisgKi8KKworLyotLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0qLworLyoKKyAqIFByZXBhcmUgdGhlIHBwcCBmcmFtZSBmb3IgdHJhbnNtaXNzaW9uIG92ZXIgdGhlIElyREEgc29ja2V0LgorICogV2UgbWFrZSBzdXJlIHRoYXQgdGhlIGhlYWRlciBzcGFjZSBpcyBlbm91Z2gsIGFuZCB3ZSBjaGFuZ2UgcHBwIGhlYWRlcgorICogYWNjb3JkaW5nIHRvIGZsYWdzIHBhc3NlZCBieSBwcHBkLgorICogVGhpcyBpcyBub3QgY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Agc2tiX3B1bGwoc2tiLDEpOworCisgIC8qIENoZWNrIGlmIHdlIG5lZWQgYWRkcmVzcy9jb250cm9sIGZpZWxkcyAqLworICBuZWVkYWRkciA9IDIqKChhcC0+ZmxhZ3MgJiBTQ19DT01QX0FDKSA9PSAwIHx8IGlzbGNwKTsKKworICAvKiBJcyB0aGUgc2tiIGhlYWRyb29tIGxhcmdlIGVub3VnaCB0byBjb250YWluIGFsbCBJckRBLWhlYWRlcnM/ICovCisgIGlmKChza2JfaGVhZHJvb20oc2tiKSA8IChhcC0+bWF4X2hlYWRlcl9zaXplICsgbmVlZGFkZHIpKSB8fAorICAgICAgKHNrYl9zaGFyZWQoc2tiKSkpCisgICAgeworICAgICAgc3RydWN0IHNrX2J1ZmYgKgluZXdfc2tiOworCisgICAgICBERUJVRyhQUFBfSU5GTywgIlJlYWxsb2NhdGluZyBza2JcbiIpOworCisgICAgICAvKiBDcmVhdGUgYSBuZXcgc2tiICovCisgICAgICBuZXdfc2tiID0gc2tiX3JlYWxsb2NfaGVhZHJvb20oc2tiLCBhcC0+bWF4X2hlYWRlcl9zaXplICsgbmVlZGFkZHIpOworCisgICAgICAvKiBXZSBoYXZlIHRvIGZyZWUgdGhlIG9yaWdpbmFsIHNrYiBhbnl3YXkgKi8KKyAgICAgIGRldl9rZnJlZV9za2Ioc2tiKTsKKworICAgICAgLyogRGlkIHRoZSByZWFsbG9jIHN1Y2NlZWQgPyAqLworICAgICAgREFCT1JUKG5ld19za2IgPT0gTlVMTCwgTlVMTCwgUFBQX0VSUk9SLCAiQ291bGQgbm90IHJlYWxsb2Mgc2tiXG4iKTsKKworICAgICAgLyogVXNlIHRoZSBuZXcgc2tiIGluc3RlYWQgKi8KKyAgICAgIHNrYiA9IG5ld19za2I7CisgICAgfQorCisgIC8qIHByZXBlbmQgYWRkcmVzcy9jb250cm9sIGZpZWxkcyBpZiBuZWNlc3NhcnkgKi8KKyAgaWYobmVlZGFkZHIpCisgICAgeworICAgICAgc2tiX3B1c2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isgICAgICBhcC0+ZmxhZ3MgPSB2YWwgJiB+U0NfUkNWX0JJVFM7CisgICAgICBhcC0+cmJpdHMgPSB2YWwgJiBTQ19SQ1ZfQklUUzsKKyAgICAgIGVyciA9IDA7CisgICAgICBicmVhazsKKworICAgICAgLyogQXN5bmMgbWFwIHN0dWZmIC0gYWxsIGR1bW15IHRvIHBsZWFzZSBwcHBkICovCisgICAgY2FzZSBQUFBJT0NHQVNZTkNNQVA6CisgICAgICBpZihwdXRfdXNlcihhcC0+eGFjY21bMF0sICh1MzIgX191c2VyICopIGFyZ3ApKQorCWJyZWFrOworICAgICAgZXJyID0gMDsKKyAgICAgIGJyZWFrOworICAgIGNhc2UgUFBQSU9DU0FTWU5DTUFQOgorICAgICAgaWYoZ2V0X3VzZXIoYXAtPnhhY2NtWzBdLCAodTMyIF9fdXNlciAqKSBhcmdwKSkKKwlicmVhazsKKyAgICAgIGVyciA9IDA7CisgICAgICBicmVhazsKKyAgICBjYXNlIFBQUElPQ0dSQVNZTkNNQVA6CisgICAgICBpZihwdXRfdXNlcihhcC0+cmFjY20sICh1MzIgX191c2VyICopIGFyZ3ApKQorCWJyZWFrOworICAgICAgZXJyID0gMDsKKyAgICAgIGJyZWFrOworICAgIGNhc2UgUFBQSU9DU1JBU1lOQ01BUDoKKyAgICAgIGlmKGdldF91c2VyKGFwLT5yYWNjbSwgKHUzMiBfX3VzZXIgKikgYXJncCkpCisJYnJlYWs7CisgICAgICBlcnIgPSAwOworICAgICAgYnJlYWs7CisgICAgY2FzZSBQUFBJT0NHWEFTWU5DTUFQOgorICAgICAgaWYoY29weV90b191c2VyKGFyZ3AsIGFwLT54YWNjbSwgc2l6ZW9mKGFwLT54YWNjbSkpKQorCWJyZWFrOworICAgICAgZXJyID0gMDsKKyAgICAgIGJyZWFrOworICAgIGNhc2UgUFBQSU9DU1hBU1lOQ01BUDoKKyAgICAgIGlmKGNvcHlfZnJvbV91c2VyKGFjY20sIGFyZ3AsIHNpemVvZihhY2NtKSkpCisJYnJlYWs7CisgICAgICBhY2NtWzJdICY9IH4weDQwMDAwMDAwVTsJCS8qIGNhbid0IGVzY2FwZSAweDVlICovCisgICAgICBhY2NtWzNdIHw9IDB4NjAwMDAwMDBVOwkJLyogbXVzdCBlc2NhcGUgMHg3ZCwgMHg3ZSAqLworICAgICAgbWVtY3B5KGFwLT54YWNjbSwgYWNjbSwgc2l6ZW9mKGFwLT54YWNjbSkpOworICAgICAgZXJyID0gMDsKKyAgICAgIGJyZWFrOworCisgICAgICAvKiBNYXggUFBQIGZyYW1lIHNpemUgKi8KKyAgICBjYXNlIFBQUElPQ0dNUlU6CisgICAgICBpZihwdXRfdXNlcihhcC0+bXJ1LCAoaW50IF9fdXNlciAqKSBhcmdwKSkKKwlicmVhazsKKyAgICAgIGVyciA9IDA7CisgICAgICBicmVhazsKKyAgICBjYXNlIFBQUElPQ1NNUlU6CisgICAgICBpZihnZXRfdXNlcih2YWwsIChpbnQgX191c2VyICopIGFyZ3ApKQorCWJyZWFrOworICAgICAgaWYodmFsIDwgUFBQX01SVSkKKwl2YWwgPSBQUFBfTVJVOworICAgICAgYXAtPm1ydSA9IHZhbDsKKyAgICAgIGVyciA9IDA7CisgICAgICBicmVhazsKKworICAgIGRlZmF1bHQ6CisgICAgICBERUJVRyhQUFBfSU5GTywgIlVuc3VwcG9ydGVkIGlvY3RsICgweCVYKVxuIiwgY21kKTsKKyAgICAgIGVyciA9IC1FTk9JT0NUTENNRDsKKyAgICB9CisKKyAgREVYSVQoUFBQX1RSQUNFLCAiIC0gZXJyID0gMHglWFxuIiwgZXJyKTsKKyAgcmV0dXJuIGVycjsKK30KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqIElOSVRJQUxJU0FUSU9OICoqKioqKioqKioqKioqKioqKioqKioqKioqLworLyoKKyAqIE1vZHVsZSBpbml0aWFsaXNhdGlvbiBhbmQgYWxsIHRoYXQgamF6ei4uLgorICovCisKKy8qLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS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YnVmWzFdOyAvKiBFeHRyYWN0IGxlbmdodCBvZiB2YWx1ZSAqLworCisJLyogQ2hlY2sgaWYgYnVmZmVyIGlzIGxvbmcgZW5vdWdoIGZvciBwYXJzaW5nICovCisJaWYgKGxlbiA8ICgyK3AucGwpKSB7CisJCUlSREFfV0FSTklORygiJXM6IGJ1ZmZlciB0byBzaG9ydCBmb3IgcGFyc2luZyEgIgorCQkJICAgICAiTmVlZCAlZCBieXRlcywgYnV0IGxlbiBpcyBvbmx5ICVkXG4iLAorCQkJICAgICBfX0ZVTkNUSU9OX18sIHAucGwsIGxlbik7CisJCXJldHVybiAtMTsKKwl9CisKKwlJUkRBX0RFQlVHKDAsICIlcygpLCBub3QgaW1wbFxuIiwgX19GVU5DVElPTl9fKTsKKworCXJldHVybiBwLnBsKzI7IC8qIEV4dHJhY3RlZCBwbCsyIGJ5dGVzICovCit9CisKKy8qCisgKiBGdW5jdGlvbiBpcmRhX3BhcmFtX3BhY2sgKHNrYiwgZm10LCAuLi4pCisgKgorICogICAgRm9ybWF0OgorICogICAgICAgICdpJyA9IDMyIGJpdHMgaW50ZWdlcgorICogICAgICAgICdzJyA9IHN0cmluZworICoKKyAqLworaW50IGlyZGFfcGFyYW1fcGFjayhfX3U4ICpidWYsIGNoYXIgKmZtdCwgLi4uKQoreworCWlyZGFfcHZfdCBhcmc7CisJdmFfbGlzdCBhcmdzOworCWNoYXIgKnA7CisJaW50IG4gPSAwOworCisJdmFfc3RhcnQoYXJncywgZm10KTsKKworCWZvciAocCA9IGZtdDsgKnAgIT0gJ1wwJzsgcCsrKSB7CisJCXN3aXRjaCAoKnApIHsKKwkJY2FzZSAnYic6ICAvKiA4IGJpdHMgdW5zaWduZWQgYnl0ZSAqLworCQkJYnVmW24rK10gPSAoX191OCl2YV9hcmcoYXJncywgaW50KTsKKwkJCWJyZWFrOworCQljYXNlICdzJzogIC8qIDE2IGJpdHMgdW5zaWduZWQgc2hvcnQgKi8KKwkJCWFyZy5pID0gKF9fdTE2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N0KHNlbGYsIGJ1ZituLCBsZW4sIGluZm8pOworCQlpZiAocmV0IDwgMCkKKwkJCXJldHVybiByZXQ7CisKKwkJbiArPSByZXQ7CisJCWxlbiAtPSByZXQ7CisJfQorCXJldHVybiBuOworfQorRVhQT1JUX1NZTUJPTChpcmRhX3BhcmFtX2V4dHJhY3RfYWxsKTsKZGlmZiAtLWdpdCBhL25ldC9pcmRhL3Fvcy5jIGIvbmV0L2lyZGEvcW9zLmMKbmV3IGZpbGUgbW9kZSAxMDA2NDQKaW5kZXggMDAwMDAwMC4uZGY3MzJkNQotLS0gL2Rldi9udWxsCisrKyBiL25ldC9pcmRhL3Fvcy5jCkBAIC0wLDAgKzEsNzc0IEBACisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCisgKiBGaWxlbmFtZTogICAgICBxb3MuYworICogVmVyc2lvbjogICAgICAgMS4wCisgKiBEZXNjcmlwdGlvbjogICBJckxBUCBRb1MgcGFyYW1ldGVyIG5lZ290aWF0aW9uCisgKiBTdGF0dXM6ICAgICAgICBTdGFibGUKKyAqIEF1dGhvcjogICAgICAgIERhZyBCcmF0dGxpIDxkYWdiQGNzLnVpdC5ubz4KKyAqIENyZWF0ZWQgYXQ6ICAgIFR1ZSBTZXAgIDkgMDA6MDA6MjYgMTk5NworICogTW9kaWZpZWQgYXQ6ICAgU3VuIEphbiAzMCAxNDoyOToxNiAyMDAwCisgKiBNb2RpZmllZCBieTogICBEYWcgQnJhdHRsaSA8ZGFnYkBjcy51aXQubm8+CisgKiAKKyAqICAgICBDb3B5cmlnaHQgKGMpIDE5OTgtMjAwMCBEYWcgQnJhdHRsaSA8ZGFnYkBjcy51aXQubm8+LCAKKyAqICAgICBBbGwgUmlnaHRzIFJlc2VydmVkLgorICogICAgIENvcHlyaWdodCAoYykgMjAwMC0yMDAxIEplYW4gVG91cnJp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vY2ssIGludCBiYWNrbG9nKQoreworCXN0cnVjdCBzb2NrICpzayA9IHNvY2stPnNrOworCWludCByYyA9IC1FSU5WQUw7CisKKwlsb2NrX3NvY2soc2spOworCWlmIChzb2NrLT5zdGF0ZSAhPSBTU19VTkNPTk5FQ1RFRCkKKwkJZ290byBvdXQ7CisJcmMgPSAtRU9QTk9UU1VQUDsKKwlpZiAoc2stPnNrX3R5cGUgIT0gU09DS19TVFJFQU0pCisJCWdvdG8gb3V0OworCXJjID0gLUVBR0FJTjsKKwlpZiAoc29ja19mbGFnKHNrLCBTT0NLX1pBUFBFRCkpCisJCWdvdG8gb3V0OworCXJjID0gMDsKKwlpZiAoISh1bnNpZ25lZCliYWNrbG9nKQkvKiBCU0Rpc20gKi8KKwkJYmFja2xvZyA9IDE7CisJc2stPnNrX21heF9hY2tfYmFja2xvZyA9IGJhY2tsb2c7CisJaWYgKHNrLT5za19zdGF0ZSAhPSBUQ1BfTElTVEVOKSB7CisJCXNrLT5za19hY2tfYmFja2xvZyA9IDA7CisJCXNrLT5za19zdGF0ZQkgICA9IFRDUF9MSVNURU47CisJfQorCXNrLT5za19zb2NrZXQtPmZsYWdzIHw9IF9fU09fQUNDRVBUQ09OOworb3V0OgorCXJlbGVhc2Vfc29jayhzayk7CisJcmV0dXJuIHJjOworfQorCitzdGF0aWMgaW50IGxsY191aV93YWl0X2Zvcl9kaXNjKHN0cnVjdCBzb2NrICpzaywgaW50IHRpbWVvdXQpCit7CisJREVDTEFSRV9XQUlUUVVFVUUod2FpdCwgY3VycmVudCk7CisJaW50IHJjOworCisJYWRkX3dhaXRfcXVldWVfZXhjbHVzaXZlKHNrLT5za19zbGVlcCwgJndhaXQpOworCWZvciAoOzspIHsKKwkJX19zZXRfY3VycmVudF9zdGF0ZShUQVNLX0lOVEVSUlVQVElCTEUpOworCQlyYyA9IDA7CisJCWlmIChzay0+c2tfc3RhdGUgIT0gVENQX0NMT1NFKSB7CisJCQlyZWxlYXNlX3NvY2soc2spOworCQ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NrX2J1ZmYgKmV2KTsKKworc3RhdGljIGludCBsbGNfY29ubl9hY19pbmNfbnB0YV92YWx1ZShzdHJ1Y3Qgc29jayAqc2ssIHN0cnVjdCBza19idWZmICpza2IpOworCitzdGF0aWMgaW50IGxsY19jb25uX2FjX3NlbmRfcnJfcnNwX2Zfc2V0X2Fja3BmKHN0cnVjdCBzb2NrICpzaywKKwkJCQkJICAgICAgIHN0cnVjdCBza19idWZmICpza2IpOworCitzdGF0aWMgaW50IGxsY19jb25uX2FjX3NldF9wX2ZsYWdfMShzdHJ1Y3Qgc29jayAqc2ssIHN0cnVjdCBza19idWZmICpza2IpOworCisjZGVmaW5lIElOQ09SUkVDVCAwCisKK2ludCBsbGNfY29ubl9hY19jbGVhcl9yZW1vdGVfYnVzeShzdHJ1Y3Qgc29jayAqc2ssIHN0cnVjdCBza19idWZmICpza2IpCit7CisJc3RydWN0IGxsY19zb2NrICpsbGMgPSBsbGNfc2soc2spOworCisJaWYgKGxsYy0+cmVtb3RlX2J1c3lfZmxhZykgeworCQl1OCBucjsKKwkJc3RydWN0IGxsY19wZHVfc24gKnBkdSA9IGxsY19wZHVfc25faGRyKHNrYik7CisKKwkJbGxjLT5yZW1vdGVfYnVzeV9mbGFnID0gMDsKKwkJZGVsX3RpbWVyKCZsbGMtPmJ1c3lfc3RhdGVfdGltZXIudGltZXIpOworCQluciA9IExMQ19JX0dFVF9OUihwZHUpOworCQlsbGNfY29ubl9yZXNlbmRfaV9wZHVfYXNfY21kKHNrLCBuciwgMCk7CisJfQorCXJldHVybiAwOworfQorCitpbnQgbGxjX2Nvbm5fYWNfY29ubl9pbmQoc3RydWN0IHNvY2sgKnNrLCBzdHJ1Y3Qgc2tfYnVmZiAqc2tiKQoreworCWludCByYyA9IC1FTk9UQ09OTjsKKwl1OCBkc2FwOworCXN0cnVjdCBsbGNfc2FwICpzYXA7CisKKwlsbGNfcGR1X2RlY29kZV9kc2FwKHNrYiwgJmRzYXApOworCXNhcCA9IGxsY19zYXBfZmluZChkc2FwKTsKKwlpZiAoc2FwKSB7CisJCXN0cnVjdCBsbGNfY29ubl9zdGF0ZV9ldiAqZXYgPSBsbGNfY29ubl9ldihza2IpOworCQlzdHJ1Y3QgbGxjX3NvY2sgKmxsYyA9IGxsY19zayhzayk7CisKKwkJbGxjX3BkdV9kZWNvZGVfc2Eoc2tiLCBsbGMtPmRhZGRyLm1hYyk7CisJCWxsY19wZHVfZGVjb2RlX2RhKHNrYiwgbGxjLT5sYWRkci5tYWMpOworCQlsbGMtPmRldiA9IHNrYi0+ZGV2OworCQlldi0+aW5kX3ByaW0gPSBMTENfQ09OTl9QUklNOworCQlyYyA9IDA7CisJfQorCXJldHVybiByYzsKK30KKworaW50IGxsY19jb25uX2FjX2Nvbm5fY29uZmlybShzdHJ1Y3Qgc29jayAqc2ssIHN0cnVjdCBza19idWZmICpza2IpCit7CisJc3RydWN0IGxsY19jb25uX3N0YXRlX2V2ICpldiA9IGxsY19jb25uX2V2KHNrYik7CisKKwlldi0+Y2ZtX3ByaW0gPSBMTENfQ09OTl9QUklNOworCXJldHVybiAwOworfQorCitzdGF0aWMgaW50IGxsY19jb25uX2FjX2RhdGFfY29uZmlybShzdHJ1Y3Qgc29jayAqc2ssIHN0cnVjdCBza19idWZmICpza2IpCit7CisJc3RydWN0IGxsY19jb25uX3N0YXRlX2V2ICpldiA9IGxsY19jb25uX2V2KHNrYik7CisKKwlldi0+Y2ZtX3ByaW0gPSBMTENfREFUQV9QUklNOworCXJldHVybiAwOworfQorCitpbnQgbGxjX2Nvbm5fYWNfZGF0YV9pbmQoc3RydWN0IHNvY2sgKnNrLCBzdHJ1Y3Qgc2tfYnVmZiAqc2tiKQoreworCWxsY19jb25uX3J0bl9wZHUoc2ssIHNrYik7CisJcmV0dXJuIDA7Cit9CisKK2ludCBsbGNfY29ubl9hY19kaXNjX2luZChzdHJ1Y3Qgc29jayAqc2ssIHN0cnVjdCBza19idWZmICpza2IpCit7CisJc3RydWN0IGxsY19jb25uX3N0YXRlX2V2ICpldiA9IGxsY19jb25uX2V2KHNrYik7CisJdTggcmVhc29uID0gMDsKKwlpbnQgcmMgPSAwOworCisJaWYgKGV2LT50eXBlID09IExMQ19DT05OX0VWX1RZUEVfUERVKSB7CisJCXN0cnVjdCBsbGNfcGR1X3VuICpwZHUgPSBsbGNfcGR1X3VuX2hkcihza2IpOworCisJCWlmIChMTENfUERVX0lTX1JTUChwZHUpICYmCisJCSAgICBMTENfUERVX1RZUEVfSVNfVShwZHUpICYmCisJCSAgICBMTENfVV9QRFVfUlNQKHBkdSkgPT0gTExDXzJfUERVX1JTUF9ETSkKKwkJCXJlYXNvbiA9IExMQ19ESVNDX1JFQVNPTl9SWF9ETV9SU1BfUERVOworCQllbHNlIGlmIChMTENfUERVX0lTX0NNRChwZHUpICYmCisJCQkgICBMTENfUERVX1RZUEVfSVNfVShwZHUpICYmCisJCQkgICBMTENfVV9QRFVfQ01EKHBkdSkgPT0gTExDXzJfUERVX0NNRF9ESVNDKQorCQkJcmVhc29uID0gTExDX0RJU0NfUkVBU09OX1JYX0RJU0NfQ01EX1BEVTsKKwl9IGVsc2UgaWYgKGV2LT50eXBlID09IExMQ19DT05OX0VWX1RZUEVfQUNLX1RNUikKKwkJcmVhc29uID0gTExDX0RJU0NfUkVBU09OX0FDS19UTVJfRVhQOworCWVsc2UgeworCQlyZWFzb24gPSAwOworCQlyYyA9IC1FSU5WQUw7CisJfQorCWlmICghcmMpIHsKKwkJZXYtPnJlYXNvbiAgID0gcmVhc29uOworCQlldi0+aW5kX3ByaW0gPSBMTENfRElTQ19QUklNOworCX0KKwlyZXR1cm4gcmM7Cit9CisKK2ludCBsbGNfY29ubl9hY19kaXNjX2NvbmZpcm0oc3RydWN0IHNvY2sgKnNrLCBzdHJ1Y3Qgc2tfYnVmZiAqc2tiKQoreworCXN0cnVjdCBsbGNfY29ubl9zdGF0ZV9ldiAqZXYgPSBsbGNfY29ubl9ldihza2IpOworCisJZXYtPnJlYXNvbiAgID0gZXYtPnN0YXR1czsKKwlldi0+Y2ZtX3ByaW0gPSBMTENfRElTQ19QUklNOworCXJldHVybiAwOworfQorCitpbnQgbGxjX2Nvbm5fYWNfcnN0X2luZChzdHJ1Y3Qgc29jayAqc2ssIHN0cnVjdCBza19idWZmICpza2IpCit7CisJdTggcmVhc29uID0gMDsKKwlpbnQgcmMgPSAxOworCXN0cnVjdCBsbGNfY29ubl9zdGF0ZV9ldiAqZXYgPSBsbGNfY29ubl9ldihza2IpOworCXN0cnVjdCBsbGNfcGR1X3VuICpwZHUgPSBsbGNfcGR1X3VuX2hkcihza2IpOworCXN0cnVjdCBsbGNfc29jayAqbGxjID0gbGxjX3NrKHNrKTsKKworCXN3aXRjaCAoZXYtPnR5cGUpIHsKKwljYXNlIExMQ19DT05OX0VWX1RZUEVfUERVOgorCQlpZiAoTExDX1BEVV9JU19SU1AocGR1KSAmJgorCQkgICAgTExDX1BEVV9UWVBFX0lTX1UocGR1KSAmJgorCQkgICAgTExDX1VfUERVX1JTUChwZHUpID09IExMQ18yX1BEVV9SU1BfRlJNUikgeworCQkJcmVhc29uID0gTExDX1JFU0VUX1JFQVNPTl9MT0NBTDsKKwkJCXJjID0gMDsKKwkJfSBlbHNlIGlmIChMTENfUERVX0lTX0NNRChwZHUpICYmCisJCQkgICBMTENfUERVX1RZUEVfSVNfVShwZHUpICYmCisJCQkgICBMTENfVV9QRFVfQ01EKHBkdSkgPT0gTExDXzJfUERVX0NNRF9TQUJNRSkgeworCQkJcmVhc29uID0gTExDX1JFU0VUX1JFQVNPTl9SRU1PVEU7CisJCQlyYyA9IDA7CisJCX0gZWxzZSB7CisJCQlyZWFzb24gPSAwOworCQkJcmMgID0gMTsKKwkJfQorCQlicmVhazsKKwljYXNlIExMQ19DT05OX0VWX1RZUEVfQUNLX1RNUjoKKwljYXNlIExMQ19DT05OX0VWX1RZUEVfUF9UTVI6CisJY2FzZSBMTENfQ09OTl9FVl9UWVBFX1JFSl9UTVI6CisJY2FzZSBMTENfQ09OTl9FVl9UWVBFX0JVU1lfVE1SOgorCQlpZiAobGxjLT5yZXRyeV9jb3VudCA+IGxsYy0+bjIpIHsKKwkJCXJlYXNvbiA9IExMQ19SRVNFVF9SRUFTT05fTE9DQUw7CisJCQlyYyA9IDA7CisJCX0gZWxzZQorCQkJcmMgPSAxOworCQlicmVhazsKKwl9CisJaWYgKCFyYykgeworCQlldi0+cmVhc29uICAgPSByZWFzb247CisJCWV2LT5pbmRfcHJpbSA9IExMQ19SRVNFVF9QUklNOworCX0KKwlyZXR1cm4gcmM7Cit9CisKK2ludCBsbGNfY29ubl9hY19yc3RfY29uZmlybShzdHJ1Y3Qgc29jayAqc2ssIHN0cnVjdCBza19idWZmICpza2IpCit7CisJc3RydWN0IGxsY19jb25uX3N0YXRlX2V2ICpldiA9IGxsY19jb25uX2V2KHNrYik7CisKKwlldi0+cmVhc29uICAgPSAwOworCWV2LT5jZm1fcHJpbSA9IExMQ19SRVNFVF9QUklNOworCXJldHVybiAwOworfQorCitpbnQgbGxjX2Nvbm5fYWNfY2xlYXJfcmVtb3RlX2J1c3lfaWZfZl9lcV8xKHN0cnVjdCBzb2NrICpzaywKKwkJCQkJICAgIHN0cnVjdCBza19idWZmICpza2IpCit7CisJc3RydWN0IGxsY19wZHVfc24gKnBkdSA9IGxsY19wZHVfc25faGRyKHNrYik7CisKKwlpZiAoTExDX1BEVV9JU19SU1AocGR1KSAmJgorCSAgICBMTENfUERVX1RZUEVfSVNfSShwZHUpICYmCisJICAgIExMQ19JX1BGX0lTXzEocGR1KSAmJiBsbGNfc2soc2spLT5hY2tfcGYpCisJCWxsY19jb25uX2FjX2NsZWFyX3JlbW90ZV9idXN5KHNrLCBza2IpOworCXJldHVybiAwOworfQorCitpbnQgbGxjX2Nvbm5fYWNfc3RvcF9yZWpfdG1yX2lmX2RhdGFfZmxhZ19lcV8yKHN0cnVjdCBzb2NrICpzaywKKwkJCQkJICAgICAgIHN0cnVjdCBza19idWZmICpza2IpCit7CisJc3RydWN0IGxsY19zb2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9CisKK2ludCBsbGNfY29ubl9hY19zZXRfcmV0cnlfY250XzAoc3RydWN0IHNvY2sgKnNrLCBzdHJ1Y3Qgc2tfYnVmZiAqc2tiKQoreworCWxsY19zayhzayktPnJldHJ5X2NvdW50ID0gMDsKKwlyZXR1cm4gMDsKK30KKworaW50IGxsY19jb25uX2FjX2luY19yZXRyeV9jbnRfYnlfMShzdHJ1Y3Qgc29jayAqc2ssIHN0cnVjdCBza19idWZmICpza2IpCit7CisJbGxjX3NrKHNrKS0+cmV0cnlfY291bnQrKzsKKwlyZXR1cm4gMDsKK30KKworaW50IGxsY19jb25uX2FjX3NldF92cl8wKHN0cnVjdCBzb2NrICpzaywgc3RydWN0IHNrX2J1ZmYgKnNrYikKK3sKKwlsbGNfc2soc2spLT52UiA9IDA7CisJcmV0dXJuIDA7Cit9CisKK2ludCBsbGNfY29ubl9hY19pbmNfdnJfYnlfMShzdHJ1Y3Qgc29jayAqc2ssIHN0cnVjdCBza19idWZmICpza2IpCit7CisJbGxjX3NrKHNrKS0+dlIgPSBQRFVfR0VUX05FWFRfVnIobGxjX3NrKHNrKS0+dlIpOworCXJldHVybiAwOworfQorCitpbnQgbGxjX2Nvbm5fYWNfc2V0X3ZzXzAoc3RydWN0IHNvY2sgKnNrLCBzdHJ1Y3Qgc2tfYnVmZiAqc2tiKQoreworCWxsY19zayhzayktPnZTID0gMDsKKwlyZXR1cm4gMDsKK30KKworaW50IGxsY19jb25uX2FjX3NldF92c19ucihzdHJ1Y3Qgc29jayAqc2ssIHN0cnVjdCBza19idWZmICpza2IpCit7CisJbGxjX3NrKHNrKS0+dlMgPSBsbGNfc2soc2spLT5sYXN0X25yOworCXJldHVybiAwOworfQorCitpbnQgbGxjX2Nvbm5fYWNfaW5jX3ZzX2J5XzEoc3RydWN0IHNvY2sgKnNrLCBzdHJ1Y3Qgc2tfYnVmZiAqc2tiKQoreworCWxsY19zayhzayktPnZTID0gKGxsY19zayhzayktPnZTICsgMSkgJSAxMjg7CisJcmV0d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Y19wZHVfc25faGRyKHNrYik7CisKKwlyZXR1cm4gbGxjX2Nvbm5fc3BhY2Uoc2ssIHNrYikgJiYKKwkgICAgICAgTExDX1BEVV9JU19DTUQocGR1KSAmJiBMTENfUERVX1RZUEVfSVNfSShwZHUpICYmCisJICAgICAgIExMQ19JX1BGX0lTXzAocGR1KSAmJgorCSAgICAgICBMTENfSV9HRVRfTlMocGR1KSA9PSBsbGNfc2soc2spLT52UiA/IDAgOiAxOworfQorCitpbnQgbGxjX2Nvbm5fZXZfcnhfaV9jbWRfcGJpdF9zZXRfMShzdHJ1Y3Qgc29jayAqc2ssIHN0cnVjdCBza19idWZmICpza2IpCit7CisJc3RydWN0IGxsY19wZHVfc24gKnBkdSA9IGxsY19wZHVfc25faGRyKHNrYik7CisKKwlyZXR1cm4gbGxjX2Nvbm5fc3BhY2Uoc2ssIHNrYikgJiYKKwkgICAgICAgTExDX1BEVV9JU19DTUQocGR1KSAmJiBMTENfUERVX1RZUEVfSVNfSShwZHUpICYmCisJICAgICAgIExMQ19JX1BGX0lTXzEocGR1KSAmJgorCSAgICAgICBMTENfSV9HRVRfTlMocGR1KSA9PSBsbGNfc2soc2spLT52UiA/IDAgOiAxOworfQorCitpbnQgbGxjX2Nvbm5fZXZfcnhfaV9jbWRfcGJpdF9zZXRfMF91bmV4cGRfbnMoc3RydWN0IHNvY2sgKnNrLAorCQkJCQkgICAgICBzdHJ1Y3Qgc2tfYnVmZiAqc2tiKQoreworCXN0cnVjdCBsbGNfcGR1X3NuICpwZHUgPSBsbGNfcGR1X3NuX2hkcihza2IpOworCXU4IHZyID0gbGxjX3NrKHNrKS0+dlI7CisJdTggbnMgPSBMTENfSV9HRVRfTlMocGR1KTsKKworCXJldHVybiBMTENfUERVX0lTX0NNRChwZHUpICYmIExMQ19QRFVfVFlQRV9JU19JKHBkdSkgJiYKKwkgICAgICAgTExDX0lfUEZfSVNfMChwZHUpICYmIG5zICE9IHZyICYmCisJICAgICAgICFsbGNfdXRpbF9uc19pb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ENfUERVX1RZUEVfSVNfSShwZHUpICYmCisJICAgICAgIExMQ19JX0dFVF9OUyhwZHUpID09IGxsY19zayhzayktPnZSID8gMCA6IDE7Cit9CisKK2ludCBsbGNfY29ubl9ldl9yeF9pX3JzcF9mYml0X3NldF8wX3VuZXhwZF9ucyhzdHJ1Y3Qgc29jayAqc2ssCisJCQkJCSAgICAgIHN0cnVjdCBza19idWZmICpza2IpCit7CisJc3RydWN0IGxsY19wZHVfc24gKnBkdSA9IGxsY19wZHVfc25faGRyKHNrYik7CisJdTggdnIgPSBsbGNfc2soc2spLT52UjsKKwl1OCBucyA9IExMQ19JX0dFVF9OUyhwZHUpOworCisJcmV0dXJuIExMQ19QRFVfSVNfUlNQKHBkdSkgJiYgTExDX1BEVV9UWVBFX0lTX0kocGR1KSAmJgorCSAgICAgICBMTENfSV9QRl9JU18wKHBkdSkgJiYgbnMgIT0gdnIgJiYKKwkgICAgICAgIWxsY191dGlsX25zX2luc2lkZV9yeF93aW5kb3cobnMsIHZyLCBsbGNfc2soc2spLT5ydykgPyAwIDogMTsKK30KKworaW50IGxsY19jb25uX2V2X3J4X2lfcnNwX2ZiaXRfc2V0XzFfdW5leHBkX25zKHN0cnVjdCBzb2NrICpzaywKKwkJCQkJICAgICAgc3RydWN0IHNrX2J1ZmYgKnNrYikKK3sKKwlzdHJ1Y3QgbGxjX3BkdV9zbiAqcGR1ID0gbGxjX3BkdV9zbl9oZHIoc2tiKTsKKwl1OCB2ciA9IGxsY19zayhzayktPnZSOworCXU4IG5zID0gTExDX0lfR0VUX05TKHBkdSk7CisKKwlyZXR1cm4gTExDX1BEVV9JU19SU1AocGR1KSAmJiBMTENfUERVX1RZUEVfSVNfSShwZHUpICYmCisJICAgICAgIExMQ19JX1BGX0lTXzEocGR1KSAmJiBucyAhPSB2ciAmJgorCSAgICAgICAhbGxjX3V0aWxfbnNfaW5zaWRlX3J4X3dpbmRvdyhucywgdnIsIGxsY19zayhzayktPnJ3KSA/IDAgOiAxOworfQorCit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pdF9zZXRfMShzdHJ1Y3Qgc29jayAqc2ssIHN0cnVjdCBza19idWZmICpza2IpCit7CisJc3RydWN0IGxsY19wZHVfc24gKnBkdSA9IGxsY19wZHVfc25faGRyKHNrYik7CisKKwlyZXR1cm4gTExDX1BEVV9JU19DTUQocGR1KSAmJiBMTENfUERVX1RZUEVfSVNfUyhwZHUpICYmCisJICAgICAgIExMQ19TX1BGX0lTXzEocGR1KSAmJgorCSAgICAgICBMTENfU19QRFVfQ01EKHBkdSkgPT0gTExDXzJfUERVX0NNRF9STlIgPyAwIDogMTsKK30KKworaW50IGxsY19jb25uX2V2X3J4X3Jucl9yc3BfZmJpdF9zZXRfMChzdHJ1Y3Qgc29jayAqc2ssIHN0cnVjdCBza19idWZmICpza2IpCit7CisJc3RydWN0IGxsY19wZHVfc24gKnBkdSA9IGxsY19wZHVfc25faGRyKHNrYik7CisKKwlyZXR1cm4gTExDX1BEVV9JU19SU1AocGR1KSAmJiBMTENfUERVX1RZUEVfSVNfUyhwZHUpICYmCisJICAgICAgIExMQ19TX1BGX0lTXzAocGR1KSAmJgorCSAgICAgICBMTENfU19QRFVfUlNQKHBkdSkgPT0gTExDXzJfUERVX1JTUF9STlIgPyAwIDogMTsKK30KKworaW50IGxsY19jb25uX2V2X3J4X3Jucl9yc3BfZmJpdF9zZXRfMShzdHJ1Y3Qgc29jayAqc2ssIHN0cnVjdCBza19idWZmICpza2IpCit7CisJc3RydWN0IGxsY19wZHVfc24gKnBkdSA9IGxsY19wZHVfc25faGRyKHNrYik7CisKKwlyZXR1cm4gTExDX1BEVV9JU19SU1AocGR1KSAmJiBMTENfUERVX1RZUEVfSVNfUyhwZHUpICYmCisJICAgICAgIExMQ19TX1BGX0lTXzEocGR1KSAmJgorCSAgICAgICBMTENfU19QRFVfUlNQKHBkdSkgPT0gTExDXzJfUERVX1JTUF9STlIgPyAwIDogMTsKK30KKworaW50IGxsY19jb25uX2V2X3J4X3JyX2NtZF9wYml0X3NldF8wKHN0cnVjdCBz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OgorCQkJCXJjID0gMDsKKwkJCQlicmVhazsKKwkJCX0KKwl9CisKKwlyZXR1cm4gcmM7Cit9CisKK2ludCBsbGNfY29ubl9ldl9yeF96enpfY21kX3BiaXRfc2V0X3hfaW52YWxfbnIoc3RydWN0IHNvY2sgKnNrLAorCQkJCQkgICAgICAgc3RydWN0IHNrX2J1ZmYgKnNrYikKK3sKKwl1MTYgcmMgPSAxOworCXN0cnVjdCBsbGNfcGR1X3NuICpwZHUgPSBsbGNfcGR1X3NuX2hkcihza2IpOworCXU4IHZzID0gbGxjX3NrKHNrKS0+dlM7CisJdTggbnIgPSBMTENfSV9HRVRfTlIocGR1KTsKKworCWlmIChMTENfUERVX0lTX0NNRChwZHUpICYmCisJICAgIChMTENfUERVX1RZUEVfSVNfSShwZHUpIHx8IExMQ19QRFVfVFlQRV9JU19TKHBkdSkpICYmCisJICAgIG5yICE9IHZzICYmIGxsY191dGlsX25yX2luc2lkZV90eF93aW5kb3coc2ssIG5yKSkgeworCQlkcHJpbnRrKCIlczogbWF0Y2hlZCwgc3RhdGU9JWQsIHZzPSVkLCBucj0lZFxuIiwKKwkJCV9fRlVOQ1RJT05fXywgbGxjX3NrKHNrKS0+c3RhdGUsIHZzLCBucik7CisJCXJjID0gMDsKKwl9CisJcmV0dXJuIHJjOworfQorCitpbnQgbGxjX2Nvbm5fZXZfcnhfenp6X3JzcF9mYml0X3NldF94X2ludmFsX25yKHN0cnVjdCBzb2NrICpzaywKKwkJCQkJICAgICAgIHN0cnVjdCBza19idWZmICpza2IpCit7CisJdTE2IHJjID0gMTsKKwlzdHJ1Y3QgbGxjX3BkdV9zbiAqcGR1ID0gbGxjX3BkdV9zbl9oZHIoc2tiKTsKKwl1OCB2cyA9IGxsY19zayhzayktPnZTOworCXU4IG5yID0gTExDX0lfR0VUX05SKHBkdSk7CisKKwlpZiAoTExDX1BEVV9JU19SU1AocGR1KSAmJgorCSAgICAoTExDX1BEVV9UWVBFX0lTX0kocGR1KSB8fCBMTENfUERV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xpZCBza2IgaW4gYmFja2xvZ1xuIiwgX19GVU5DVElPTl9fKTsKKwkJZ290byBvdXRfa2ZyZWVfc2tiOworCX0KK291dDoKKwlyZXR1cm4gcmM7CitvdXRfa2ZyZWVfc2tiOgorCWtmcmVlX3NrYihza2IpOworCWdvdG8gb3V0OworfQorCisvKioKKyAqICAgICBsbGNfc2tfaW5pdCAtIEluaXRpYWxpemVzIGEgc29ja2V0IHdpdGggZGVmYXVsdCBsbGMgdmFsdWVzLgorICogICAgIEBzazogc29ja2V0IHRvIGluaXRpYWxpemUuCisgKgorICogICAgIEluaXRpYWxpemVzIGEgc29ja2V0IHdpdGggZGVmYXVsdCBsbGMgdmFsdWVzLgorICovCitzdGF0aWMgdm9pZCBsbGNfc2tfaW5pdChzdHJ1Y3Qgc29jayogc2spCit7CisJc3RydWN0IGxsY19zb2NrICpsbGMgPSBsbGNfc2soc2spOworCisJbGxjLT5zdGF0ZSAgICA9IExMQ19DT05OX1NUQVRFX0FETTsKKwlsbGMtPmluY19jbnRyID0gbGxjLT5kZWNfY250ciA9IDI7CisJbGxjLT5kZWNfc3RlcCA9IGxsYy0+Y29ubmVjdF9zdGVwID0gMTsKKworCWluaXRfdGltZXIoJmxsYy0+YWNrX3RpbWVyLnRpbWVyKTsKKwlsbGMtPmFja190aW1lci5leHBpcmUJICAgICAgPSBMTENfQUNLX1RJTUU7CisJbGxjLT5hY2tfdGltZXIudGltZXIuZGF0YSAgICAgPSAodW5zaWduZWQgbG9uZylzazsKKwlsbGMtPmFja190aW1lci50aW1lci5mdW5jdGlvbiA9IGxsY19jb25uX2Fja190bXJfY2I7CisKKwlpbml0X3RpbWVyKCZsbGMtPnBmX2N5Y2xlX3RpbWVyLnRpbWVyKTsKKwlsbGMtPnBmX2N5Y2xlX3RpbWVyLmV4cGlyZQkgICA9IExMQ19QX1RJTUU7CisJbGxjLT5wZl9jeWNsZV90aW1lci50aW1lci5kYXRhICAgICA9ICh1bnNpZ25lZCBsb25nKXNrOworCWxsY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wICpzYXAsIHN0cnVjdCBza19idWZmICpza2IpCit7CisJc3RydWN0IGxsY19zYXBfc3RhdGVfZXYgKmV2ID0gbGxjX3NhcF9ldihza2IpOworCisJcmV0dXJuIGV2LT50eXBlID09IExMQ19TQVBfRVZfVFlQRV9QUklNICYmCisJICAgICAgIGV2LT5wcmltID09IExMQ19EQVRBVU5JVF9QUklNICYmCisJICAgICAgIGV2LT5wcmltX3R5cGUgPT0gTExDX1BSSU1fVFlQRV9SRVEgPyAwIDogMTsKKworfQorCitpbnQgbGxjX3NhcF9ldl94aWRfcmVxKHN0cnVjdCBsbGNfc2FwICpzYXAsIHN0cnVjdCBza19idWZmICpza2IpCit7CisJc3RydWN0IGxsY19zYXBfc3RhdGVfZXYgKmV2ID0gbGxjX3NhcF9ldihza2IpOworCisJcmV0dXJuIGV2LT50eXBlID09IExMQ19TQVBfRVZfVFlQRV9QUklNICYmCisJICAgICAgIGV2LT5wcmltID09IExMQ19YSURfUFJJTSAmJgorCSAgICAgICBldi0+cHJpbV90eXBlID09IExMQ19QUklNX1RZUEVfUkVRID8gMCA6IDE7Cit9CisKK2ludCBsbGNfc2FwX2V2X3J4X3hpZF9jKHN0cnVjdCBsbGNfc2FwICpzYXAsIHN0cnVjdCBza19idWZmICpza2IpCit7CisJc3RydWN0IGxsY19zYXBfc3RhdGVfZXYgKmV2ID0gbGxjX3NhcF9ldihza2IpOworCXN0cnVjdCBsbGNfcGR1X3VuICpwZHUgPSBsbGNfcGR1X3VuX2hkcihza2IpOworCisJcmV0dXJuIGV2LT50eXBlID09IExMQ19TQVBfRVZfVFlQRV9QRFUgJiYgTExDX1BEVV9JU19DTUQocGR1KSAmJgorCSAgICAgICBMTENfUERVX1RZUEVfSVNfVShwZHUpICYmCisJICAgICAgIExMQ19VX1BEVV9DTUQocGR1KSA9PSBMTENfMV9QRFVfQ01EX1hJRCA/IDAgOiAxOworfQorCitpbnQgbGxjX3NhcF9ldl9yeF94aWRfcihzdHJ1Y3QgbGxjX3Nhc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3NrKG9zayktPnBpZCA9PSBwaWQpCisJCQlicmVhazsKKwkJbGVuKys7CisJfQorCWlmIChub2RlKQorCQlnb3RvIGVycjsKKworCWVyciA9IC1FQlVTWTsKKwlpZiAobmxrX3NrKHNrKS0+cGlkKQorCQlnb3RvIGVycjsKKworCWVyciA9IC1FTk9NRU07CisJaWYgKEJJVFNfUEVSX0xPTkcgPiAzMiAmJiB1bmxpa2VseShoYXNoLT5lbnRyaWVzID49IFVJTlRfTUFYKSkKKwkJZ290byBlcnI7CisKKwlpZiAobGVuICYmIG5sX3BpZF9oYXNoX2RpbHV0ZShoYXNoLCBsZW4pKQorCQloZWFkID0gbmxfcGlkX2hhc2hmbihoYXNoLCBwaWQpOworCWhhc2gtPmVudHJpZXMrKzsKKwlubGtfc2soc2spLT5waWQgPSBwaWQ7CisJc2tfYWRkX25vZGUoc2ssIGhlYWQpOworCWVyciA9IDA7CisKK2VycjoKKwluZXRsaW5rX3RhYmxlX3VuZ3JhYigpOworCXJldHVybiBlcnI7Cit9CisKK3N0YXRpYyB2b2lkIG5ldGxpbmtfcmVtb3ZlKHN0cnVjdCBzb2NrICpzaykKK3sKKwluZXRsaW5rX3RhYmxlX2dyYWIoKTsKKwlubF90YWJsZVtzay0+c2tfcHJvdG9jb2xdLmhhc2guZW50cmllcy0tOworCXNrX2RlbF9ub2RlX2luaXQoc2spOworCWlmIChubGtfc2soc2spLT5ncm91cHMpCisJCV9fc2tfZGVsX2JpbmRfbm9kZShzayk7CisJbmV0bGlua190YWJsZV91bmdyYWIoKTsKK30KKworc3RhdGljIHN0cnVjdCBwcm90byBuZXRsaW5rX3Byb3RvID0geworCS5uYW1lCSAgPSAiTkVUTElOSyIsCisJLm93bmVyCSAgPSBUSElTX01PRFVMRSwKKwkub2JqX3NpemUgPSBzaXplb2Yoc3RydWN0IG5ldGxpbmtfc29jayksCit9OworCitzdGF0aWMgaW50IG5ldGxpbmtfY3JlYXRlKHN0cnVjdCBzb2NrZXQgKnNvY2ssIGludCB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CXJldHVybiBza2I7CisKKwlpZiAoc2tiX3NoYXJlZChza2IpKSB7CisJCXN0cnVjdCBza19idWZmICpuc2tiID0gc2tiX2Nsb25lKHNrYiwgYWxsb2NhdGlvbik7CisJCWlmICghbnNrYikKKwkJCXJldHVybiBza2I7CisJCWtmcmVlX3NrYihza2IpOworCQlza2IgPSBuc2tiOworCX0KKworCWlmICghcHNrYl9leHBhbmRfaGVhZChza2IsIDAsIC1kZWx0YSwgYWxsb2NhdGlvbikpCisJCXNrYi0+dHJ1ZXNpemUgLT0gZGVsdGE7CisKKwlyZXR1cm4gc2tiOworfQorCitpbnQgbmV0bGlua191bmljYXN0KHN0cnVjdCBzb2NrICpzc2ssIHN0cnVjdCBza19idWZmICpza2IsIHUzMiBwaWQsIGludCBub25ibG9jaykKK3sKKwlzdHJ1Y3Qgc29jayAqc2s7CisJaW50IGVycjsKKwlsb25nIHRpbWVvOworCisJc2tiID0gbmV0bGlua190cmltKHNrYiwgZ2ZwX2FueSgpKTsKKworCXRpbWVvID0gc29ja19zbmR0aW1lbyhzc2ssIG5vbmJsb2NrKTsKK3JldHJ5OgorCXNrID0gbmV0bGlua19nZXRzb2NrYnlwaWQoc3NrLCBwaWQpOworCWlmIChJU19FUlIoc2spKSB7CisJCWtmcmVlX3NrYihza2IpOworCQlyZXR1cm4gUFRSX0VSUihzayk7CisJfQorCWVyciA9IG5ldGxpbmtfYXR0YWNoc2tiKHNrLCBza2IsIG5vbmJsb2NrLCB0aW1lbyk7CisJaWYgKGVyciA9PSAxKQorCQlnb3RvIHJldHJ5OworCWlmIChlcnIpCisJCXJldHVybiBlcnI7CisKKwlyZXR1cm4gbmV0bGlua19zZW5kc2tiKHNrLCBza2IsIHNzay0+c2tfcHJvdG9jb2wpOworfQorCitzdGF0aWMgX19pbmxpbmVfXyBpbnQgbmV0bGlua19icm9hZGNhc3RfZGVsaXZlcihzdHJ1Y3Qgc29jayAqc2ssIHN0cnVjdCBza19idWZmICpza2IpCit7CisJc3RydWN0I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ZW4gPSAwOworCisJY29waWVkID0gc2tiLT5sZW47CisJaWYgKGxlbiA8IGNvcGllZCkgeworCQltc2ctPm1zZ19mbGFncyB8PSBNU0dfVFJVTkM7CisJCWNvcGllZCA9IGxlbjsKKwl9CisKKwlza2ItPmgucmF3ID0gc2tiLT5kYXRhOworCWVyciA9IHNrYl9jb3B5X2RhdGFncmFtX2lvdmVjKHNrYiwgMCwgbXNnLT5tc2dfaW92LCBjb3BpZWQpOworCisJaWYgKG1zZy0+bXNnX25hbWUpIHsKKwkJc3RydWN0IHNvY2thZGRyX25sICphZGRyID0gKHN0cnVjdCBzb2NrYWRkcl9ubCopbXNnLT5tc2dfbmFtZTsKKwkJYWRkci0+bmxfZmFtaWx5ID0gQUZfTkVUTElOSzsKKwkJYWRkci0+bmxfcGFkICAgID0gMDsKKwkJYWRkci0+bmxfcGlkCT0gTkVUTElOS19DQihza2IpLnBpZDsKKwkJYWRkci0+bmxfZ3JvdXBzCT0gTkVUTElOS19DQihza2IpLmRzdF9ncm91cHM7CisJCW1zZy0+bXNnX25hbWVsZW4gPSBzaXplb2YoKmFkZHIpOworCX0KKworCWlmIChOVUxMID09IHNpb2NiLT5zY20pIHsKKwkJbWVtc2V0KCZzY20sIDAsIHNpemVvZihzY20pKTsKKwkJc2lvY2ItPnNjbSA9ICZzY207CisJfQorCXNpb2NiLT5zY20tPmNyZWRzID0gKk5FVExJTktfQ1JFRFMoc2tiKTsKKwlza2JfZnJlZV9kYXRhZ3JhbShzaywgc2tiKTsKKworCWlmIChubGstPmNiICYmIGF0b21pY19yZWFkKCZzay0+c2tfcm1lbV9hbGxvYykgPD0gc2stPnNrX3JjdmJ1ZiAvIDIpCisJCW5ldGxpbmtfZHVtcChzayk7CisKKwlzY21fcmVjdihzb2NrLCBtc2csIHNpb2NiLT5zY20sIGZsYWdzKTsKKworb3V0OgorCW5ldGxpbmtfcmN2X3dha2Uoc2spOworCXJldHVybiBlcnIgPyA6IGNvcGllZDsKK30KKworc3RhdGljIHZ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1Y3Qgc29jayAqc2s7CisJc3RydWN0IG5ldGxpbmtfc29jayAqbmxrOworCisJY2IgPSBrbWFsbG9jKHNpemVvZigqY2IpLCBHRlBfS0VSTkVMKTsKKwlpZiAoY2IgPT0gTlVMTCkKKwkJcmV0dXJuIC1FTk9CVUZTOworCisJbWVtc2V0KGNiLCAwLCBzaXplb2YoKmNiKSk7CisJY2ItPmR1bXAgPSBkdW1wOworCWNiLT5kb25lID0gZG9uZTsKKwljYi0+bmxoID0gbmxoOworCWF0b21pY19pbmMoJnNrYi0+dXNlcnMpOworCWNiLT5za2IgPSBza2I7CisKKwlzayA9IG5ldGxpbmtfbG9va3VwKHNzay0+c2tfcHJvdG9jb2wsIE5FVExJTktfQ0Ioc2tiKS5waWQpOworCWlmIChzayA9PSBOVUxMKSB7CisJCW5ldGxpbmtfZGVzdHJveV9jYWxsYmFjayhjYik7CisJCXJldHVybiAtRUNPTk5SRUZVU0VEOworCX0KKwlubGsgPSBubGtfc2soc2spOworCS8qIEEgZHVtcCBpcyBpbiBwcm9ncmVzcy4uLiAqLworCXNwaW5fbG9jaygmbmxrLT5jYl9sb2NrKTsKKwlpZiAobmxrLT5jYikgeworCQlzcGluX3VubG9jaygmbmxrLT5jYl9sb2NrKTsKKwkJbmV0bGlua19kZXN0cm95X2NhbGxiYWNrKGNiKTsKKwkJc29ja19wdXQoc2spOworCQlyZXR1cm4gLUVCVVNZOworCX0KKwlubGstPmNiID0gY2I7CisJc29ja19ob2xkKHNrKTsKKwlzcGluX3VubG9jaygmbmxrLT5jYl9sb2NrKTsKKworCW5ldGxpbmtfZHVtcChzayk7CisJc29ja19wdXQoc2spOworCXJldHVybiAwOworfQorCit2b2lkIG5ldGxpbmtfYWNrKHN0cnVjdCBza19idWZmICppbl9za2IsIHN0cnVjdCBubG1zZ2hkciAqbmxoLCBpbnQgZXJyKQoreworCXN0cnVjdCBza19idWZmICpza2I7CisJc3RydWN0IG5sbXNnaGRyICpyZXA7CisJc3RydWN0IG5sbXN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OgorCXNwaW5fdW5sb2NrX2JoKCZucl9saXN0X2xvY2spOworCXJldHVybiBzOworfQorCisvKgorICoJRmluZCBhIGNvbm5lY3RlZCBORVQvUk9NIHNvY2tldCBnaXZlbiB0aGVpciBjaXJjdWl0IElEcy4KKyAqLworc3RhdGljIHN0cnVjdCBzb2NrICpucl9maW5kX3BlZXIodW5zaWduZWQgY2hhciBpbmRleCwgdW5zaWduZWQgY2hhciBpZCwKKwlheDI1X2FkZHJlc3MgKmRlc3QpCit7CisJc3RydWN0IHNvY2sgKnM7CisJc3RydWN0IGhsaXN0X25vZGUgKm5vZGU7CisKKwlzcGluX2xvY2tfYmgoJm5yX2xpc3RfbG9jayk7CisJc2tfZm9yX2VhY2gocywgbm9kZSwgJm5yX2xpc3QpIHsKKwkJc3RydWN0IG5yX3NvY2sgKm5yID0gbnJfc2socyk7CisJCQorCQlpZiAobnItPnlvdXJfaW5kZXggPT0gaW5kZXggJiYgbnItPnlvdXJfaWQgPT0gaWQgJiYKKwkJICAgICFheDI1Y21wKCZuci0+ZGVzdF9hZGRyLCBkZXN0KSkgeworCQkgICAgCWJoX2xvY2tfc29jayhzKTsKKwkJCWdvdG8gZm91bmQ7CisJCX0KKwl9CisJcyA9IE5VTEw7Citmb3VuZDoKKwlzcGluX3VubG9ja19iaCgmbnJfbGlzdF9sb2NrKTsKKwlyZXR1cm4gczsKK30KKworLyoKKyAqCUZpbmQgbmV4dCBmcmVlIGNpcmN1aXQgSUQuCisgKi8KK3N0YXRpYyB1bnNpZ25lZCBzaG9ydCBucl9maW5kX25leHRfY2lyY3VpdCh2b2lkKQoreworCXVuc2lnbmVkIHNob3J0IGlkID0gY2lyY3VpdDsKKwl1bnNpZ25lZCBjaGFyIGksIGo7CisJc3RydWN0IHNvY2sgKnNrOworCisJZm9yICg7OykgeworCQlpID0gaWQgLyAyNTY7CisJCWogPSBpZCAlIDI1NjsKKworCQlpZiAoaSAhPSAwICYmIGogIT0gMCkgeworCQkJaWYgKChzaz1ucl9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ZXR1cm4gLUVOT1BST1RPT1BUOworCX0KK30KKworc3RhdGljIGludCBucl9nZXRzb2Nrb3B0KHN0cnVjdCBzb2NrZXQgKnNvY2ssIGludCBsZXZlbCwgaW50IG9wdG5hbWUsCisJY2hhciBfX3VzZXIgKm9wdHZhbCwgaW50IF9fdXNlciAqb3B0bGVuKQoreworCXN0cnVjdCBzb2NrICpzayA9IHNvY2stPnNrOworCXN0cnVjdCBucl9zb2NrICpuciA9IG5yX3NrKHNrKTsKKwlpbnQgdmFsID0gMDsKKwlpbnQgbGVuOyAKKworCWlmIChsZXZlbCAhPSBTT0xfTkVUUk9NKQorCQlyZXR1cm4gLUVOT1BST1RPT1BUOworCQorCWlmIChnZXRfdXNlcihsZW4sIG9wdGxlbikpCisJCXJldHVybiAtRUZBVUxUOworCisJaWYgKGxlbiA8IDApCisJCXJldHVybiAtRUlOVkFMOworCQkKKwlzd2l0Y2ggKG9wdG5hbWUpIHsKKwljYXNlIE5FVFJPTV9UMToKKwkJdmFsID0gbnItPnQxIC8gSFo7CisJCWJyZWFrOworCisJY2FzZSBORVRST01fVDI6CisJCXZhbCA9IG5yLT50MiAvIEhaOworCQlicmVhazsKKworCWNhc2UgTkVUUk9NX04yOgorCQl2YWwgPSBuci0+bjI7CisJCWJyZWFrOworCisJY2FzZSBORVRST01fVDQ6CisJCXZhbCA9IG5yLT50NCAvIEhaOworCQlicmVhazsKKworCWNhc2UgTkVUUk9NX0lETEU6CisJCXZhbCA9IG5yLT5pZGxlIC8gKDYwICogSFopOworCQlicmVhazsKKworCWRlZmF1bHQ6CisJCXJldHVybiAtRU5PUFJPVE9PUFQ7CisJfQorCisJbGVuID0gbWluX3QodW5zaWduZWQgaW50LCBsZW4sIHNpemVvZihpbnQpKTsKKworCWlmIChwdXRfdXNlcihsZW4sIG9wdGxlbikpCisJCXJldHVybiAtRUZBVUxUOworCisJcmV0dXJuIGNvcHlfdG9fdXNlcihvcHR2YWwsICZ2YWwsIGxlbikgPyAtRUZBVUxUIDogMDsKK30KKworc3RhdGljIGludCBucl9saXN0ZW4oc3RydWN0IHNvY2tldCAqc29jaywgaW50IGJhY2tsb2cpCit7CisJc3RydWN0IHNvY2sgKnNrID0gc29jay0+c2s7CisKKwlsb2NrX3NvY2soc2spOworCWlmIChzay0+c2tfc3RhdGUgIT0gVENQX0xJU1RFTikgeworCQltZW1zZXQoJm5yX3NrKHNrKS0+dXNlcl9hZGRyLCAwLCBBWDI1X0FERFJfTEVOKTsKKwkJc2stPnNrX21heF9hY2tfYmFja2xvZyA9IGJhY2tsb2c7CisJCXNrLT5za19zdGF0ZSAgICAgICAgICAgPSBUQ1BfTElTVEVOOworCQlyZWxlYXNlX3NvY2soc2spOworCQlyZXR1cm4gMDsKKwl9CisJcmVsZWFzZV9zb2NrKHNrKTsKKworCXJldHVybiAtRU9QTk9UU1VQUDsKK30KKworc3RhdGljIHN0cnVjdCBwcm90byBucl9wcm90byA9IHsKKwkubmFtZQkgID0gIk5FVFJPTSIsCisJLm93bmVyCSAgPSBUSElTX01PRFVMRSwKKwkub2JqX3NpemUgPSBzaXplb2Yoc3RydWN0IG5yX3NvY2spLAorfTsKKworc3RhdGljIGludCBucl9jcmVhdGUoc3RydWN0IHNvY2tldCAqc29jaywgaW50IHByb3RvY29sKQoreworCXN0cnVjdCBzb2NrICpzazsKKwlzdHJ1Y3QgbnJfc29jayAqbnI7CisKKwlpZiAoc29jay0+dHlwZSAhPSBTT0NLX1NFUVBBQ0tFVCB8fCBwcm90b2NvbCAhPSAwKQorCQlyZXR1cm4gLUVTT0NLVE5PU1VQUE9SVDsKKworCWlmICgoc2sgPSBza19hbGxvYyhQRl9ORVRST00sIEdGUF9BVE9NSUMsICZucl9wcm90bywgMSkpID09IE5VTEwpCisJCXJldHVybiAtRU5PTUVNOworCisJbnIgPSBucl9zayhzayk7CisKKwlzb2NrX2luaXRfZGF0YShzb2NrLCBzayk7CisKKwlzb2NrLT5vcHMgICAgPSAmbnJfcHJvdG9fb3BzOworCXNrLT5za19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0gbnJfc2soc2spOworCisJc29ja19pbml0X2RhdGEoTlVMTCwgc2spOworCisJc2stPnNrX3R5cGUgICAgID0gb3NrLT5za190eXBlOworCXNrLT5za19zb2NrZXQgICA9IG9zay0+c2tfc29ja2V0OworCXNrLT5za19wcmlvcml0eSA9IG9zay0+c2tfcHJpb3JpdHk7CisJc2stPnNrX3Byb3RvY29sID0gb3NrLT5za19wcm90b2NvbDsKKwlzay0+c2tfcmN2YnVmICAgPSBvc2stPnNrX3JjdmJ1ZjsKKwlzay0+c2tfc25kYnVmICAgPSBvc2stPnNrX3NuZGJ1ZjsKKwlzay0+c2tfc3RhdGUgICAgPSBUQ1BfRVNUQUJMSVNIRUQ7CisJc2stPnNrX3NsZWVwICAgID0gb3NrLT5za19zbGVlcDsKKworCWlmIChzb2NrX2ZsYWcob3NrLCBTT0NLX1pBUFBFRCkpCisJCXNvY2tfc2V0X2ZsYWcoc2ssIFNPQ0tfWkFQUEVEKTsKKworCWlmIChzb2NrX2ZsYWcob3NrLCBTT0NLX0RCRykpCisJCXNvY2tfc2V0X2ZsYWcoc2ssIFNPQ0tfREJHKTsKKworCXNrYl9xdWV1ZV9oZWFkX2luaXQoJm5yLT5hY2tfcXVldWUpOworCXNrYl9xdWV1ZV9oZWFkX2luaXQoJm5yLT5yZXNlcV9xdWV1ZSk7CisJc2tiX3F1ZXVlX2hlYWRfaW5pdCgmbnItPmZyYWdfcXVldWUpOworCisJbnJfaW5pdF90aW1lcnMoc2spOworCisJb25yID0gbnJfc2sob3NrKTsKKworCW5yLT50MSAgICAgID0gb25yLT50MTsKKwluci0+dDIgICAgICA9IG9uci0+dDI7CisJbnItPm4yICAgICAgPSBvbnItPm4yOworCW5yLT50NCAgICAgID0gb25yLT50NDsKKwluci0+aWRsZSAgICA9IG9uci0+aWRsZTsKKwluci0+d2luZG93ICA9IG9uci0+d2luZG93OworCisJbnItPmRldmljZSAgPSBvbnItPmRldmljZTsKKwluci0+YnBxZXh0ICA9IG9uci0+YnBxZXh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ICAgICAgICAgICA9IG1ha2U7CisJbWFrZS0+c2tfc3RhdGUJICAgID0gVENQX0VTVEFCTElTSEVEOworCisJLyogRmlsbCBpbiBoaXMgY2lyY3VpdCBkZXRhaWxzICovCisJbnJfbWFrZSA9IG5yX3NrKG1ha2UpOworCW5yX21ha2UtPnNvdXJjZV9hZGRyID0gKmRlc3Q7CisJbnJfbWFrZS0+ZGVzdF9hZGRyICAgPSAqc3JjOworCW5yX21ha2UtPnVzZXJfYWRkciAgID0gKnVzZXI7CisKKwlucl9tYWtlLT55b3VyX2luZGV4ICA9IGNpcmN1aXRfaW5kZXg7CisJbnJfbWFrZS0+eW91cl9pZCAgICAgPSBjaXJjdWl0X2lkOworCisJYmhfdW5sb2NrX3NvY2soc2spOworCWNpcmN1aXQgPSBucl9maW5kX25leHRfY2lyY3VpdCgpOworCWJoX2xvY2tfc29jayhzayk7CisKKwlucl9tYWtlLT5teV9pbmRleCAgICA9IGNpcmN1aXQgLyAyNTY7CisJbnJfbWFrZS0+bXlfaWQgICAgICAgPSBjaXJjdWl0ICUgMjU2OworCisJY2lyY3VpdCsrOworCisJLyogV2luZG93IG5lZ290aWF0aW9uICovCisJaWYgKHdpbmRvdyA8IG5yX21ha2UtPndpbmRvdykKKwkJbnJfbWFrZS0+d2luZG93ID0gd2luZG93OworCisJLyogTDQgdGltZW91dCBuZWdvdGlhdGlvbiAqLworCWlmIChza2ItPmxlbiA9PSAzNykgeworCQl0aW1lb3V0ID0gc2tiLT5kYXRhWzM2XSAqIDI1NiArIHNrYi0+ZGF0YVszNV07CisJCWlmICh0aW1lb3V0ICogSFogPCBucl9tYWtlLT50MSkKKwkJCW5yX21ha2UtPnQxID0gdGltZW91dCAqIEhaOworCQlucl9tYWtlLT5icHFleHQgPSAxOworCX0gZWxzZSB7CisJCW5yX21ha2UtPmJwcWV4dCA9IDA7CisJfQorCisJbnJfd3JpdGVfaW50ZXJuYWwobWFrZSwgTlJfQ09OTkFDSyk7CisKKwlucl9tYWtlLT5j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BBQ0tFVF9IT1NUOworCisJaXBfcmN2KHNrYiwgc2tiLT5kZXYsIE5VTEwpOworCisJcmV0dXJuIDE7Cit9CisKKworc3RhdGljIGludCBucl9yZWJ1aWxkX2hlYWRlcihzdHJ1Y3Qgc2tfYnVmZiAqc2tiKQoreworCXN0cnVjdCBuZXRfZGV2aWNlICpkZXYgPSBza2ItPmRldjsKKwlzdHJ1Y3QgbmV0X2RldmljZV9zdGF0cyAqc3RhdHMgPSBuZXRkZXZfcHJpdihkZXYpOworCXN0cnVjdCBza19idWZmICpza2JuOworCXVuc2lnbmVkIGNoYXIgKmJwID0gc2tiLT5kYXRhOworCWludCBsZW47CisKKwlpZiAoYXJwX2ZpbmQoYnAgKyA3LCBza2IpKSB7CisJCXJldHVybiAxOworCX0KKworCWJwWzZdICY9IH5BWDI1X0NCSVQ7CisJYnBbNl0gJj0gfkFYMjVfRUJJVDsKKwlicFs2XSB8PSBBWDI1X1NTU0lEX1NQQVJFOworCWJwICAgICs9IEFYMjVfQUREUl9MRU47CisKKwlicFs2XSAmPSB+QVgyNV9DQklUOworCWJwWzZdIHw9IEFYMjVfRUJJVDsKKwlicFs2XSB8PSBBWDI1X1NTU0lEX1NQQVJFOworCisJaWYgKChza2JuID0gc2tiX2Nsb25lKHNrYiwgR0ZQX0FUT01JQykpID09IE5VTEwpIHsKKwkJa2ZyZWVfc2tiKHNrYik7CisJCXJldHVybiAxOworCX0KKworCWlmIChza2ItPnNrICE9IE5VTEwpCisJCXNrYl9zZXRfb3duZXJfdyhza2JuLCBza2ItPnNrKTsKKworCWtmcmVlX3NrYihza2IpOworCisJbGVuID0gc2tibi0+bGVuOworCisJaWYgKCFucl9yb3V0ZV9mcmFtZShza2JuLCBOVUxMKSkgeworCQlrZnJlZV9za2Ioc2tibik7CisJCXN0YXRzLT50eF9lcnJvcnMrKzsKKwl9CisKKwlzdGF0cy0+dHhfcGFja2V0cysrOworCXN0YXRzLT50eF9ieXRlcyArPSBsZW47CisKKwlyZXR1cm4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za2JfZGVxdWV1ZSgmbnItPmZyYWdfcXVldWUpKSAhPSBOVUxMKSB7CisJCQltZW1jcHkoc2tiX3B1dChza2JuLCBza2JvLT5sZW4pLCBza2JvLT5kYXRhLCBza2JvLT5sZW4pOworCQkJa2ZyZWVfc2tiKHNrYm8pOworCQl9CisKKwkJbnItPmZyYWdsZW4gPSAwOworCX0KKworCXJldHVybiBzb2NrX3F1ZXVlX3Jjdl9za2Ioc2ssIHNrYm4pOworfQorCisvKgorICogU3RhdGUgbWFjaGluZSBmb3Igc3RhdGUgMSwgQXdhaXRpbmcgQ29ubmVjdGlvbiBTdGF0ZS4KKyAqIFRoZSBoYW5kbGluZyBvZiB0aGUgdGltZXIocykgaXMgaW4gZmlsZSBucl90aW1lci5jLgorICogSGFuZGxpbmcgb2Ygc3RhdGUgMCBhbmQgY29ubmVjdGlvbiByZWxlYXNlIGlzIGluIG5ldHJvbS5jLgorICovCitzdGF0aWMgaW50IG5yX3N0YXRlMV9tYWNoaW5lKHN0cnVjdCBzb2NrICpzaywgc3RydWN0IHNrX2J1ZmYgKnNrYiwKKwlpbnQgZnJhbWV0eXBlKQoreworCXN3aXRjaCAoZnJhbWV0eXBlKSB7CisJY2FzZSBOUl9DT05OQUNLOiB7CisJCXN0cnVjdCBucl9zb2NrICpuciA9IG5yX3NrKHNrKTsKKworCQlucl9zdG9wX3QxdGltZXIoc2spOworCQlucl9zdGFydF9pZGxldGltZXIoc2spOworCQluci0+eW91cl9pbmRleCA9IHNrYi0+ZGF0YVsxN107CisJCW5yLT55b3VyX2lkICAgID0gc2tiLT5kYXRhWzE4XTsKKwkJbnItPnZzCSAgICAgICA9IDA7CisJCW5yLT52YQkgICAgICAgPSAwOworCQluci0+dnIJICAgICAgID0gMDsKKwkJbnItPnZsCSAgICAgICA9IDA7CisJCW5yLT5zdGF0ZSAgICAgID0gTlJfU1RBVEVfMzsKKwkJbnItPm4yY291bnQgICAgPSAwOworCQluci0+d2luZG93ICAgICA9IHNrYi0+ZGF0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wlza2JuLT5kYXRhWzNdID0gbnItPnZyOworCisJaWYgKG5yLT5jb25kaXRpb24gJiBOUl9DT05EX09XTl9SWF9CVVNZKQorCQlza2JuLT5kYXRhWzRdIHw9IE5SX0NIT0tFX0ZMQUc7CisKKwlucl90cmFuc21pdF9idWZmZXIoc2ssIHNrYm4pOworCisJbnItPmNvbmRpdGlvbiAmPSB+TlJfQ09ORF9BQ0tfUEVORElORzsKKwluci0+dmwgICAgICAgICA9IG5yLT52cjsKKworCW5yX3N0b3BfdDF0aW1lcihzayk7Cit9CisKK3ZvaWQgbnJfa2ljayhzdHJ1Y3Qgc29jayAqc2spCit7CisJc3RydWN0IG5yX3NvY2sgKm5yID0gbnJfc2soc2spOworCXN0cnVjdCBza19idWZmICpza2IsICpza2JuOworCXVuc2lnbmVkIHNob3J0IHN0YXJ0LCBlbmQ7CisKKwlpZiAobnItPnN0YXRlICE9IE5SX1NUQVRFXzMpCisJCXJldHVybjsKKworCWlmIChuci0+Y29uZGl0aW9uICYgTlJfQ09ORF9QRUVSX1JYX0JVU1kpCisJCXJldHVybjsKKworCWlmICghc2tiX3BlZWsoJnNrLT5za193cml0ZV9xdWV1ZSkpCisJCXJldHVybjsKKworCXN0YXJ0ID0gKHNrYl9wZWVrKCZuci0+YWNrX3F1ZXVlKSA9PSBOVUxMKSA/IG5yLT52YSA6IG5yLT52czsKKwllbmQgICA9IChuci0+dmEgKyBuci0+d2luZG93KSAlIE5SX01PRFVMVVM7CisKKwlpZiAoc3RhcnQgPT0gZW5kKQorCQlyZXR1cm47CisKKwluci0+dnMgPSBzdGFydDsKKworCS8qCisJICogVHJhbnNtaXQgZGF0YSB1bnRpbCBlaXRoZXIgd2UncmUgb3V0IG9mIGRhdGEgdG8gc2VuZCBvcgorCSAqIHRoZSB3aW5kb3cgaXMgZnVsbC4KKwkgKi8KKworCS8qCisJICogRGVxdWV1ZSB0aGUgZnJhbWUgYW5kIGNvcHkgaXQuCisJICovCisJc2tiID0gc2tiX2RlcXVldW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pZGxldGltZXIoc2spOworCW5yX3N0YXJ0X3QxdGltZXIoc2spOworfQorCisvKgorICogTmV2ZXIgc2VuZCBhIE5BSyB3aGVuIHdlIGFyZSBDSE9LRWQuCisgKi8KK3ZvaWQgbnJfZW5xdWlyeV9yZXNwb25zZShzdHJ1Y3Qgc29jayAqc2spCit7CisJc3RydWN0IG5yX3NvY2sgKm5yID0gbnJfc2soc2spOworCWludCBmcmFtZXR5cGUgPSBOUl9JTkZPQUNLOworCisJaWYgKG5yLT5jb25kaXRpb24gJiBOUl9DT05EX09XTl9SWF9CVVNZKSB7CisJCWZyYW1ldHlwZSB8PSBOUl9DSE9LRV9GTEFHOworCX0gZWxzZSB7CisJCWlmIChza2JfcGVlaygmbnItPnJlc2VxX3F1ZXVlKSAhPSBOVUxMKQorCQkJZnJhbWV0eXBlIHw9IE5SX05BS19GTEFHOworCX0KKworCW5yX3dyaXRlX2ludGVybmFsKHNrLCBmcmFtZXR5cGUpOworCisJbnItPnZsICAgICAgICAgPSBuci0+dnI7CisJbnItPmNvbmRpdGlvbiAmPSB+TlJfQ09ORF9BQ0tfUEVORElORzsKK30KKwordm9pZCBucl9jaGVja19pZnJhbWVzX2Fja2VkKHN0cnVjdCBzb2NrICpzaywgdW5zaWduZWQgc2hvcnQgbnIpCit7CisJc3RydWN0IG5yX3NvY2sgKm5yb20gPSBucl9zayhzayk7CisKKwlpZiAobnJvbS0+dnMgPT0gbnIpIHsKKwkJbnJfZnJhbWVzX2Fja2VkKHNrLCBucik7CisJCW5yX3N0b3BfdDF0aW1lcihzayk7CisJCW5yb20tPm4yY291bnQgPSAwOworCX0gZWxzZSB7CisJCWlmIChucm9tLT52YSAhPSBucikgeworCQkJbnJfZnJhbWVzX2Fja2VkKHNrLCBucik7CisJCQlucl9zdGFydF90MXRpbWVyKHNrKTsKKwkJfQorCX0KK30KZGlmZiAtLWdpdCBhL25ldC9uZXRyb20vbnJfcm91dGUuYyBiL25ldC9uZXRyb20vbnJfcm91dGUuYwpuZ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azsKKwkJY2FzZSBORVRST01fTkVJR0g6CisJCQlyZXQgPSBucl9kZWxfbmVpZ2goJm5yX3JvdXRlLmNhbGxzaWduLAorCQkJCWRldiwgbnJfcm91dGUucXVhbGl0eSk7CisJCQlicmVhazsKKwkJZGVmYXVsdDoKKwkJCXJldCA9IC1FSU5WQUw7CisJCX0KKwkJZGV2X3B1dChkZXYpOworCQlyZXR1cm4gcmV0OworCisJY2FzZSBTSU9DTlJERUNPQlM6CisJCXJldHVybiBucl9kZWNfb2JzKCk7CisKKwlkZWZhdWx0OgorCQlyZXR1cm4gLUVJTlZBTDsKKwl9CisKKwlyZXR1cm4gMDsKK30KKworLyoKKyAqIAlBIGxldmVsIDIgbGluayBoYXMgdGltZWQgb3V0LCB0aGVyZWZvcmUgaXQgYXBwZWFycyB0byBiZSBhIHBvb3IgbGluaywKKyAqCXRoZW4gZG9uJ3QgdXNlIHRoYXQgbmVpZ2hib3VyIHVudGlsIGl0IGlzIHJlc2V0LgorICovCit2b2lkIG5yX2xpbmtfZmFpbGVkKGF4MjVfY2IgKmF4MjUsIGludCByZWFzb24pCit7CisJc3RydWN0IG5yX25laWdoICpzLCAqbnJfbmVpZ2ggPSBOVUxMOworCXN0cnVjdCBobGlzdF9ub2RlICpub2RlOworCXN0cnVjdCBucl9ub2RlICAqbnJfbm9kZSA9IE5VTEw7CisKKwlzcGluX2xvY2tfYmgoJm5yX25laWdoX2xpc3RfbG9jayk7CisJbnJfbmVpZ2hfZm9yX2VhY2gocywgbm9kZSwgJm5yX25laWdoX2xpc3QpCisJCWlmIChzLT5heDI1ID09IGF4MjUpIHsKKwkJCW5yX25laWdoX2hvbGQocyk7CisJCQlucl9uZWlnaCA9IHM7CisJCQlicmVhazsKKwkJfQorCXNwaW5fdW5sb2NrX2JoKCZucl9uZWlnaF9saXN0X2xvY2spOworCisJaWYgKG5yX25laWdoID09IE5VTEwpIHJldHVybjsKKworCW5yX25laWdoLT5heDI1ID0gTlVMTDsKKwlheDI1X2NiX3B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orCWJoX3VubG9ja19zb2NrKHNrKTsKK30KKworc3RhdGljIHZvaWQgbnJfdDR0aW1lcl9leHBpcnkodW5zaWduZWQgbG9uZyBwYXJhbSkKK3sKKwlzdHJ1Y3Qgc29jayAqc2sgPSAoc3RydWN0IHNvY2sgKilwYXJhbTsKKworCWJoX2xvY2tfc29jayhzayk7CisJbnJfc2soc2spLT5jb25kaXRpb24gJj0gfk5SX0NPTkRfUEVFUl9SWF9CVVNZOworCWJoX3VubG9ja19zb2NrKHNrKTsKK30KKworc3RhdGljIHZvaWQgbnJfaWRsZXRpbWVyX2V4cGlyeSh1bnNpZ25lZCBsb25nIHBhcmFtKQoreworCXN0cnVjdCBzb2NrICpzayA9IChzdHJ1Y3Qgc29jayAqKXBhcmFtOworCXN0cnVjdCBucl9zb2NrICpuciA9IG5yX3NrKHNrKTsKKworCWJoX2xvY2tfc29jayhzayk7CisKKwlucl9jbGVhcl9xdWV1ZXMoc2spOworCisJbnItPm4yY291bnQgPSAwOworCW5yX3dyaXRlX2ludGVybmFsKHNrLCBOUl9ESVNDUkVRKTsKKwluci0+c3RhdGUgPSBOUl9TVEFURV8yOworCisJbnJfc3RhcnRfdDF0aW1lcihzayk7CisJbnJfc3RvcF90MnRpbWVyKHNrKTsKKwlucl9zdG9wX3Q0dGltZXIoc2spOworCisJc2stPnNrX3N0YXRlICAgICA9IFRDUF9DTE9TRTsKKwlzay0+c2tfZXJyICAgICAgID0gMDsKKwlzay0+c2tfc2h1dGRvd24gfD0gU0VORF9TSFVURE9XTjsKKworCWlmICghc29ja19mbGFnKHNrLCBTT0NLX0RFQUQpKSB7CisJCXNrLT5za19zdGF0ZV9jaGFuZ2Uoc2spOworCQlzb2NrX3NldF9mbGFnKHNrLCBTT0NLX0RFQUQpOworCX0KKwliaF91bmxvY2tfc29jayhzayk7Cit9CisKK3N0YXRpYyB2b2lkIG5yX3QxdGltZXJfZXhwaXJ5KHVuc2lnbmVkIGxvbmcgcGFyYW0pCit7CisJc3RydWN0IH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W5fdDFbXSAgICAgID0gezUgKiBIWn07CitzdGF0aWMgaW50IG1heF90MVtdICAgICAgPSB7NjAwICogSFp9Oworc3RhdGljIGludCBtaW5fbjJbXSAgICAgID0gezJ9LCBtYXhfbjJbXSAgICAgID0gezEyN307CitzdGF0aWMgaW50IG1pbl90MltdICAgICAgPSB7MSAqIEhafTsKK3N0YXRpYyBpbnQgbWF4X3QyW10gICAgICA9IHs2MCAqIEhafTsKK3N0YXRpYyBpbnQgbWluX3Q0W10gICAgICA9IHsxICogSFp9Oworc3RhdGljIGludCBtYXhfdDRbXSAgICAgID0gezEwMDAgKiBIWn07CitzdGF0aWMgaW50IG1pbl93aW5kb3dbXSAgPSB7MX0sIG1heF93aW5kb3dbXSAgPSB7MTI3fTsKK3N0YXRpYyBpbnQgbWluX2lkbGVbXSAgICA9IHswICogSFp9Oworc3RhdGljIGludCBtYXhfaWRsZVtdICAgID0gezY1NTM1ICogSFp9Oworc3RhdGljIGludCBtaW5fcm91dGVbXSAgID0gezB9LCBtYXhfcm91dGVbXSAgID0gezF9Oworc3RhdGljIGludCBtaW5fZmFpbHNbXSAgID0gezF9LCBtYXhfZmFpbHNbXSAgID0gezEwfTsKKworc3RhdGljIHN0cnVjdCBjdGxfdGFibGVfaGVhZGVyICpucl90YWJsZV9oZWFkZXI7CisKK3N0YXRpYyBjdGxfdGFibGUgbnJfdGFibGVbXSA9IHsKKyAgICAgICAgeworCQkuY3RsX25hbWUJPSBORVRfTkVUUk9NX0RFRkFVTFRfUEFUSF9RVUFMSVRZLAorCQkucHJvY25hbWUJPSAiZGVmYXVsdF9wYXRoX3F1YWxpdHkiLAorCQkuZGF0YQkJPSAmc3lzY3RsX25ldHJvbV9kZWZhdWx0X3BhdGhfcXVhbGl0eSwKKwkJLm1heGxlbgkJPSBzaXplb2YoaW50KSwKKwkJLm1vZGUJCT0gMDY0NCwKKwkJLnByb2NfaGFuZGxlcgk9ICZwcm9jX2RvaW50dmVjX21pbm1heCwKKwkJLnN0cmF0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2IsIExMX1JFU0VSVkVEX1NQQUNFKGRldikpOworCXNrYi0+bmgucmF3ID0gc2tiLT5kYXRhOworCisJaWYgKGRldi0+aGFyZF9oZWFkZXIpIHsKKwkJaW50IHJlczsKKwkJZXJyID0gLUVJTlZBTDsKKwkJcmVzID0gZGV2LT5oYXJkX2hlYWRlcihza2IsIGRldiwgbnRvaHMocHJvdG8pLCBhZGRyLCBOVUxMLCBsZW4pOworCQlpZiAoc29jay0+dHlwZSAhPSBTT0NLX0RHUkFNKSB7CisJCQlza2ItPnRhaWwgPSBza2ItPmRhdGE7CisJCQlza2ItPmxlbiA9IDA7CisJCX0gZWxzZSBpZiAocmVzIDwgMCkKKwkJCWdvdG8gb3V0X2ZyZWU7CisJfQorCisJLyogUmV0dXJucyAtRUZBVUxUIG9uIGVycm9yICovCisJZXJyID0gbWVtY3B5X2Zyb21pb3ZlYyhza2JfcHV0KHNrYixsZW4pLCBtc2ctPm1zZ19pb3YsIGxlbik7CisJaWYgKGVycikKKwkJZ290byBvdXRfZnJlZTsKKworCXNrYi0+cHJvdG9jb2wgPSBwcm90bzsKKwlza2ItPmRldiA9IGRldjsKKwlza2ItPnByaW9yaXR5ID0gc2stPnNrX3ByaW9yaXR5OworCisJZXJyID0gLUVORVRET1dOOworCWlmICghKGRldi0+ZmxhZ3MgJiBJRkZfVVApKQorCQlnb3RvIG91dF9mcmVlOworCisJLyoKKwkgKglOb3cgc2VuZCBpdAorCSAqLworCisJZXJyID0gZGV2X3F1ZXVlX3htaXQoc2tiKTsKKwlpZiAoZXJyID4gMCAmJiAoZXJyID0gbmV0X3htaXRfZXJybm8oZXJyKSkgIT0gMCkKKwkJZ290byBvdXRfdW5sb2NrOworCisJZGV2X3B1dChkZXYpOworCisJcmV0dXJuKGxlbik7CisKK291dF9mcmVlOgorCWtmcmVlX3NrYihza2IpOworb3V0X3VubG9jazoKKwlpZiAoZGV2KQorCQlkZXZfcHV0KGRldik7CitvdXQ6CisJcmV0dXJuIGVycjsKK30KKwor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sIDEpOworCX0KKyNlbmRpZgorCisJLyoKKwkgKglOb3cgdGhlIHNvY2tldCBpcyBkZWFkLiBObyBtb3JlIGlucHV0IHdpbGwgYXBwZWFyLgorCSAqLworCisJc29ja19vcnBoYW4oc2spOworCXNvY2stPnNrID0gTlVMTDsKKworCS8qIFB1cmdlIHF1ZXVlcyAqLworCisJc2tiX3F1ZXVlX3B1cmdlKCZzay0+c2tfcmVjZWl2ZV9xdWV1ZSk7CisKKwlzb2NrX3B1dChzayk7CisJcmV0dXJuIDA7Cit9CisKKy8qCisgKglBdHRhY2ggYSBwYWNrZXQgaG9vay4KKyAqLworCitzdGF0aWMgaW50IHBhY2tldF9kb19iaW5kKHN0cnVjdCBzb2NrICpzaywgc3RydWN0IG5ldF9kZXZpY2UgKmRldiwgaW50IHByb3RvY29sKQoreworCXN0cnVjdCBwYWNrZXRfc29jayAqcG8gPSBwa3Rfc2soc2spOworCS8qCisJICoJRGV0YWNoIGFuIGV4aXN0aW5nIGhvb2sgaWYgcHJlc2VudC4KKwkgKi8KKworCWxvY2tfc29jayhzayk7CisKKwlzcGluX2xvY2soJnBvLT5iaW5kX2xvY2spOworCWlmIChwby0+cnVubmluZykgeworCQlfX3NvY2tfcHV0KHNrKTsKKwkJcG8tPnJ1bm5pbmcgPSAwOworCQlwby0+bnVtID0gMDsKKwkJc3Bpbl91bmxvY2soJnBvLT5iaW5kX2xvY2spOworCQlkZXZfcmVtb3ZlX3BhY2soJnBvLT5wcm90X2hvb2spOworCQlzcGluX2xvY2soJnBvLT5iaW5kX2xvY2spOworCX0KKworCXBvLT5udW0gPSBwcm90b2NvbDsKKwlwby0+cHJvdF9ob29rLnR5cGUgPSBwcm90b2NvbDsKKwlwby0+cHJvdF9ob29rLmRldiA9IGRldjsKKworCXBvLT5pZmluZGV4ID0gZGV2ID8gZGV2LT5pZmluZGV4IDogMDsKKworCWlmIChwcm90b2NvbCA9PSAwKQorCQlnb3RvIG91dF91bmxvY2s7CisKKwlpZiAoZGV2KS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CXJ4cnBjX2tyeGlvZF9xdWV1ZV9jYWxsKGNhbGwpOworfQorCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisvKgorICogY2FsY3VsYXRlIGEgdGltZW91dCBiYXNlZCBvbiBhbiBSVFQgdmFsdWUKKyAqLworc3RhdGljIGlubGluZSB1bnNpZ25lZCBsb25nIF9fcnhycGNfcnR0X2Jhc2VkX3RpbWVvdXQoc3RydWN0IHJ4cnBjX2NhbGwgKmNhbGwsCisJCQkJCQkgICAgICB1bnNpZ25lZCBsb25nIHZhbCkKK3sKKwl1bnNpZ25lZCBsb25nIGV4cGlyeSA9IGNhbGwtPmNvbm4tPnBlZXItPnJ0dCAvICgxMDAwMDAwIC8gSFopOworCisJZXhwaXJ5ICs9IDEwOworCWlmIChleHBpcnkgPCBIWiAvIDI1KQorCQlleHBpcnkgPSBIWiAvIDI1OworCWlmIChleHBpcnkgPiBIWikKKwkJZXhwaXJ5ID0gSFo7CisKKwlfbGVhdmUoIiA9ICVsdSBqaWZmaWVzIiwgZXhwaXJ5KTsKKwlyZXR1cm4gamlmZmllcyArIGV4cGlyeTsKK30gLyogZW5kIF9fcnhycGNfcnR0X2Jhc2VkX3RpbWVvdXQoKSAqLworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisvKgorICogY3JlYXRlIGEgbmV3IGNhbGwgcmVjb3JkCisgKi8KK3N0YXRpYyBpbmxpbmUgaW50IF9fcnhycGNfY3JlYXRlX2NhbGwoc3RydWN0IHJ4cnBjX2Nvbm5lY3Rpb24gKmNvbm4sCisJCQkJICAgICAgc3RydWN0IHJ4cnBjX2NhbGwgKipfY2FsbCkKK3sKKwlzdHJ1Y3QgcnhycGNfY2FsbCAqY2FsbDsKKworCV9lbnRlcigiJXAiLCBjb25uKTsKKworCS8qIGFs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ubmVsc1tjaXhdID0gY2FsbDsgLyogYXNzaWduIF9hZnRlcl8gZG9uZSBjYWxsaWQgY2hlY2sgbG9vcCAqLworCWRvX2dldHRpbWVvZmRheSgmY29ubi0+YXRpbWUpOworCWNhbGwtPmNoYW5faXggPSBodG9ubChjaXgpOworCisJc3Bpbl91bmxvY2soJmNvbm4tPmxvY2spOworCisJZG93bl93cml0ZSgmcnhycGNfY2FsbHNfc2VtKTsKKwlsaXN0X2FkZF90YWlsKCZjYWxsLT5jYWxsX2xpbmssICZyeHJwY19jYWxscyk7CisJdXBfd3JpdGUoJnJ4cnBjX2NhbGxzX3NlbSk7CisKKwlfX1JYQUNDVChhdG9taWNfaW5jKCZyeHJwY19jYWxsX2NvdW50KSk7CisJKl9jYWxsID0gY2FsbDsKKworCV9sZWF2ZSgiID0gMCAoY2FsbD0lcCBjaXg9JXUpIiwgY2FsbCwgY2l4KTsKKwlyZXR1cm4gMDsKKworIGVycm9yX3Vud2FpdDoKKwlyZW1vdmVfd2FpdF9xdWV1ZSgmY29ubi0+Y2hhbndhaXQsICZteXNlbGYpOworCXNldF9jdXJyZW50X3N0YXRlKFRBU0tfUlVOTklORyk7CisJc3Bpbl91bmxvY2soJmNvbm4tPmxvY2spOworCisJZnJlZV9wYWdlKCh1bnNpZ25lZCBsb25nKSBjYWxsKTsKKwlfbGVhdmUoIiA9ICVkIiwgcmV0KTsKKwlyZXR1cm4gcmV0OworfSAvKiBlbmQgcnhycGNfY3JlYXRlX2NhbGwoKSAqLworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisvKgorICogY3JlYXRlIGEgbmV3IGNhbGwgcmVjb3JkIGZvciBpbmNvbWluZyBjYWxscworICovCitpbnQgcnhycGNfaW5jb21pbmdfY2FsbChzdHJ1Y3QgcnhycGNfY29ubmVjdGlvbiAqY29ubiwKKwkJCXN0cnVjdCByeHJwY19tZXNzYWdlICptc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WMoJnJ4cnBjX2NhbGxfY291bnQpKTsKKwlmcmVlX3BhZ2UoKHVuc2lnbmVkIGxvbmcpIGNhbGwpOworCisJX2xlYXZlKCIgW2Rlc3Ryb3llZF0iKTsKK30gLyogZW5kIHJ4cnBjX3B1dF9jYWxsKCkgKi8KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworLyoKKyAqIGFjdHVhbGx5IGdlbmVyYXRlIGEgbm9ybWFsIEFDSworICovCitzdGF0aWMgaW5saW5lIGludCBfX3J4cnBjX2NhbGxfZ2VuX25vcm1hbF9BQ0soc3RydWN0IHJ4cnBjX2NhbGwgKmNhbGwsCisJCQkJCSAgICAgIHJ4cnBjX3NlcV90IHNlcSkKK3sKKwlzdHJ1Y3QgcnhycGNfbWVzc2FnZSAqbXNnOworCXN0cnVjdCBrdmVjIGRpb3ZbM107CisJX19iZTMyIGF1eFs0XTsKKwlpbnQgZGVsdGEsIHJldDsKKworCS8qIEFDS3MgZGVmYXVsdCB0byBERUxBWSAqLworCWlmICghY2FsbC0+YWNrci5yZWFzb24pCisJCWNhbGwtPmFja3IucmVhc29uID0gUlhSUENfQUNLX0RFTEFZOworCisJX3Byb3RvKCJSeCAlMDVsdSBTZW5kaW5nIEFDSyB7IG09JWh1IGY9IyV1IHA9IyV1IHM9JSUldSByPSVzIG49JXUgfSIsCisJICAgICAgIGppZmZpZXMgLSBjYWxsLT5jamlmLAorCSAgICAgICBudG9ocyhjYWxsLT5hY2tyLm1heFNrZXcpLAorCSAgICAgICBudG9obChjYWxsLT5hY2tyLmZpcnN0UGFja2V0KSwKKwkgICAgICAgbnRvaGwoY2FsbC0+YWNrci5wcmV2aW91c1BhY2tldCksCisJICAgICAgIG50b2hsKGNhbGwtPmFja3Iuc2VyaWFsKSwKKwkgICAgICAgcnhycGNfYWNrc1tjYWxsLT5hY2tyLnJlYXNvbl0sCisJICAgICAgIGNhbGwt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ID0gc2VxOworCQltc2ctPmhkci5zZXEgPSBodG9ubChzZXEpOworCQltc2ctPmhkci5mbGFncyB8PSBSWFJQQ19TTE9XX1NUQVJUX09LOworCisJCWVyciA9IHJ4cnBjX2Nvbm5fc2VuZG1zZyhjYWxsLT5jb25uLCBtc2cpOworCQlyeHJwY19wdXRfbWVzc2FnZShtc2cpOworCQlpZiAoZXJyIDwgMCkgeworCQkJcmV0ID0gZXJyOworCQkJZ290byBvdXQ7CisJCX0KKwkJY2FsbC0+cGt0X3NuZF9jb3VudCsrOworCX0KKworIG91dDoKKwlpZiAoaGRyLT5zZXEpCisJCWNhbGwtPmFja3JfcHJldl9zZXEgPSBoZHItPnNlcTsKKworCV9sZWF2ZSgiID0gJWQiLCByZXQpOworCXJldHVybiByZXQ7Cit9IC8qIGVuZCByeHJwY19jYWxsX2dlbmVyYXRlX0FDSygpICovCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKy8qCisgKiBoYW5kbGUgd29yayB0byBiZSBkb25lIG9uIGEgY2FsbAorICogLSBpbmNsdWRlcyBwYWNrZXQgcmVjZXB0aW9uIGFuZCB0aW1lb3V0IHByb2Nlc3NpbmcKKyAqLwordm9pZCByeHJwY19jYWxsX2RvX3N0dWZmKHN0cnVjdCByeHJwY19jYWxsICpjYWxsKQoreworCV9lbnRlcigiJXB7ZmxhZ3M9JWx4fSIsIGNhbGwsIGNhbGwtPmZsYWdzKTsKKworCS8qIGhhbmRsZSBwYWNrZXQgcmVjZXB0aW9uICovCisJaWYgKGNhbGwtPmZsYWdzICYgUlhSUENfQ0FMTF9SQ1ZfUEtUKSB7CisJCV9kZWJ1ZygiLSByZWNlaXZlIHBhY2tldCIpOworCQljYWxsLT5mbGFncyAmPSB+UlhSUENfQ0FMTF9SQ1ZfUEtUOworCQlyeHJwY19jYWxsX3JlY2VpdmVfcGFja2V0KGNhbGwpOworCX0KKworC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KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisvKgorICogY3JlYXRlIGEgbmV3IGNvbm5lY3Rpb24gcmVjb3JkIGZvciBvdXRnb2luZyBjb25uZWN0aW9ucworICovCitpbnQgcnhycGNfY3JlYXRlX2Nvbm5lY3Rpb24oc3RydWN0IHJ4cnBjX3RyYW5zcG9ydCAqdHJhbnMsCisJCQkgICAgX19iZTE2IHBvcnQsCisJCQkgICAgX19iZTMyIGFkZHIsCisJCQkgICAgdWludDE2X3Qgc2VydmljZV9pZCwKKwkJCSAgICB2b2lkICpzZWN1cml0eSwKKwkJCSAgICBzdHJ1Y3QgcnhycGNfY29ubmVjdGlvbiAqKl9jb25uKQoreworCXN0cnVjdCByeHJwY19jb25uZWN0aW9uICpjYW5kaWRhdGUsICpjb25uOworCXN0cnVjdCByeHJwY19wZWVyICpwZWVyOworCXN0cnVjdCBsaXN0X2hlYWQgKl9wOworCV9fYmUzMiBjb25uaWQ7CisJaW50IHJldDsKKworCV9lbnRlcigiJXB7JWh1fSwldSwlaHUiLCB0cmFucywgdHJhbnMtPnBvcnQsIG50b2hzKHBvcnQpLCBzZXJ2aWNlX2lkKTsKKworCS8qIGdldCBhIHBlZXIgcmVjb3JkICovCisJcmV0ID0gcnhycGNfcGVlcl9sb29rdXAodHJhbnMsIGFkZHIsICZwZWVyKTsKKwlpZiAocmV0IDwgMCkgeworCQlfbGVhdmUoIiA9ICVkIiwgcmV0KTsKKwkJcmV0dXJuIHJldDsKKwl9CisKKwkvKiBhbGxvY2F0ZSBhbmQgaW5pdGlhbGlzZSBhIGNvbm5lY3Rpb24gcmVjb3JkICovCisJcmV0ID0gX19yeHJwY19jcmVhdGVfY29ubmVjdGlvbihwZWVyLCAmY2FuZGlkYXRlKTsKKwlpZiAocmV0IDwgMCkgeworCQlyeHJwY19wdXRfcGVlcihwZWVyKTsKKwkJX2xlYXZlKCIgPSAlZCIsIHJldCk7CisJCXJld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bm5fdGltZW91dCAqIEhaKTsKKworCXNwaW5fdW5sb2NrKCZwZWVyLT5jb25uX2d5bG9jayk7CisKKwlyeHJwY19wdXRfcGVlcihjb25uLT5wZWVyKTsKKworCV9sZWF2ZSgiIFtraWxsZWRdIik7Cit9IC8qIGVuZCByeHJwY19wdXRfY29ubmVjdGlvbigpICovCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKy8qCisgKiBmcmVlIGEgY29ubmVjdGlvbiByZWNvcmQKKyAqLworc3RhdGljIHZvaWQgcnhycGNfY29ubl9kb190aW1lb3V0KHN0cnVjdCByeHJwY19jb25uZWN0aW9uICpjb25uKQoreworCXN0cnVjdCByeHJwY19wZWVyICpwZWVyOworCisJX2VudGVyKCIlcHt1PSVkIHA9JWh1fSIsCisJICAgICAgIGNvbm4sIGF0b21pY19yZWFkKCZjb25uLT51c2FnZSksIG50b2hzKGNvbm4tPmFkZHIuc2luX3BvcnQpKTsKKworCXBlZXIgPSBjb25uLT5wZWVyOworCisJaWYgKGF0b21pY19yZWFkKCZjb25uLT51c2FnZSkgPCAwKQorCQlCVUcoKTsKKworCS8qIHJlbW92ZSBmcm9tIGdyYXZleWFyZCBpZiBzdGlsbCBkZWFkICovCisJc3Bpbl9sb2NrKCZwZWVyLT5jb25uX2d5bG9jayk7CisJaWYgKGF0b21pY19yZWFkKCZjb25uLT51c2FnZSkgPT0gMCkgeworCQlsaXN0X2RlbF9pbml0KCZjb25uLT5saW5rKTsKKwl9CisJZWxzZSB7CisJCWNvbm4gPSBOVUxMOworCX0KKwlzcGluX3VubG9jaygmcGVlci0+Y29ubl9neWxvY2spOworCisJaWYgKCFjb25uKSB7CisJCV9sZWF2ZSgiIik7CisJCXJldHVybjsgLyogcmVzdXJyZWN0ZWQgKi8KKwl9CisKKwlfZGVidWcoIi0tLSBEZXN0cm95aW5nIENvbm5lY3Rpb24gJXB7JTA4eH0gLS0tIiwKKwkgICAgICAgY29ubiwgbnRvaGwoY29ubi0+Y29ubl9pZCkpOworCisJZG93bl93cml0ZSgmcnhycGNfY29ubnNfc2VtKTsKKwlsaXN0X2RlbCgmY29ubi0+cHJvY19saW5rKTsKKwl1cF93cml0ZSgmcnhycGNfY29ubnNfc2VtKTsKKworCXdyaXRlX2xvY2soJnBlZXItPmNvbm5faWRsb2NrKTsKKwlsaXN0X2RlbCgmY29ubi0+aWRfbGluayk7CisJd3JpdGVfdW5sb2NrKCZwZWVyLT5jb25uX2lkbG9jayk7CisKKwlfX1JYQUNDVChhdG9taWNfZGVjKCZyeHJwY19jb25uZWN0aW9uX2NvdW50KSk7CisJa2ZyZWUoY29ubik7CisKKwkvKiBpZiB0aGUgZ3JhdmV5YXJkIGlzIG5vdyBlbXB0eSwgd2FrZSB1cCBhbnlvbmUgd2FpdGluZyBmb3IgdGhhdCAqLworCWlmIChhdG9taWNfZGVjX2FuZF90ZXN0KCZwZWVyLT5jb25uX2NvdW50KSkKKwkJd2FrZV91cCgmcGVlci0+Y29ubl9neV93YWl0cSk7CisKKwlfbGVhdmUoIiBbZGVzdHJveWVkXSIpOworfSAvKiBlbmQgcnhycGNfY29ubl9kb190aW1lb3V0KCkgKi8KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworLyoKKyAqIGNsZWFyIGFsbCBjb25uZWN0aW9uIHJlY29yZHMgZnJvbSBhIHBlZXIgZW5kcG9pbnQKKyAqLwordm9pZCByeHJwY19jb25uX2NsZWFyYWxsKHN0cnVjdCByeHJwY19wZWVyICpwZWVyKQoreworCURFQ0xBUkVfV0FJVFFVRVVFKG15c2VsZiwgY3VycmVudCk7CisKKwlzdHJ1Y3QgcnhycGNfY29ubmVjdGlvbiAqY29ubjsKKwlpbnQgZXJyOworCisJX2VudGVyKCIlcCIsIHBlZXIpOworCisJLyogdGhlcmUgc2hvdWxk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m15c2VsZik7CisJc2V0X2N1cnJlbnRfc3RhdGUoVEFTS19SVU5OSU5HKTsKKworCV9sZWF2ZSgiIik7Cit9IC8qIGVuZCByeHJwY19jb25uX2NsZWFyYWxsKCkgKi8KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworLyoKKyAqIGFsbG9jYXRlIGFuZCBwcmVwYXJlIGEgbWVzc2FnZSBmb3Igc2VuZGluZyBvdXQgdGhyb3VnaCB0aGUgdHJhbnNwb3J0CisgKiBlbmRwb2ludAorICovCitpbnQgcnhycGNfY29ubl9uZXdtc2coc3RydWN0IHJ4cnBjX2Nvbm5lY3Rpb24gKmNvbm4sCisJCSAgICAgIHN0cnVjdCByeHJwY19jYWxsICpjYWxsLAorCQkgICAgICB1aW50OF90IHR5cGUsCisJCSAgICAgIGludCBkY291bnQsCisJCSAgICAgIHN0cnVjdCBrdmVjIGRpb3ZbXSwKKwkJICAgICAgaW50IGFsbG9jX2ZsYWdzLAorCQkgICAgICBzdHJ1Y3QgcnhycGNfbWVzc2FnZSAqKl9tc2cpCit7CisJc3RydWN0IHJ4cnBjX21lc3NhZ2UgKm1zZzsKKwlpbnQgbG9vcDsKKworCV9lbnRlcigiJXB7JWR9LCVwLCV1IiwgY29ubiwgbnRvaHMoY29ubi0+YWRkci5zaW5fcG9ydCksIGNhbGwsIHR5cGUpOworCisJaWYgKGRjb3VudCA+IDMpIHsKKwkJX2xlYXZlKCIgPSAtRUlOVkFMIik7CisJCXJldHVybiAtRUlOVkFMOworCX0KKworCW1zZyA9IGttYWxsb2Moc2l6ZW9mKHN0cnVjdCByeHJwY19tZXNzYWdlKSwgYWxsb2NfZmxhZ3MpOworCWlmICghbXNnKSB7CisJCV9sZWF2ZSgiID0gLUVOT01FTSIpOworCQlyZXR1cm4gLUVOT01FTTsKKwl9CisKKwltZW1zZXQobXNnLCAwLCBzaXplb2YoKm1zZykpOworCWF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3Rpb24obXNnLT5jb25uKTsKKworCWZvciAobG9vcCA9IDA7IGxvb3AgPCA4OyBsb29wKyspCisJCWlmICh0ZXN0X2JpdChsb29wLCAmbXNnLT5kZnJlZSkpCisJCQlrZnJlZShtc2ctPmRhdGFbbG9vcF0uaW92X2Jhc2UpOworCisJX19SWEFDQ1QoYXRvbWljX2RlYygmcnhycGNfbWVzc2FnZV9jb3VudCkpOworCWtmcmVlKG1zZyk7CisKKwlfbGVhdmUoIiIpOworfSAvKiBlbmQgX19yeHJwY19wdXRfbWVzc2FnZSgpICovCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKy8qCisgKiBzZW5kIGEgbWVzc2FnZSBvdXQgdGhyb3VnaCB0aGUgdHJhbnNwb3J0IGVuZHBvaW50CisgKi8KK2ludCByeHJwY19jb25uX3NlbmRtc2coc3RydWN0IHJ4cnBjX2Nvbm5lY3Rpb24gKmNvbm4sCisJCSAgICAgICBzdHJ1Y3QgcnhycGNfbWVzc2FnZSAqbXNnKQoreworCXN0cnVjdCBtc2doZHIgbXNnaGRyOworCWludCByZXQ7CisKKwlfZW50ZXIoIiVweyVkfSIsIGNvbm4sIG50b2hzKGNvbm4tPmFkZHIuc2luX3BvcnQpKTsKKworCS8qIGZpbGwgaW4gc29tZSBmaWVsZHMgaW4gdGhlIGhlYWRlciAqLworCXNwaW5fbG9jaygmY29ubi0+bG9jayk7CisJbXNnLT5oZHIuc2VyaWFsID0gaHRvbmwoKytjb25uLT5zZXJpYWxfY291bnRlcik7CisJbXNnLT5ydHRkb25lID0gMDsKKwlzcGluX3VubG9jaygmY29ubi0+bG9jayk7CisKKwkvKiBzZXQgdXAgdGhlIG1lc3NhZ2UgdG8gYmUgdHJhbnNtaXR0ZWQgKi8KKwltc2doZHIubXNnX25hbWUJCT0gJmNvbm4tPmFkZHI7CisJbXNnaGRyLm1zZ19uYW1lbGVuCT0gc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RvbWljX3JlYWQoJmNhbGwtPnVzYWdlKSA+IDApIHsKKwkJCQkJX2RlYnVnKCJAQEAgS1JYSU9EIgorCQkJCQkgICAgICAgIiBCZWdpbiBBdHRlbmQgQ2FsbCAlcCIsIGNhbGwpOworCQkJCQlyeHJwY19nZXRfY2FsbChjYWxsKTsKKwkJCQl9CisJCQkJZWxzZSB7CisJCQkJCWNhbGwgPSBOVUxMOworCQkJCX0KKwkJCX0KKworCQkJc3Bpbl91bmxvY2tfaXJxKCZyeHJwY19rcnhpb2RfY2FsbHFfbG9jayk7CisKKwkJCWlmIChjYWxsKSB7CisJCQkJcnhycGNfY2FsbF9kb19zdHVmZihjYWxsKTsKKwkJCQlyeHJwY19wdXRfY2FsbChjYWxsKTsKKwkJCQlfZGVidWcoIkBAQCBLUlhJT0QgRW5kIEF0dGVuZCBDYWxsICVwIiwgY2FsbCk7CisJCQl9CisJCX0KKworCQlfZGVidWcoIiMjIyBFbmQgV29yayIpOworCisJCXRyeV90b19mcmVlemUoUEZfRlJFRVpFKTsKKworICAgICAgICAgICAgICAgIC8qIGRpc2NhcmQgcGVuZGluZyBzaWduYWxzICovCisJCXJ4cnBjX2Rpc2NhcmRfbXlfc2lnbmFscygpOworCisJfSB3aGlsZSAoIXJ4cnBjX2tyeGlvZF9kaWUpOworCisJLyogYW5kIHRoYXQncyBhbGwgKi8KKwljb21wbGV0ZV9hbmRfZXhpdCgmcnhycGNfa3J4aW9kX2RlYWQsIDApOworCit9IC8qIGVuZCByeHJwY19rcnhpb2QoKSAqLworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisvKgorICogc3RhcnQgdXAgYSBrcnhpb2QgZGFlbW9uCisgKi8KK2ludCBfX2luaXQgcnhycGNfa3J4aW9kX2luaXQodm9pZCkKK3sKKwlyZXR1cm4ga2VybmVsX3RocmVhZChyeHJwY19rcnhpb2QsIE5VTEwsIDApOworCit9IC8qIGVuZCByeHJwY19rcnhpb2RfaW5pdCgpICovCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKy8qCisgKiBraWxsIHRoZSBrcnhpb2QgZGFlbW9uIGFuZCB3YWl0IGZvciBpdCB0byBjb21wbGV0ZQorICovCit2b2lkIHJ4cnBjX2tyeGlvZF9raWxsKHZvaWQpCit7CisJcnhycGNfa3J4aW9kX2RpZSA9IDE7CisJd2FrZV91cF9hbGwoJnJ4cnBjX2tyeGlvZF9zbGVlcHEpOworCXdhaXRfZm9yX2NvbXBsZXRpb24oJnJ4cnBjX2tyeGlvZF9kZWFkKTsKKworfSAvKiBlbmQgcnhycGNfa3J4aW9kX2tpbGwoKSAqLworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisvKgorICogcXVldWUgYSB0cmFuc3BvcnQgZm9yIGF0dGVudGlvbiBieSBrcnhpb2QKKyAqLwordm9pZCByeHJwY19rcnhpb2RfcXVldWVfdHJhbnNwb3J0KHN0cnVjdCByeHJwY190cmFuc3BvcnQgKnRyYW5zKQoreworCXVuc2lnbmVkIGxvbmcgZmxhZ3M7CisKKwlfZW50ZXIoIiIpOworCisJaWYgKGxpc3RfZW1wdHkoJnRyYW5zLT5rcnhpb2RxX2xpbmspKSB7CisJCXNwaW5fbG9ja19pcnFzYXZlKCZyeHJwY19rcnhpb2RfdHJhbnNwb3J0cV9sb2NrLCBmbGFncyk7CisKKwkJaWYgKGxpc3RfZW1wdHkoJnRyYW5zLT5rcnhpb2RxX2xpbmspKSB7CisJCQlpZiAoYXRvbWljX3JlYWQoJnRyYW5zLT51c2FnZSkgPiAwKSB7CisJCQkJbGlzdF9hZGRfdGFpbCgmdHJhbnMtPmtyeGlvZHFfbGluaywKKwkJCQkJICAgICAgJnJ4cnBjX2tyeG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c2VjZF9kaWU7CisKK3N0YXRpYyBhdG9taWNfdCByeHJwY19rcnhzZWNkX3Fjb3VudDsKKworLyogcXVldWUgb2YgdW5wcm9jZXNzZWQgaW5ib3VuZCBtZXNzYWdlcyB3aXRoIHNlcW5vICMxIGFuZAorICogUlhSUENfQ0xJRU5UX0lOSVRJQVRFRCBmbGFnIHNldCAqLworc3RhdGljIExJU1RfSEVBRChyeHJwY19rcnhzZWNkX2luaXRtc2dxKTsKK3N0YXRpYyBERUZJTkVfU1BJTkxPQ0socnhycGNfa3J4c2VjZF9pbml0bXNncV9sb2NrKTsKKworc3RhdGljIHZvaWQgcnhycGNfa3J4c2VjZF9wcm9jZXNzX2luY29taW5nX2NhbGwoc3RydWN0IHJ4cnBjX21lc3NhZ2UgKm1zZyk7CisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKy8qCisgKiBSeCBzZWN1cml0eSBkYWVtb24KKyAqLworc3RhdGljIGludCByeHJwY19rcnhzZWNkKHZvaWQgKmFyZykKK3sKKwlERUNMQVJFX1dBSVRRVUVVRShrcnhzZWNkLCBjdXJyZW50KTsKKworCWludCBkaWU7CisKKwlwcmludGsoIlN0YXJ0ZWQga3J4c2VjZCAlZFxuIiwgY3VycmVudC0+cGlkKTsKKworCWRhZW1vbml6ZSgia3J4c2VjZCIpOworCisJLyogbG9vcCBhcm91bmQgd2FpdGluZyBmb3Igd29yayB0byBkbyAqLworCWRvIHsKKwkJLyogd2FpdCBmb3Igd29yayBvciB0byBiZSB0b2xkIHRvIGV4aXQgKi8KKwkJX2RlYnVnKCIjIyMgQmVnaW4gV2FpdCIpOworCQlpZiAoIWF0b21pY19yZWFkKCZyeHJwY19rcnhzZWNkX3Fjb3VudCkpIHsKKwkJCXNldF9jdXJyZW50X3N0YXRlKFRBU0tfSU5URVJSVVBUSUJMRSk7CisKKwkJCWFkZF93YWl0X3F1ZXVlKCZy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taWNfZGVjKCZyeHJwY19rcnhzZWNkX3Fjb3VudCk7CisJCQl9CisKKwkJCXNwaW5fdW5sb2NrKCZyeHJwY19rcnhzZWNkX2luaXRtc2dxX2xvY2spOworCisJCQlpZiAobXNnKSB7CisJCQkJcnhycGNfa3J4c2VjZF9wcm9jZXNzX2luY29taW5nX2NhbGwobXNnKTsKKwkJCQlyeHJwY19wdXRfbWVzc2FnZShtc2cpOworCQkJfQorCQl9CisKKwkJX2RlYnVnKCIjIyMgRW5kIEluYm91bmQgQ2FsbHMiKTsKKworCQl0cnlfdG9fZnJlZXplKFBGX0ZSRUVaRSk7CisKKyAgICAgICAgICAgICAgICAvKiBkaXNjYXJkIHBlbmRpbmcgc2lnbmFscyAqLworCQlyeHJwY19kaXNjYXJkX215X3NpZ25hbHMoKTsKKworCX0gd2hpbGUgKCFkaWUpOworCisJLyogYW5kIHRoYXQncyBhbGwgKi8KKwljb21wbGV0ZV9hbmRfZXhpdCgmcnhycGNfa3J4c2VjZF9kZWFkLCAwKTsKKworfSAvKiBlbmQgcnhycGNfa3J4c2VjZCgpICovCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKy8qCisgKiBzdGFydCB1cCBhIGtyeHNlY2QgZGFlbW9uCisgKi8KK2ludCBfX2luaXQgcnhycGNfa3J4c2VjZF9pbml0KHZvaWQpCit7CisJcmV0dXJuIGtlcm5lbF90aHJlYWQocnhycGNfa3J4c2VjZCwgTlVMTCwgMCk7CisKK30gLyogZW5kIHJ4cnBjX2tyeHNlY2RfaW5pdCgpICovCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKy8qCisgKiBraWxsIHRoZSBrcnhzZWNkIGRhZW1vbiBhbmQgd2FpdCBmb3IgaXQgdG8gY29tcGxldGUKKyAqLwordm9pZCByeH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KyNpbmNsdWRlIDxsaW51eC9pbml0Lmg+CisjaW5jbHVkZSA8bGludXgvc2NoZWQuaD4KKyNpbmNsdWRlIDxsaW51eC9jb21wbGV0aW9uLmg+CisjaW5jbHVkZSA8cnhycGMvcnhycGMuaD4KKyNpbmNsdWRlIDxyeHJwYy9rcnh0aW1vZC5oPgorI2luY2x1ZGUgPGFzbS9lcnJuby5oPgorI2luY2x1ZGUgImludGVybmFsLmgiCisKK3N0YXRpYyBERUNMQVJFX0NPTVBMRVRJT04oa3J4dGltb2RfYWxpdmUpOworc3RhdGljIERFQ0xBUkVfQ09NUExFVElPTihrcnh0aW1vZF9kZWFkKTsKK3N0YXRpYyBERUNMQVJFX1dBSVRfUVVFVUVfSEVBRChrcnh0aW1vZF9zbGVlcHEpOworc3RhdGljIGludCBrcnh0aW1vZF9kaWU7CisKK3N0YXRpYyBMSVNUX0hFQUQoa3J4dGltb2RfbGlzdCk7CitzdGF0aWMgREVGSU5FX1NQSU5MT0NLKGtyeHRpbW9kX2xvY2spOworCitzdGF0aWMgaW50IGtyeHRpbW9kKHZvaWQgKmFyZyk7CisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKy8qCisgKiBzdGFydCB0aGUgdGltZW91dCBkYWVtb24KKyAqLworaW50IHJ4cnBjX2tyeHRpbW9kX3N0YXJ0KHZvaWQpCit7CisJaW50IHJldDsKKworCXJldCA9IGtlcm5lbF90aHJlYWQoa3J4dGltb2QsIE5VTEwsIDApOworCWlmIChyZXQgPCAwKQorCQlyZXR1cm4gcmV0OworCisJd2FpdF9mb3JfY29tcGxldGlvbigma3J4dGltb2RfYWxpdmUpOworCisJcmV0dXJuIHJldDsKK30gLyogZW5kIHJ4cnBjX2tyeHRpbW9kX3N0YXJ0KCkgKi8KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworLyoKKyAqIHN0b3AgdGhlIHRpbWVvdXQgZGFlbW9uCisgKi8KK3ZvaWQgcnhycGNfa3J4dGltb2Rfa2lsbCh2b2lkKQoreworCS8qIGdldCByaWQgb2YgbXkgZGFlbW9uICovCisJa3J4dGltb2RfZGllID0gMTsKKwl3YWtlX3VwKCZrcnh0aW1vZF9zbGVlcHEpOworCXdhaXRfZm9yX2NvbXBsZXRpb24oJmtyeHRpbW9kX2RlYWQpOworCit9IC8qIGVuZCByeHJwY19rcnh0aW1vZF9raWxsKCkgKi8KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworLyoKKyAqIHRpbWVvdXQgcHJvY2Vzc2luZyBkYWVtb24KKyAqLworc3RhdGljIGludCBrcnh0aW1vZCh2b2lkICphcmcpCit7CisJREVDTEFSRV9XQUlUUVVFVUUobXlzZWxmLCBjdXJyZW50KTsKKworCXJ4cnBjX3RpbWVyX3QgKnRpbWVyOworCisJcHJpbnRrKCJTdGFydGVkIGtyeHRpbW9kICVkXG4iLCBjdXJyZW50LT5waWQpOworCisJZGFlbW9uaXplKCJrcnh0aW1vZCIpOworCisJY29tcGxldGUoJmtyeHRpbW9kX2FsaXZlKTsKKworCS8qIGxvb3AgYXJvdW5kIGxvb2tpbmcgZm9yIHRoaW5ncyB0byBhdHRlbmQgdG8gKi8KKyBsb29wOgorCXNldF9jdXJyZW50X3N0YXRlKFRBU0tfSU5URVJSVVBUSUJMRSk7CisJYWRkX3dhaXRfcXVldWUoJmtyeHRpbW9kX3NsZWVwcSwgJm15c2VsZik7CisKKwlmb3IgKDs7KSB7CisJCXVuc2lnbmVkIGxvbmcgamlmOworCQlzaWduZWQgbG9uZyB0aW1lb3V0OworCisJCS8qIGRlYWwgd2l0aCB0aGUgc2VydmVyIGJlaW5nIGFza2VkIHRvIGRpZSAqLworCQlpZiAoa3J4dGltb2RfZGll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CBvciByZXNldCAtIHB1dCBpdCBiYWNrIGluIHRoZSBxdWV1ZSBhdCB0aGUKKwkgKiByaWdodCBwbGFjZSAqLworCXRpbWVyLT50aW1vX2ppZiA9IGppZmZpZXMgKyB0aW1lb3V0OworCisJbGlzdF9mb3JfZWFjaChfcCwgJmtyeHRpbW9kX2xpc3QpIHsKKwkJcHRpbWVyID0gbGlzdF9lbnRyeShfcCwgcnhycGNfdGltZXJfdCwgbGluayk7CisJCWlmICh0aW1lX2JlZm9yZSh0aW1lci0+dGltb19qaWYsIHB0aW1lci0+dGltb19qaWYpKQorCQkJYnJlYWs7CisJfQorCisJbGlzdF9hZGRfdGFpbCgmdGltZXItPmxpbmssIF9wKTsgLyogaW5zZXJ0IGJlZm9yZSBzdG9wcGluZyBwb2ludCAqLworCisJc3Bpbl91bmxvY2soJmtyeHRpbW9kX2xvY2spOworCisJd2FrZV91cCgma3J4dGltb2Rfc2xlZXBxKTsKKworCV9sZWF2ZSgiIik7Cit9IC8qIGVuZCByeHJwY19rcnh0aW1vZF9hZGRfdGltZXIoKSAqLworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisvKgorICogZGVxdWV1ZSBhIHRpbWVyCisgKiAtIHJldHVybnMgMCBpZiB0aGUgdGltZXIgd2FzIGRlbGV0ZWQgb3IgLUVOT0VOVCBpZiBpdCB3YXNuJ3QgcXVldWVkCisgKi8KK2ludCByeHJwY19rcnh0aW1vZF9kZWxfdGltZXIocnhycGNfdGltZXJfdCAqdGltZXIpCit7CisJaW50IHJldCA9IDA7CisKKwlfZW50ZXIoIiVwIiwgdGltZXIpOworCisJc3Bpbl9sb2NrKCZrcnh0aW1vZF9sb2NrKTsKKworCWlmIChsaXN0X2VtcHR5KCZ0aW1lci0+bGluaykpCisJCXJldCA9IC1FTk9FTlQ7CisJZWxzZQorCQlsaXN0X2RlbF9pbml0KCZ0aW1lci0+bGluayk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UgPHJ4cnBjL2tyeGlvZC5oPgorI2luY2x1ZGUgPHJ4cnBjL2tyeHNlY2QuaD4KKyNpbmNsdWRlIDxyeHJwYy9rcnh0aW1vZC5oPgorI2luY2x1ZGUgPHJ4cnBjL3RyYW5zcG9ydC5oPgorI2luY2x1ZGUgPHJ4cnBjL2Nvbm5lY3Rpb24uaD4KKyNpbmNsdWRlIDxyeHJwYy9jYWxsLmg+CisjaW5jbHVkZSA8cnhycGMvbWVzc2FnZS5oPgorI2luY2x1ZGUgImludGVybmFsLmgiCisKK01PRFVMRV9ERVNDUklQVElPTigiUnggUlBDIGltcGxlbWVudGF0aW9uIik7CitNT0RVTEVfQVVUSE9SKCJSZWQgSGF0LCBJbmMuIik7CitNT0RVTEVfTElDRU5TRSgiR1BMIik7CisKK19fYmUzMiByeHJwY19lcG9jaDsKKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworLyoKKyAqIGluaXRpYWxpc2UgdGhlIFJ4IG1vZHVsZQorICovCitzdGF0aWMgaW50IF9faW5pdCByeHJwY19pbml0aWFsaXNlKHZvaWQpCit7CisJaW50IHJldDsKKworCS8qIG15IGVwb2NoIHZhbHVlICovCisJcnhycGNfZXBvY2ggPSBodG9ubCh4dGltZS50dl9zZWMpOworCisJLyogcmVnaXN0ZXIgdGhlIC9wcm9jIGludGVyZmFjZSAqLworI2lmZGVmIENPTkZJR19QUk9DX0ZTCisJcmV0ID0gcnhycGNfcHJvY19pbml0KCk7CisJaWYgKHJldDwwKQorCQlyZXR1cm4gcmV0OworI2VuZGlmCisKKwkvKiByZWdpc3RlciB0aGUgc3lzY3RsIGZpbGVzICovCisjaWZkZWYgQ09ORklHX1NZU0NUTAorCXJldCA9IHJ4cnBjX3N5c2N0bF9pbml0KCk7CisJaWYgKHJldDwwKQorCQlnb3RvIGVycm9yX3Byb2M7CisjZW5kaWYKKworCS8qIHN0YXJ0IHRoZSBrcnh0aW1vZCBkYWVtb24gKi8KKwlyZXQgPSByeHJwY19rcnh0aW1vZF9zdGFydCgpOworCWlmIChyZXQ8MCkKKwkJZ290byBlcnJvcl9zeXNjdGw7CisKKwkvKiBzdGFydCB0aGUga3J4aW9kIGRhZW1vbiAqLworCXJldCA9IHJ4cnBjX2tyeGlvZF9pbml0KCk7CisJaWYgKHJldDwwKQorCQlnb3RvIGVycm9yX2tyeHRpbW9kOworCisJLyogc3RhcnQgdGhlIGtyeHNlY2QgZGFlbW9uICovCisJcmV0ID0gcnhycGNfa3J4c2VjZF9pbml0KCk7CisJaWYgKHJldDwwKQorCQlnb3RvIGVycm9yX2tyeGlvZDsKKworCWtkZWJ1ZygiXG5cbiIpOworCisJcmV0dXJuIDA7CisKKyBlcnJvcl9rcnhpb2Q6CisJcnhycGNfa3J4aW9kX2tpbGwoKTsKKyBlcnJvcl9rcnh0aW1vZDoKKwlyeHJwY19rcnh0aW1vZF9raWxsKCk7CisgZXJyb3Jfc3lzY3RsOgorI2lmZGVmIENPTkZJR19TWVNDVEwKKwlyeHJwY19zeXNjdGxfY2xlYW51cCgpOworI2VuZGlmCisgZXJyb3JfcHJvYzoKKyNpZmRlZiBDT05GSUdfUFJPQ19GUworCXJ4cnBjX3Byb2NfY2xlYW51cCgpOworI2VuZGlmCisJcmV0dXJuIHJldDsKK30gLyogZW5kIHJ4cnBjX2luaXRpYWxpc2UoKSAqLworCittb2R1bGVfaW5pdChyeHJwY19pbml0aWFsaXNlKTsKKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworLyoKKyAqIGNsZWFuIHVwIHRoZSBSeCBtb2R1bGUKKyAqLworc3RhdGljIHZvaWQgX19leGl0IHJ4cnBjX2NsZWFudXAodm9pZCkKK3sKKwlrZW50ZXIoIiIpOworCisJX19SWEFDQ1QocHJpbnRrKCJPdXRzdGFuZGluZyBNZXNzYWdlcyAg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b25zOiAlZFxuIiwKKwkJCWF0b21pY19yZWFkKCZyeHJwY19jb25uZWN0aW9uX2NvdW50KSkpOworCV9fUlhBQ0NUKHByaW50aygiT3V0c3RhbmRpbmcgUGVlcnMgICAgICA6ICVkXG4iLAorCQkJYXRvbWljX3JlYWQoJnJ4cnBjX3BlZXJfY291bnQpKSk7CisJX19SWEFDQ1QocHJpbnRrKCJPdXRzdGFuZGluZyBUcmFuc3BvcnRzIDogJWRcbiIsCisJCQlhdG9taWNfcmVhZCgmcnhycGNfdHJhbnNwb3J0X2NvdW50KSkpOworCisJa2xlYXZlKCIiKTsKK30gLyogZW5kIHJ4cnBjX2NsZWFudXAoKSAqLworCittb2R1bGVfZXhpdChyeHJwY19jbGVhbnVwKTsKKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworLyoKKyAqIGNsZWFyIHRoZSBkZWFkIHNwYWNlIGJldHdlZW4gdGFza19zdHJ1Y3QgYW5kIGtlcm5lbCBzdGFjaworICogLSBjYWxsZWQgYnkgc3VwcGx5aW5nIC1maW5zdHJ1bWVudC1mdW5jdGlvbnMgdG8gZ2NjCisgKi8KKyNpZiAwCit2b2lkIF9fY3lnX3Byb2ZpbGVfZnVuY19lbnRlciAodm9pZCAqdGhpc19mbiwgdm9pZCAqY2FsbF9zaXRlKQorX19hdHRyaWJ1dGVfXygobm9faW5zdHJ1bWVudF9mdW5jdGlvbikpOworCit2b2lkIF9fY3lnX3Byb2ZpbGVfZnVuY19lbnRlciAodm9pZCAqdGhpc19mbiwgdm9pZCAqY2FsbF9zaXRlKQoreworICAgICAgIGFzbSB2b2xhdGlsZSgiICBtb3ZsICAgICUlZXNwLCUlZWRpICAgICBcbiIKKyAgICAgICAgICAgICAgICAgICAgIiAgYW5kbCAgICAlMCwlJWVkaSAgICAgICAgXG4iCisgICAgICAgICAgICAgICAgICAgICIgIGFkZGwgICAgJTEsJSVlZGkgICAgICAgIFxuIgorICAgICAgICAgICAgICAgICAgICAiICBtb3ZsICAgICUlZXNwLCUlZWN4ICAgICBcbiIKKyAgICAgICAgICAgICAgICAgICAgIiAgc3VibCAgICAlJWVkaSwlJWVjeCAgICAgXG4iCisgICAgICAgICAgICAgICAgICAgICIgIHNocmwgICAgJDIsJSVlY3ggICAgICAgIFxuIgorICAgICAgICAgICAgICAgICAgICAiICBtb3ZsICAgICQweGVkZWRlZGVkLCUlZWF4ICAgICBcbiIKKyAgICAgICAgICAgICAgICAgICAgIiAgcmVwIHN0b3NsICAgICAgICAgICAgICAgXG4iCisgICAgICAgICAgICAgICAgICAgIDoKKyAgICAgICAgICAgICAgICAgICAgOiAiaSIofihUSFJFQURfU0laRS0xKSksICJpIihzaXplb2Yoc3RydWN0IHRocmVhZF9pbmZvKSkKKyAgICAgICAgICAgICAgICAgICAgOiAiZWF4IiwgImVjeCIsICJlZGkiLCAibWVtb3J5IiwgImNjIgorICAgICAgICAgICAgICAgICAgICApOworfQorCit2b2lkIF9fY3lnX3Byb2ZpbGVfZnVuY19leGl0KHZvaWQgKnRoaXNfZm4sIHZvaWQgKmNhbGxfc2l0ZSkKK19fYXR0cmlidXRlX18oKG5vX2luc3RydW1lbnRfZnVuY3Rpb24pKTsKKwordm9pZCBfX2N5Z19wcm9maWxlX2Z1bmNfZXhpdCh2b2lkICp0aGlzX2ZuLCB2b2lkICpjYWxsX3NpdGUpCit7CisgICAgICAgYXNtIHZvbGF0aWxlKCIgIG1vdmwgICAgJSVlc3AsJSVlZGkgICAgIFxuIgorICAgICAgICAgICAgICAgICAgICAiICBhbmRsICAgICUwLCUlZWRpICAgICAgICBcbiIKKyAgICAgICAgICAgICAgICAgICAgIiAgYWRkbCAgICAlMSwlJWVkaSAgICAgICAgXG4iCisgICAgICAgICAgICAgICAgICAgICIgIG1vdmwgICAgJSVlc3AsJSVlY3ggICAgIFxuIgorICAgICAgICAgICAgICAgICAgICAiICBzdWJsICAgICUlZWRpLCUlZWN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nBjX3BlZXIsIHRpbWVvdXQpOworCisJX2RlYnVnKCJSeCBQRUVSIFRJTUVPVVQgWyVwe3U9JWR9XSIsIHBlZXIsIGF0b21pY19yZWFkKCZwZWVyLT51c2FnZSkpOworCisJcnhycGNfcGVlcl9kb190aW1lb3V0KHBlZXIpOworfQorCitzdGF0aWMgY29uc3Qgc3RydWN0IHJ4cnBjX3RpbWVyX29wcyByeHJwY19wZWVyX3RpbWVyX29wcyA9IHsKKwkudGltZWRfb3V0CT0gX19yeHJwY19wZWVyX3RpbWVvdXQsCit9OworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisvKgorICogY3JlYXRlIGEgcGVlciByZWNvcmQKKyAqLworc3RhdGljIGludCBfX3J4cnBjX2NyZWF0ZV9wZWVyKHN0cnVjdCByeHJwY190cmFuc3BvcnQgKnRyYW5zLCBfX2JlMzIgYWRkciwKKwkJCSAgICAgICBzdHJ1Y3QgcnhycGNfcGVlciAqKl9wZWVyKQoreworCXN0cnVjdCByeHJwY19wZWVyICpwZWVyOworCisJX2VudGVyKCIlcCwlMDh4IiwgdHJhbnMsIG50b2hsKGFkZHIpKTsKKworCS8qIGFsbG9jYXRlIGFuZCBpbml0aWFsaXNlIGEgcGVlciByZWNvcmQgKi8KKwlwZWVyID0ga21hbGxvYyhzaXplb2Yoc3RydWN0IHJ4cnBjX3BlZXIpLCBHRlBfS0VSTkVMKTsKKwlpZiAoIXBlZXIpIHsKKwkJX2xlYXZlKCIgPSAtRU5PTUVNIik7CisJCXJldHVybiAtRU5PTUVNOworCX0KKworCW1lbXNldChwZWVyLCAwLCBzaXplb2Yoc3RydWN0IHJ4cnBjX3BlZXIpKTsKKwlhdG9taWNfc2V0KCZwZWVyLT51c2FnZSwgMSk7CisKKwlJTklUX0xJU1RfSEVBRCgmcGVlci0+bGluayk7CisJSU5JVF9MSVNUX0hFQUQoJnBlZXItPnByb2Nfb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2h0IG9mZiAqLworIGZvdW5kX2FjdGl2ZToKKwlyeHJwY19nZXRfcGVlcihwZWVyKTsKKwlyZWFkX3VubG9jaygmdHJhbnMtPnBlZXJfbG9jayk7CisJZ290byBzdWNjZXNzOworCisJLyogaGFuZGxlIHJlc3VycmVjdGluZyBhIHBlZXIgZnJvbSB0aGUgZ3JhdmV5YXJkICovCisgZm91bmRfaW5fZ3JhdmV5YXJkOgorCXJ4cnBjX2dldF9wZWVyKHBlZXIpOworCXJ4cnBjX2dldF90cmFuc3BvcnQocGVlci0+dHJhbnMpOworCXJ4cnBjX2tyeHRpbW9kX2RlbF90aW1lcigmcGVlci0+dGltZW91dCk7CisJbGlzdF9kZWxfaW5pdCgmcGVlci0+bGluayk7CisJc3Bpbl91bmxvY2soJnRyYW5zLT5wZWVyX2d5bG9jayk7CisJZ290byBtYWtlX2FjdGl2ZTsKKworCS8qIGhhbmRsZSBmaW5kaW5nIHRoZSBwZWVyIG9uIHRoZSBzZWNvbmQgdGltZSB0aHJvdWdoIHRoZSBhY3RpdmUKKwkgKiBsaXN0ICovCisgZm91bmRfYWN0aXZlX3NlY29uZF9jaGFuY2U6CisJcnhycGNfZ2V0X3BlZXIocGVlcik7CisJZ290byBzdWNjZXNzX3V3ZnJlZTsKKworfSAvKiBlbmQgcnhycGNfcGVlcl9sb29rdXAoKSAqLworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisvKgorICogZmluaXNoIHdpdGggYSBwZWVyIHJlY29yZAorICogLSBpdCBnZXRzIHNlbnQgdG8gdGhlIGdyYXZleWFyZCBmcm9tIHdoZXJlIGl0IGNhbiBiZSByZXN1cnJlY3RlZCBvciB0aW1lZAorICogICBvdXQKKyAqLwordm9pZCByeHJwY19wdXRfcGVlcihzdHJ1Y3QgcnhycGNfcGVlciAqcGVlcikKK3sKKwlzdHJ1Y3QgcnhycGNfdHJhbnNwb3J0ICp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qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKy8qCisgKiBoYW5kbGUgYSBwZWVyIHRpbWluZyBvdXQgaW4gdGhlIGdyYXZleWFyZAorICogLSBjYWxsZWQgZnJvbSBrcnh0aW1vZAorICovCitzdGF0aWMgdm9pZCByeHJwY19wZWVyX2RvX3RpbWVvdXQoc3RydWN0IHJ4cnBjX3BlZXIgKnBlZXIpCit7CisJc3RydWN0IHJ4cnBjX3RyYW5zcG9ydCAqdHJhbnMgPSBwZWVyLT50cmFuczsKKworCV9lbnRlcigiJXB7dT0lZCBjYz0lZCBhPSUwOHh9IiwKKwkgICAgICAgcGVlciwKKwkgICAgICAgYXRvbWljX3JlYWQoJnBlZXItPnVzYWdlKSwKKwkgICAgICAgYXRvbWljX3JlYWQoJnBlZXItPmNvbm5fY291bnQpLAorCSAgICAgICBudG9obChwZWVyLT5hZGRyLnNfYWRkcikpOworCisJQlVHX09OKGF0b21pY19yZWFkKCZwZWVyLT51c2FnZSkgPCAwKTsKKworCS8qIHJlbW92ZSBmcm9tIGdyYXZleWFyZCBpZiBzdGlsbCBkZWFkICovCisJc3Bpbl9sb2NrKCZ0cmFucy0+cGVlcl9neWxvY2spOworCWlmIChhdG9taWNfcmVhZCgmcGVlci0+dXNhZ2UpID09IDApCisJCWxpc3RfZGVsX2luaXQoJnBlZXItPmxpbmspOworCWVsc2UKKwkJcGVlciA9IE5VTEw7CisJc3Bpbl91bmxvY2soJnRyYW5zLT5wZWVyX2d5bG9jayk7CisKKwlpZiAoIXBlZXIpIHsKKwkJX2xlYXZlKCIiKTsKKwkJcmV0dXJuOyAvKiByZXN1cnJlY3RlZCAqLworCX0KKworCS8qIGNsZWFyIGFsbCBjb25uZWN0aW9ucyBvbiB0aGlzIHBlZXIgKi8KKwlyeHJwY19jb25uX2NsZWFyYWxsKHBlZXIpOworCisJQlVHX09OKCFsaXN0X2VtcHR5KCZwZW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nQsCisJLm5leHQJPSByeHJwY19wcm9jX2NhbGxzX25leHQsCisJLnN0b3AJPSByeHJwY19wcm9jX2NhbGxzX3N0b3AsCisJLnNob3cJPSByeHJwY19wcm9jX2NhbGxzX3Nob3csCit9OworCitzdGF0aWMgc3RydWN0IGZpbGVfb3BlcmF0aW9ucyByeHJwY19wcm9jX2NhbGxzX2ZvcHMgPSB7CisJLm9wZW4JCT0gcnhycGNfcHJvY19jYWxsc19vcGVuLAorCS5yZWFkCQk9IHNlcV9yZWFkLAorCS5sbHNlZWsJCT0gc2VxX2xzZWVrLAorCS5yZWxlYXNlCT0gc2VxX3JlbGVhc2UsCit9OworCitzdGF0aWMgY29uc3QgY2hhciAqcnhycGNfY2FsbF9zdGF0ZXM3W10gPSB7CisJImNvbXBsZXQiLAorCSJlcnJvciAgIiwKKwkicmN2X29wICIsCisJInJjdl9hcmciLAorCSJnb3RfYXJnIiwKKwkic25kX3JwbCIsCisJImZpbl9hY2siLAorCSJzbmRfYXJnIiwKKwkicmN2X3JwbCIsCisJImdvdF9ycGwiCit9OworCitzdGF0aWMgY29uc3QgY2hhciAqcnhycGNfY2FsbF9lcnJvcl9zdGF0ZXM3W10gPSB7CisJIm5vX2VyciAiLAorCSJsb2NfYWJ0IiwKKwkicm10X2FidCIsCisJImxvY19lcnIiLAorCSJybXRfZXJyIgorfTsKKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworLyoKKyAqIGluaXRpYWxpc2UgdGhlIC9wcm9jL25ldC9yeHJwYy8gZGlyZWN0b3J5CisgKi8KK2ludCByeHJwY19wcm9jX2luaXQodm9pZCkKK3sKKwlzdHJ1Y3QgcHJvY19kaXJfZW50cnkgKnA7CisKKwlwcm9jX3J4cnBjID0gcHJvY19ta2RpcigicnhycGMiLCBwcm9jX25ldCk7CisJaWYgKCFwcm9jX3J4cnBjKQorCQlnb3RvIGVycm9yOworCXByb2N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XJuIHJldDsKKworCW0gPSBmaWxlLT5wcml2YXRlX2RhdGE7CisJbS0+cHJpdmF0ZSA9IFBERShpbm9kZSktPmRhdGE7CisKKwlyZXR1cm4gMDsKK30gLyogZW5kIHJ4cnBjX3Byb2NfdHJhbnNwb3J0c19vcGVuKCkgKi8KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworLyoKKyAqIHNldCB1cCB0aGUgaXRlcmF0b3IgdG8gc3RhcnQgcmVhZGluZyBmcm9tIHRoZSB0cmFuc3BvcnRzIGxpc3QgYW5kIHJldHVybiB0aGUgZmlyc3QgaXRlbQorICovCitzdGF0aWMgdm9pZCAqcnhycGNfcHJvY190cmFuc3BvcnRzX3N0YXJ0KHN0cnVjdCBzZXFfZmlsZSAqbSwgbG9mZl90ICpfcG9zKQoreworCXN0cnVjdCBsaXN0X2hlYWQgKl9wOworCWxvZmZfdCBwb3MgPSAqX3BvczsKKworCS8qIGxvY2sgdGhlIGxpc3QgYWdhaW5zdCBtb2RpZmljYXRpb24gKi8KKwlkb3duX3JlYWQoJnJ4cnBjX3Byb2NfdHJhbnNwb3J0c19zZW0pOworCisJLyogYWxsb3cgZm9yIHRoZSBoZWFkZXIgbGluZSAqLworCWlmICghcG9zKQorCQlyZXR1cm4gU0VRX1NUQVJUX1RPS0VOOworCXBvcy0tOworCisJLyogZmluZCB0aGUgbid0aCBlbGVtZW50IGluIHRoZSBsaXN0ICovCisJbGlzdF9mb3JfZWFjaChfcCwgJnJ4cnBjX3Byb2NfdHJhbnNwb3J0cykKKwkJaWYgKCFwb3MtLSkKKwkJCWJyZWFrOworCisJcmV0dXJuIF9wICE9ICZyeHJwY19wcm9jX3RyYW5zcG9ydHMgPyBfcCA6IE5VTEw7Cit9IC8qIGVuZCByeHJwY19wcm9jX3RyYW5zcG9ydHNfc3RhcnQoKSAqLworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisvKgorICogbW92ZSB0byBuZXh0IGNhbGwgaW4gdHJhbnNwb3J0cyBsaXN0CisgKi8KK3N0YXRpYyB2b2lkICpyeHJwY19wcm9jX3RyYW5zcG9ydHNfbmV4dChzdHJ1Y3Qgc2VxX2ZpbGUgKnAsIHZvaWQgKnYsIGxvZmZfdCAqcG9zKQoreworCXN0cnVjdCBsaXN0X2hlYWQgKl9wOworCisJKCpwb3MpKys7CisKKwlfcCA9IHY7CisJX3AgPSAodiA9PSBTRVFfU1RBUlRfVE9LRU4pID8gcnhycGNfcHJvY190cmFuc3BvcnRzLm5leHQgOiBfcC0+bmV4dDsKKworCXJldHVybiBfcCAhPSAmcnhycGNfcHJvY190cmFuc3BvcnRzID8gX3AgOiBOVUxMOworfSAvKiBlbmQgcnhycGNfcHJvY190cmFuc3BvcnRzX25leHQoKSAqLworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisvKgorICogY2xlYW4gdXAgYWZ0ZXIgcmVhZGluZyBmcm9tIHRoZSB0cmFuc3BvcnRzIGxpc3QKKyAqLworc3RhdGljIHZvaWQgcnhycGNfcHJvY190cmFuc3BvcnRzX3N0b3Aoc3RydWN0IHNlcV9maWxlICpwLCB2b2lkICp2KQoreworCXVwX3JlYWQoJnJ4cnBjX3Byb2NfdHJhbnNwb3J0c19zZW0pOworCit9IC8qIGVuZCByeHJwY19wcm9jX3RyYW5zcG9ydHNfc3RvcCgpICovCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKy8qCisgKiBkaXNwbGF5IGEgaGVhZGVyIGxpbmUgZm9sbG93ZWQgYnkgYSBsb2FkIG9mIGNhbGwgbGluZXMKKyAqLworc3RhdGljIGludCByeHJwY19wcm9jX3RyYW5zcG9ydHNfc2hvdyhzdHJ1Y3Qgc2VxX2ZpbGUgKm0sIHZvaWQgKnYpCit7CisJc3RydWN0IHJ4cnBjX3RyYW5zcG9ydCAqdHJhbnMgPQorCQlsaXN0X2VudHJ5KHYsIHN0cnVjdCByeHJwY190cmFuc3BvcnQsIHByb2NfbGluayk7CisKKwkvKiBkaXNwbGF5IGhlYWRlciBvbiBsaW5lIDEgKi8KKwlpZiAodiA9PSBTRVFfU1RBUlRfVE9LRU4pIHsKKwkJc2VxX3B1dHMobSwgIkxPQ0FMIFVTRVxuIik7CisJCXJldHVybiAwOworCX0KKworCS8qIGRpc3BsYXkgb25lIHRyYW5zcG9ydCBwZXIgbGluZSBvbiBzdWJzZXF1ZW50IGxpbmVzICovCisJc2VxX3ByaW50ZihtLCAiJTVodSAlM2RcbiIsCisJCSAgIHRyYW5zLT5wb3J0LAorCQkgICBhdG9taWNfcmVhZCgmdHJhbnMtPnVzYWdlKQorCQkgICApOworCisJcmV0dXJuIDA7Cit9IC8qIGVuZCByeHJwY19wcm9jX3RyYW5zcG9ydHNfc2hvdygpICovCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKy8qCisgKiBvcGVuICIvcHJvYy9uZXQvcnhycGMvcGVlcnMiIHdoaWNoIHByb3ZpZGVzIGEgc3VtbWFyeSBvZiBleHRhbnQgcGVlcnMKKyAqLworc3RhdGljIGludCByeHJwY19wcm9jX3BlZXJzX29wZW4oc3RydWN0IGlub2RlICppbm9kZSwgc3RydWN0IGZpbGUgKmZpbGUpCit7CisJc3RydWN0IHNlcV9maWxlICptOworCWludCByZXQ7CisKKwlyZXQgPSBzZXFfb3BlbihmaWxlLCAmcnhycGNfcHJvY19wZWVyc19vcHMpOworCWlmIChyZXQgPCAwKQorCQlyZXR1cm4gcmV0OworCisJbSA9IGZpbGUtPnByaXZhdGVfZGF0YTsKKwltLT5wcml2YXRlID0gUERFKGlub2RlKS0+ZGF0YTsKKworCXJldHVybiAwOworfSAvKiBlbmQgcnhycGNfcHJvY19wZWVyc19vcGVuKCkgKi8KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworLyoKKyAqIHNldCB1cCB0aGUgaXRlcmF0b3IgdG8gc3RhcnQgcmVhZGluZyBmcm9tIHRoZSBwZWVycyBsaXN0IGFuZCByZXR1cm4gdGhlCisgKiBmaXJzdCBpdGVtCisgKi8KK3N0YXRpYyB2b2lkICpyeHJwY19wcm9jX3BlZXJzX3N0YXJ0KHN0cnVjdCBzZXFfZmlsZSAqbSwgbG9mZl90ICpfcG9zKQoreworCXN0cnVjdCBsaXN0X2hlYWQgKl9wOworCWxvZmZfdCBwb3MgPSAqX3BvczsKKworCS8qIGxvY2sgdGhlIGxpc3QgYWdhaW5zdCBtb2RpZmljYXRpb24gKi8KKwlkb3duX3JlYWQoJnJ4cnBjX3BlZXJzX3NlbSk7CisKKwkvKiBhbGxvdyBmb3IgdGhlIGhlYWRlciBsaW5lICovCisJaWYgKCFwb3MpCisJCXJldHVybiBTRVFfU1RBUlRfVE9LRU47CisJcG9zLS07CisKKwkvKiBmaW5kIHRoZSBuJ3RoIGVsZW1lbnQgaW4gdGhlIGxpc3QgKi8KKwlsaXN0X2Zvcl9lYWNoKF9wLCAmcnhycGNfcGVlcnMpCisJCWlmICghcG9zLS0pCisJCQlicmVhazsKKworCXJldHVybiBfcCAhPSAmcnhycGNfcGVlcnMgPyBfcCA6IE5VTEw7Cit9IC8qIGVuZCByeHJwY19wcm9jX3BlZXJzX3N0YXJ0KCkgKi8KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworLyoKKyAqIG1vdmUgdG8gbmV4dCBjb25uIGluIHBlZXJzIGxpc3QKKyAqLworc3RhdGljIHZvaWQgKnJ4cnBjX3Byb2NfcGVlcnNfbmV4dChzdHJ1Y3Qgc2VxX2ZpbGUgKnAsIHZvaWQgKnYsIGxvZmZfdCAqcG9zKQoreworCXN0cnVjdCBsaXN0X2hlYWQgKl9wOworCisJKCpwb3MpKys7CisKKwlfcCA9IHY7CisJX3AgPSAodiA9PSBTRVFfU1RBUlRfVE9LRU4pID8gcnhycGNfcGVlcnMubmV4dCA6IF9wLT5uZXh0OworCisJcmV0dXJuIF9wICE9ICZyeHJwY19wZWVycyA/IF9wIDogTlVMTDsKK30gLyogZW5kIHJ4cnBjX3Byb2NfcGVlcnNfbmV4dCgpICovCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKy8qCisgKiBjbGVhbiB1cCBhZnRlciByZWFkaW5nIGZyb20gdGhlIHBlZXJzIGxpc3QKKyAqLworc3RhdGljIHZvaWQgcnhycGNfcHJvY19wZWVyc19zdG9wKHN0cnVjdCBzZXFfZmlsZSAqcCwgdm9pZCAqdikKK3sKKwl1cF9yZWFkKCZyeHJwY19wZWVyc19zZW0pOworCit9IC8qIGVuZCByeHJwY19wcm9jX3BlZXJzX3N0b3AoKSAqLworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisvKgorICogZGlzcGxheSBhIGhlYWRlciBsaW5lIGZvbGxvd2VkIGJ5IGEgbG9hZCBvZiBjb25uIGxpbmVzCisgKi8KK3N0YXRpYyBpbnQgcnhycGNfcHJvY19wZWVyc19zaG93KHN0cnVjdCBzZXFfZmlsZSAqbSwgdm9pZCAqdikKK3sKKwlzdHJ1Y3QgcnhycGNfcGVlciAqcGVlciA9IGxpc3RfZW50cnkodiwgc3RydWN0IHJ4cnBjX3BlZXIsIHByb2NfbGluayk7CisJc2lnbmVkIGxvbmcgdGltZW91dDsKKworCS8qIGRpc3BsYXkgaGVhZGVyIG9uIGxpbmUgMSAqLworCWlmICh2ID09IFNFUV9TVEFSVF9UT0tFTikgeworCQlzZXFfcHV0cyhtLCAiTE9DQUwgUkVNT1RFICAgVVNBR0UgQ09OTlMgIFRJTUVPVVQiCisJCQkgIiAgIE1UVSBSVFQodVMpXG4iKTsKKwkJcmV0dXJuIDA7CisJfQorCisJLyogZGlzcGxheSBvbmUgcGVlciBwZXIgbGluZSBvbiBzdWJzZXF1ZW50IGxpbmVzICovCisJdGltZW91dCA9IDA7CisJaWYgKCFsaXN0X2VtcHR5KCZwZWVyLT50aW1lb3V0LmxpbmspKQorCQl0aW1lb3V0ID0gKHNpZ25lZCBsb25nKSBwZWVyLT50aW1lb3V0LnRpbW9famlmIC0KKwkJCShzaWduZWQgbG9uZykgamlmZmllczsKKworCXNlcV9wcmludGYobSwgIiU1aHUgJTA4eCAlNWQgJTVkICU4bGQgJTVadSAlN2x1XG4iLAorCQkgICBwZWVyLT50cmFucy0+cG9ydCwKKwkJICAgbnRvaGwocGVlci0+YWRkci5zX2FkZHIpLAorCQkgICBhdG9taWNfcmVhZCgmcGVlci0+dXNhZ2UpLAorCQkgICBhdG9taWNfcmVhZCgmcGVlci0+Y29ubl9jb3VudCksCisJCSAgIHRpbWVvdXQsCisJCSAgIHBlZXItPmlmX210dSwKKwkJICAgKGxvbmcpIHBlZXItPnJ0dAorCQkgICApOworCisJcmV0dXJuIDA7Cit9IC8qIGVuZCByeHJwY19wcm9jX3BlZXJzX3Nob3coKSAqLworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisvKgorICogb3BlbiAiL3Byb2MvbmV0L3J4cnBjL2Nvbm5lY3Rpb25zIiB3aGljaCBwcm92aWRlcyBhIHN1bW1hcnkgb2YgZXh0YW50CisgKiBjb25uZWN0aW9ucworICovCitzdGF0aWMgaW50IHJ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tLSkKKwkJCWJyZWFrOworCisJcmV0dXJuIF9wICE9ICZyeHJwY19jb25ucyA/IF9wIDogTlVMTDsKK30gLyogZW5kIHJ4cnBjX3Byb2NfY29ubnNfc3RhcnQoKSAqLworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisvKgorICogbW92ZSB0byBuZXh0IGNvbm4gaW4gY29ubnMgbGlzdAorICovCitzdGF0aWMgdm9pZCAqcnhycGNfcHJvY19jb25uc19uZXh0KHN0cnVjdCBzZXFfZmlsZSAqcCwgdm9pZCAqdiwgbG9mZl90ICpwb3MpCit7CisJc3RydWN0IGxpc3RfaGVhZCAqX3A7CisKKwkoKnBvcykrKzsKKworCV9wID0gdjsKKwlfcCA9ICh2ID09IFNFUV9TVEFSVF9UT0tFTikgPyByeHJwY19jb25ucy5uZXh0IDogX3AtPm5leHQ7CisKKwlyZXR1cm4gX3AgIT0gJnJ4cnBjX2Nvbm5zID8gX3AgOiBOVUxMOworfSAvKiBlbmQgcnhycGNfcHJvY19jb25uc19uZXh0KCkgKi8KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworLyoKKyAqIGNsZWFuIHVwIGFmdGVyIHJlYWRpbmcgZnJvbSB0aGUgY29ubnMgbGlzdAorICovCitzdGF0aWMgdm9pZCByeHJwY19wcm9jX2Nvbm5zX3N0b3Aoc3RydWN0IHNlcV9maWxlICpwLCB2b2lkICp2KQoreworCXVwX3JlYWQoJnJ4cnBjX2Nvbm5zX3NlbSk7CisKK30gLyogZW5kIHJ4cnBjX3Byb2NfY29ubnNfc3RvcCgpICovCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKy8qCisgKiBkaXNwbGF5IGEgaGVhZGV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udG9obChjb25uLT5jb25uX2lkKSwKKwkJICAgY29ubi0+b3V0X2NsaWVudGZsYWcgPyAiQ0xUIiA6ICJTUlYiLAorCQkgICBjb25uLT5zZXJpYWxfY291bnRlciwKKwkJICAgY29ubi0+Y2FsbF9jb3VudGVyLAorCQkgICBjb25uLT5tdHVfc2l6ZSwKKwkJICAgdGltZW91dAorCQkgICApOworCisJcmV0dXJuIDA7Cit9IC8qIGVuZCByeHJwY19wcm9jX2Nvbm5zX3Nob3coKSAqLworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisvKgorICogb3BlbiAiL3Byb2MvbmV0L3J4cnBjL2NhbGxzIiB3aGljaCBwcm92aWRlcyBhIHN1bW1hcnkgb2YgZXh0YW50IGNhbGxzCisgKi8KK3N0YXRpYyBpbnQgcnhycGNfcHJvY19jYWxsc19vcGVuKHN0cnVjdCBpbm9kZSAqaW5vZGUsIHN0cnVjdCBmaWxlICpmaWxlKQoreworCXN0cnVjdCBzZXFfZmlsZSAqbTsKKwlpbnQgcmV0OworCisJcmV0ID0gc2VxX29wZW4oZmlsZSwgJnJ4cnBjX3Byb2NfY2FsbHNfb3BzKTsKKwlpZiAocmV0IDwgMCkKKwkJcmV0dXJuIHJldDsKKworCW0gPSBmaWxlLT5wcml2YXRlX2RhdGE7CisJbS0+cHJpdmF0ZSA9IFBERShpbm9kZSktPmRhdGE7CisKKwlyZXR1cm4gMDsKK30gLyogZW5kIHJ4cnBjX3Byb2NfY2FsbHNfb3BlbigpICovCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKy8qCisgKiBzZXQgdXAgdGhlIGl0ZXJhdG9yIHRvIHN0YXJ0IHJlYWRpbmcgZnJvbSB0aGUgY2FsbHMgbGlzdCBhbmQgcmV0dXJuIHRoZQorICogZmlyc3Q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it9IC8qIGVuZCByeHJwY19wcm9jX2NhbGxzX25leHQoKSAqLworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisvKgorICogY2xlYW4gdXAgYWZ0ZXIgcmVhZGluZyBmcm9tIHRoZSBjYWxscyBsaXN0CisgKi8KK3N0YXRpYyB2b2lkIHJ4cnBjX3Byb2NfY2FsbHNfc3RvcChzdHJ1Y3Qgc2VxX2ZpbGUgKnAsIHZvaWQgKnYpCit7CisJdXBfcmVhZCgmcnhycGNfY2FsbHNfc2VtKTsKKworfSAvKiBlbmQgcnhycGNfcHJvY19jYWxsc19zdG9wKCkgKi8KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworLyoKKyAqIGRpc3BsYXkgYSBoZWFkZXIgbGluZSBmb2xsb3dlZCBieSBhIGxvYWQgb2YgY2FsbCBsaW5lcworICovCitzdGF0aWMgaW50IHJ4cnBjX3Byb2NfY2FsbHNfc2hvdyhzdHJ1Y3Qgc2VxX2ZpbGUgKm0sIHZvaWQgKnYpCit7CisJc3RydWN0IHJ4cnBjX2NhbGwgKmNhbGwgPSBsaXN0X2VudHJ5KHYsIHN0cnVjdCByeHJwY19jYWxsLCBjYWxsX2xpbmspOworCisJLyogZGlzcGxheSBoZWFkZXIgb24gbGluZSAxICovCisJaWYgKHYgPT0gU0VRX1NUQVJUX1RPS0VOKSB7CisJCXNlcV9wdXRzKG0sCisJCQkgIkxPQ0FMIFJFTU9UIFNSVkMgQ09OTiAgICAgQ0FMTCAgICAgRElSIFVTRSAiCisJCQkgIiBMIFNUQVRFICAgT1BDT0RFIEFCT1JUICAgIEVSUk5PXG4iCisJCQkgKTsKKwkJcmV0dXJuIDA7CisJfQorCisJLyogZGlzcGxheSBvbmUgY2FsbCBwZXIgbGluZSBvbiBzdWJzZXF1ZW50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CS5jdGxfbmFtZQk9IDEsCisJCS5wcm9jbmFtZQk9ICJyeHJwYyIsCisJCS5tYXhsZW4JCT0gMCwKKwkJLm1vZGUJCT0gMDU1NSwKKwkJLmNoaWxkCQk9IHJ4cnBjX3N5c2N0bF90YWJsZQorCX0sCisJeyAuY3RsX25hbWUgPSAwIH0KK307CisjZW5kaWYgLyogQ09ORklHX1NZU0NUTCAqLworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisvKgorICogaW5pdGlhbGlzZSB0aGUgc3lzY3RsIHN0dWZmIGZvciBSeCBSUEMKKyAqLworaW50IHJ4cnBjX3N5c2N0bF9pbml0KHZvaWQpCit7CisjaWZkZWYgQ09ORklHX1NZU0NUTAorCXJ4cnBjX3N5c2N0bCA9IHJlZ2lzdGVyX3N5c2N0bF90YWJsZShyeHJwY19kaXJfc3lzY3RsX3RhYmxlLCAwKTsKKwlpZiAoIXJ4cnBjX3N5c2N0bCkKKwkJcmV0dXJuIC1FTk9NRU07CisjZW5kaWYgLyogQ09ORklHX1NZU0NUTCAqLworCisJcmV0dXJuIDA7Cit9IC8qIGVuZCByeHJwY19zeXNjdGxfaW5pdCgpICovCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKy8qCisgKiBjbGVhbiB1cCB0aGUgc3lzY3RsIHN0dWZmIGZvciBSeCBSUEMKKyAqLwordm9pZCByeHJwY19zeXNjdGxfY2xlYW51cCh2b2lkKQoreworI2lmZGVmIENPTkZJR19TWVNDVEwKKwlpZiAocnhycGNfc3lzY3RsKSB7CisJCXVucmVnaXN0ZXJfc3lzY3RsX3RhYmxlKHJ4cnBjX3N5c2N0bCk7CisJCXJ4cnBjX3N5c2N0bCA9IE5VTEw7CisJfQorI2VuZGlmIC8qIENPTkZJR19TWVNDVEwgKi8KKwor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RlKCZyeHJwY19wcm9jX3RyYW5zcG9ydHNfc2VtKTsKKworCV9fUlhBQ0NUKGF0b21pY19pbmMoJnJ4cnBjX3RyYW5zcG9ydF9jb3VudCkpOworCisJKl90cmFucyA9IHRyYW5zOworCV9sZWF2ZSgiID0gMCAoJXApIiwgdHJhbnMpOworCXJldHVybiAwOworCisgZXJyb3I6CisJLyogZmluaXNoIGNsZWFuaW5nIHVwIHRoZSB0cmFuc3BvcnQgKG5vdCByZWFsbHkgbmVlZGVkIGhlcmUsIGJ1dC4uLikgKi8KKwlpZiAodHJhbnMtPnNvY2tldCkKKwkJdHJhbnMtPnNvY2tldC0+b3BzLT5zaHV0ZG93bih0cmFucy0+c29ja2V0LCAyKTsKKworCS8qIGNsb3NlIHRoZSBzb2NrZXQgKi8KKwlpZiAodHJhbnMtPnNvY2tldCkgeworCQl0cmFucy0+c29ja2V0LT5zay0+c2tfdXNlcl9kYXRhID0gTlVMTDsKKwkJc29ja19yZWxlYXNlKHRyYW5zLT5zb2NrZXQpOworCQl0cmFucy0+c29ja2V0ID0gTlVMTDsKKwl9CisKKwlrZnJlZSh0cmFucyk7CisKKworCV9sZWF2ZSgiID0gJWQiLCByZXQpOworCXJldHVybiByZXQ7Cit9IC8qIGVuZCByeHJwY19jcmVhdGVfdHJhbnNwb3J0KCkgKi8KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworLyoKKyAqIGRlc3Ryb3kgYSB0cmFuc3BvcnQgZW5kcG9pbnQKKyAqLwordm9pZCByeHJwY19wdXRfdHJhbnNwb3J0KHN0cnVjdCByeHJwY190cmFuc3BvcnQgKnRyYW5zKQoreworCV9lbnRlcigiJXB7dT0lZCBwPSVodX0iLAorCSAgICAgICB0cmFucywgYXRvbWljX3JlYWQoJnRyYW5zLT51c2FnZSksIHRyYW5zLT5wb3J0KTsKKworCUJVR19PTihhdG9taWNfcmVhZCgmdHJh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PnNvY2tldC0+c2stPnNrX3VzZXJfZGF0YSA9IE5VTEw7CisJCXNvY2tfcmVsZWFzZSh0cmFucy0+c29ja2V0KTsKKwkJdHJhbnMtPnNvY2tldCA9IE5VTEw7CisJfQorCisJa2ZyZWUodHJhbnMpOworCisJX2xlYXZlKCIiKTsKK30gLyogZW5kIHJ4cnBjX3B1dF90cmFuc3BvcnQoKSAqLworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisvKgorICogYWRkIGEgc2VydmljZSB0byBhIHRyYW5zcG9ydCB0byBiZSBsaXN0ZW5lZCB1cG9uCisgKi8KK2ludCByeHJwY19hZGRfc2VydmljZShzdHJ1Y3QgcnhycGNfdHJhbnNwb3J0ICp0cmFucywKKwkJICAgICAgc3RydWN0IHJ4cnBjX3NlcnZpY2UgKm5ld3NydikKK3sKKwlzdHJ1Y3QgcnhycGNfc2VydmljZSAqc3J2OworCXN0cnVjdCBsaXN0X2hlYWQgKl9wOworCWludCByZXQgPSAtRUVYSVNUOworCisJX2VudGVyKCIlcHslaHV9LCVweyVodX0iLAorCSAgICAgICB0cmFucywgdHJhbnMtPnBvcnQsIG5ld3NydiwgbmV3c3J2LT5zZXJ2aWNlX2lkKTsKKworCS8qIHZlcmlmeSB0aGF0IHRoZSBzZXJ2aWNlIElEIGlzIG5vdCBhbHJlYWR5IHByZXNlbnQgKi8KKwlzcGluX2xvY2soJnRyYW5zLT5sb2NrKTsKKworCWxpc3RfZm9yX2VhY2goX3AsICZ0cmFucy0+c2VydmljZXMpIHsKKwkJc3J2ID0gbGlzdF9lbnRyeShfcCwgc3RydWN0IHJ4cnBjX3NlcnZpY2UsIGxpbmspOworCQlpZiAoc3J2LT5zZXJ2aWNlX2lkID09IG5ld3Nydi0+c2VydmljZV9pZCkKKwkJCWdvdG8gb3V0OworCX0KKworCS8qIG9rYXkgLSBhZGQgdGhlIHRyYW5zcG9ydCB0byB0aGUgbGlzdCAqLworCWxpc3RfYWRkX3RhaWwoJm5ld3Nydi0+bGluaywgJnRyYW5zLT5zZXJ2aWNlcyk7CisJcnhycGNfZ2V0X3RyYW5zcG9ydCh0cmFucyk7CisJcmV0ID0gMDsKKworIG91dDoKKwlzcGluX3VubG9jaygmdHJhbnMtPmxvY2spOworCisJX2xlYXZlKCI9ICVkIiwgcmV0KTsKKwlyZXR1cm4gcmV0OworfSAvKiBlbmQgcnhycGNfYWRkX3NlcnZpY2UoKSAqLworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisvKgorICogcmVtb3ZlIGEgc2VydmljZSBmcm9tIGEgdHJhbnNwb3J0CisgKi8KK3ZvaWQgcnhycGNfZGVsX3NlcnZpY2Uoc3RydWN0IHJ4cnBjX3RyYW5zcG9ydCAqdHJhbnMsIHN0cnVjdCByeHJwY19zZXJ2aWNlICpzcnYpCit7CisJX2VudGVyKCIlcHslaHV9LCVweyVodX0iLCB0cmFucywgdHJhbnMtPnBvcnQsIHNydiwgc3J2LT5zZXJ2aWNlX2lkKTsKKworCXNwaW5fbG9jaygmdHJhbnMtPmxvY2spOworCWxpc3RfZGVsKCZzcnYtPmxpbmspOworCXNwaW5fdW5sb2NrKCZ0cmFucy0+bG9jayk7CisKKwlyeHJwY19wdXRfdHJhbnNwb3J0KHRyYW5zKTsKKworCV9sZWF2ZSgiIik7Cit9IC8qIGVuZCByeHJwY19kZWxfc2VydmljZSgpICovCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKy8qCisgKiBJTkVUIGNhbGxiYWNrIHdoZW4gZGF0YSBoYXMgYmVlbiByZWNlaXZlZCBvbiB0aGUgc29ja2V0LgorICovCitzdGF0aWMgdm9pZCByeHJwY19kYXRhX3JlYWR5KHN0cnVjdCBzb2N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JfQorCQlrZnJlZV9za2IocGt0KTsKKwl9CisKKwlfbGVhdmUoIiIpOworCit9IC8qIGVuZCByeHJwY190cmFuc19yZWNlaXZlX3BhY2tldCgpICovCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKy8qCisgKiBhY2NlcHQgYSBuZXcgY2FsbCBmcm9tIGEgY2xpZW50IHRyeWluZyB0byBjb25uZWN0IHRvIG9uZSBvZiBteSBzZXJ2aWNlcworICogLSBjYWxsZWQgaW4gcHJvY2VzcyBjb250ZXh0CisgKi8KK3N0YXRpYyBpbnQgcnhycGNfdHJhbnNfcmVjZWl2ZV9uZXdfY2FsbChzdHJ1Y3QgcnhycGNfdHJhbnNwb3J0ICp0cmFucywKKwkJCQkJc3RydWN0IGxpc3RfaGVhZCAqbXNncSkKK3sKKwlzdHJ1Y3QgcnhycGNfbWVzc2FnZSAqbXNnOworCisJX2VudGVyKCIiKTsKKworCS8qIG9ubHkgYm90aGVyIHdpdGggdGhlIGZpcnN0IHBhY2tldCAqLworCW1zZyA9IGxpc3RfZW50cnkobXNncS0+bmV4dCwgc3RydWN0IHJ4cnBjX21lc3NhZ2UsIGxpbmspOworCWxpc3RfZGVsX2luaXQoJm1zZy0+bGluayk7CisJcnhycGNfa3J4c2VjZF9xdWV1ZV9pbmNvbWluZ19jYWxsKG1zZyk7CisJcnhycGNfcHV0X21lc3NhZ2UobXNnKTsKKworCV9sZWF2ZSgiID0gMCIpOworCisJcmV0dXJuIDA7Cit9IC8qIGVuZCByeHJwY190cmFuc19yZWNlaXZlX25ld19jYWxsKCkgKi8KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworLyoKKyAqIHBlcmZvcm0gYW4gaW1tZWRpYXRlIGFib3J0IHdpdGhvdXQgY29ubmVjdGlvbiBvciBjYWxsI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i9udWxsCisrKyBiL25ldC9zY2hlZC9NYWtlZmlsZQpAQCAtMCwwICsxLDQxIEBACisjCisjIE1ha2VmaWxlIGZvciB0aGUgTGludXggVHJhZmZpYyBDb250cm9sIFVuaXQuCisjCisKK29iai15CTo9IHNjaF9nZW5lcmljLm8KKworb2JqLSQoQ09ORklHX05FVF9TQ0hFRCkJCSs9IHNjaF9hcGkubyBzY2hfZmlmby5vCitvYmotJChDT05GSUdfTkVUX0NMUykJCSs9IGNsc19hcGkubworb2JqLSQoQ09ORklHX05FVF9DTFNfQUNUKSAgICAgICArPSBhY3RfYXBpLm8KK29iai0kKENPTkZJR19ORVRfQUNUX1BPTElDRSkJKz0gcG9saWNlLm8KK29iai0kKENPTkZJR19ORVRfQ0xTX1BPTElDRSkJKz0gcG9saWNlLm8KK29iai0kKENPTkZJR19ORVRfQUNUX0dBQ1QpICAgICAgKz0gZ2FjdC5vCitvYmotJChDT05GSUdfTkVUX0FDVF9NSVJSRUQpICAgICs9IG1pcnJlZC5vCitvYmotJChDT05GSUdfTkVUX0FDVF9JUFQpICAgICAgICs9IGlwdC5vCitvYmotJChDT05GSUdfTkVUX0FDVF9QRURJVCkgICAgICs9IHBlZGl0Lm8KK29iai0kKENPTkZJR19ORVRfU0NIX0NCUSkJKz0gc2NoX2NicS5vCitvYmotJChDT05GSUdfTkVUX1NDSF9IVEIpCSs9IHNjaF9odGIubworb2JqLSQoQ09ORklHX05FVF9TQ0hfSFBGUSkJKz0gc2NoX2hwZnEubworb2JqLSQoQ09ORklHX05FVF9TQ0hfSEZTQykJKz0gc2NoX2hmc2Mubworb2JqLSQoQ09ORklHX05FVF9TQ0hfUkVEKQkrPSBzY2hfcmVkLm8KK29iai0kKENPTkZJR19ORVRfU0NIX0dSRUQpCSs9IHNjaF9ncmVkLm8KK29iai0kKENPTkZJR19ORVRfU0NIX0lOR1JFU1MpCSs9IHNjaF9pbmdyZXNzLm8gCitvYmotJChDT05GSUdfTkVUX1NDSF9EU01BUkspCSs9I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mRpZgorCisJCWZvciAoaSA9IG4tPnNlbC5ua2V5czsgaT4wOyBpLS0sIGtleSsrKSB7CisKKwkJCWlmICgoKih1MzIqKShwdHIra2V5LT5vZmYrKG9mZjIma2V5LT5vZmZtYXNrKSlea2V5LT52YWwpJmtleS0+bWFzaykgeworCQkJCW4gPSBuLT5uZXh0OworCQkJCWdvdG8gbmV4dF9rbm9kZTsKKwkJCX0KKyNpZmRlZiBDT05GSUdfQ0xTX1UzMl9QRVJGCisJCQluLT5wZi0+a2NudHNbal0gKz0xOworCQkJaisrOworI2VuZGlmCisJCX0KKwkJaWYgKG4tPmh0X2Rvd24gPT0gTlVMTCkgeworY2hlY2tfdGVybWluYWw6CisJCQlpZiAobi0+c2VsLmZsYWdzJlRDX1UzMl9URVJNSU5BTCkgeworCisJCQkJKnJlcyA9IG4tPnJlczsKKyNpZmRlZiBDT05GSUdfTkVUX0NMU19JTkQKKwkJCQlpZiAoIXRjZl9tYXRjaF9pbmRldihza2IsIG4tPmluZGV2KSkgeworCQkJCQluID0gbi0+bmV4dDsKKwkJCQkJZ290byBuZXh0X2tub2RlOworCQkJCX0KKyNlbmRpZgorI2lmZGVmIENPTkZJR19DTFNfVTMyX1BFUkYKKwkJCQluLT5wZi0+cmhpdCArPTE7CisjZW5kaWYKKwkJCQlyID0gdGNmX2V4dHNfZXhlYyhza2IsICZuLT5leHRzLCByZXMpOworCQkJCWlmIChyIDwgMCkgeworCQkJCQluID0gbi0+bmV4dDsKKwkJCQkJZ290byBuZXh0X2tub2RlOworCQkJCX0KKworCQkJCXJldHVybiByOworCQkJfQorCQkJbiA9IG4tPm5leHQ7CisJCQlnb3RvIG5leHRfa25vZGU7CisJCX0KKworCQkvKiBQVVNIICovCisJCWlmIChzZGVwdGggPj0gVENfVTMyX01BWERFUFRIKQorCQkJZ290byBkZWFkbG9vcDsKKwkJc3RhY2tbc2RlcHRoXS5rbm9kZSA9IG47CisJCXN0YWNrW3NkZXB0aF0ucHRyID0gcHRyOworCQlzZ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ciBhIGluZGV4IHRvIHRoZSBtZXRhIG9wZXJhdGlvbnMgdGFibGUgY29uc2lzdGluZyBvZgorICogCWZ1bmN0aW9uIHBvaW50ZXJzIHRvIHR5cGUgc3BlY2lmaWMgbWV0YSBkYXRhIGNvbGxlY3RvcnMgcmV0dXJuaW5nCisgKiAJdGhlIHZhbHVlIG9mIHRoZSByZXF1ZXN0ZWQgbWV0YSB2YWx1ZS4KKyAqCisgKiAJICAgICAgICAgbHZhbHVlICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBydmFsdWUKKyAqIAkgICAgICArLS0tLS0tLS0tLS0rICAgICAgICAgICAgICAgICAgICAgICAgICAgKy0tLS0tLS0tLS0tKworICogCSAgICAgIHwgdHlwZTogSU5UIHwgICAgICAgICAgICAgICAgICAgICAgICAgICB8IHR5cGU6IElOVCB8CisgKiAJIGRlZiAgfCBpZDogSU5ERVYgfCAgICAgICAgICAgICAgICAgICAgICAgICAgIHwgaWQ6IFZBTFVFIHwKKyAqIAkgICAgICB8IGRhdGE6ICAgICB8ICAgICAgICAgICAgICAgICAgICAgICAgICAgfCBkYXRhOiAzICAgfAorICogCSAgICAgICstLS0tLS0tLS0tLSsgICAgICAgICAgICAgICAgICAgICAgICAgICArLS0tLS0tLS0tLS0rCisgKiAJICAgICAgICAgICAgfCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwKKyAqIAkgICAgICAgICAgICAtLS0+IG1ldGFfb3BzW0lOVF1bSU5ERVZdKC4uLikgICAgICAgICAgfAorICogICAgICAgICAgICAgICAgICAgICAgICAgICAgfCAgICAgICAgICAgICAgICAgICAgICAgICAgICB8CisgKiAJICAgICAgICAgICAgLS0tLS0tLS0tLS0gICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwKKyAqIAkgICAgICAgICAgICBWICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgVgorICogCSAgICAgICstLS0tLS0tLS0tLSsgICAgICAgICAgICAgICAgICAgIC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Wx1ZQlydmFsdWU7Cit9OworCitzdGF0aWMgaW5saW5lIGludCBtZXRhX2lkKHN0cnVjdCBtZXRhX3ZhbHVlICp2KQoreworCXJldHVybiBUQ0ZfTUVUQV9JRCh2LT5oZHIua2luZCk7Cit9CisKK3N0YXRpYyBpbmxpbmUgaW50IG1ldGFfdHlwZShzdHJ1Y3QgbWV0YV92YWx1ZSAqdikKK3sKKwlyZXR1cm4gVENGX01FVEFfVFlQRSh2LT5oZHIua2luZCk7Cit9CisKKyNkZWZpbmUgTUVUQV9DT0xMRUNUT1IoRlVOQykgc3RhdGljIHZvaWQgbWV0YV8jI0ZVTkMoc3RydWN0IHNrX2J1ZmYgKnNrYiwgXAorCXN0cnVjdCB0Y2ZfcGt0X2luZm8gKmluZm8sIHN0cnVjdCBtZXRhX3ZhbHVlICp2LCBcCisJc3RydWN0IG1ldGFfb2JqICpkc3QsIGludCAqZXJyKQorCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyAqIFN5c3RlbSBzdGF0dXMgJiBtaXNjCisgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisKK01FVEFfQ09MTEVDVE9SKGludF9yYW5kb20pCit7CisJZ2V0X3JhbmRvbV9ieXRlcygmZHN0LT52YWx1ZSwgc2l6ZW9mKGRzdC0+dmFsdWUpKTsKK30KKworc3RhdGljIGlubGluZSB1bnNpZ25lZCBsb25nIGZpeGVkX2xvYWRhdmcoaW50IGxvYWQpCit7CisJaW50IHJuZF9sb2FkID0gbG9hZCArIChGSVhFRF8xLzIwMCk7CisJaW50IHJuZF9mcmFjID0gKChybmRfbG9hZCAmIChGSVhFRF8xLTEpKSAqIDEwMCkgPj4gRlNISUZUOworCisJcmV0dXJuICgocm5kX2xvYWQgPj4gRlNISUZUKSAqIDEwMCkgKyBybmRfZnJhYzsKK30KKworTUVUQV9DT0xMRUNUT1IoaW50X2xvYWRhdmdfMCkKK3sKKwlkc3QtPnZhbHVlID0gZml4ZWRfbG9hZGF2ZyhhdmVucnVuWzBdKTsKK30KKworTUVUQV9DT0xMRUNUT1IoaW50X2xvYWRhdmdfMSkKK3sKKwlkc3QtPnZhbHVlID0gZml4ZWRfbG9hZGF2ZyhhdmVucnVuWzFdKTsKK30KKworTUVUQV9DT0xMRUNUT1IoaW50X2xvYWRhdmdfMikKK3sKKwlkc3QtPnZhbHVlID0gZml4ZWRfbG9hZGF2ZyhhdmVucnVuWzJdKTsKK30KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgKiBEZXZpY2UgbmFtZXMgJiBpbmRpY2VzCisgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisKK3N0YXRpYyBpbmxpbmUgaW50IGludF9kZXYoc3RydWN0IG5ldF9kZXZpY2UgKmRldiwgc3RydWN0IG1ldGFfb2JqICpkc3QpCit7CisJaWYgKHVubGlrZWx5KGRldiA9PSBOVUxMKSkKKwkJcmV0dXJuIC0xOworCisJZHN0LT52YWx1ZSA9IGRldi0+aWZpbmRleDsKKwlyZXR1cm4gMDsKK30KKworc3RhdGljIGlubGluZSBpbnQgdmFyX2RldihzdHJ1Y3QgbmV0X2RldmljZSAqZGV2LCBzdHJ1Y3QgbWV0YV9vYmogKmRzdCkKK3sKKwlpZiAodW5saWtlbHkoZGV2ID09IE5VTEwpKQorCQlyZXR1cm4gLTE7CisKKwlkc3QtPnZhbHVlID0gKHVuc2lnbmVkIGxvbmcpIGRldi0+bmFtZTsKKwlkc3QtPmxlbiA9IHN0cmxlbihkZXYtPm5hbWUpOworCXJldHVybiAwOworfQorCitNRVRBX0NPTExFQ1RPUihpbnRfZGV2KQoreworCSplcnIgPSBpbnRfZGV2KHNrYi0+ZGV2LCBkc3QpOworfQorCitNRVRBX0NPTExFQ1RPUih2YXJfZGV2KQoreworCSplcnIgPSB2YXJfZGV2KHNrYi0+ZGV2LCBkc3QpOworfQorCitNRVRBX0NPTExFQ1RPUihpbnRfaW5kZXYpCit7CisJKmVyciA9IGludF9kZXYoc2tiLT5pbnB1dF9kZXYsIGRzdCk7Cit9CisKK01FVEFfQ09MTEVDVE9SKHZhcl9pbmRldikKK3sKKwkqZXJyID0gdmFyX2Rldihza2ItPmlucHV0X2RldiwgZHN0KTsKK30KKworTUVUQV9DT0xMRUNUT1IoaW50X3JlYWxkZXYpCit7CisJKmVyciA9IGludF9kZXYoc2tiLT5yZWFsX2RldiwgZHN0KTsKK30KKworTUVUQV9DT0xMRUNUT1IodmFyX3JlYWxkZXYpCit7CisJKmVyciA9IHZhcl9kZXYoc2tiLT5yZWFsX2RldiwgZHN0KTsKK30KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgKiBza2IgYXR0cmlidXRlcworICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworCitNRVRBX0NPTExFQ1RPUihpbnRfcHJpb3JpdHkpCit7CisJZHN0LT52YWx1ZSA9IHNrYi0+cHJpb3JpdHk7Cit9CisKK01FVEFfQ09MTEVDVE9SKGludF9wcm90b2NvbCkKK3sKKwkvKiBMZXQgdXNlcnNwYWNlIHRha2UgY2FyZSBvZiB0aGUgYnl0ZSBvcmRlcmluZyAqLworCWRzdC0+dmFsdWUgPSBza2ItPnByb3RvY29sOworfQorCitNRVRBX0NPTExFQ1RPUihpbnRfc2VjdXJpdHkpCit7CisJZHN0LT52YWx1ZSA9IHNrYi0+c2VjdXJpdHk7Cit9CisKK01FVEFfQ09MTEVDVE9SKGludF9wa3R0eXBlKQoreworCWRzdC0+dmFsdWUgPSBza2ItPnBrdF90eXBlOworfQorCitNRVRBX0NPTExFQ1RPUihpbnRfcGt0bGVuKQoreworCWRzdC0+dmFsdWUgPSBza2ItPmxlbjsKK30KKworTUVUQV9DT0xMRUNUT1IoaW50X2RhdGFsZW4pCit7CisJZHN0LT52YWx1ZSA9IHNrYi0+ZGF0YV9sZW47Cit9CisKK01FVEFfQ09MTEVDVE9SKGludF9tYWNsZW4pCit7CisJZHN0LT52YWx1ZSA9IHNrYi0+bWFjX2xlbjsKK30KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgKiBOZXRmaWx0ZXIKKyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKworI2lmZGVmIENPTkZJR19ORVRGSUxURVIKK01FVEFfQ09MTEVDVE9SKGludF9uZm1hcmspCit7CisJZHN0LT52YWx1ZSA9IHNrYi0+bmZtYXJrOworfQorI2VuZGlmCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorICogVHJhZmZpYyBDb250cm9sCisgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisKK01FVEFfQ09MTEVDVE9SKGludF90Y2luZGV4KQoreworCWRzdC0+dmFsdWUgPSBza2ItPnRjX2luZGV4OworfQorCisjaWZkZWYgQ09ORklHX05FVF9DTFNfQUNUCitNRVRBX0NPTExFQ1RPUihpbnRfdGN2ZXJkKQoreworCWRzdC0+dmFsdWUgPSBza2ItPnRjX3ZlcmQ7Cit9CisKK01FVEFfQ09MTEVDVE9SKGludF90Y2NsYXNzaWQpCit7CisJZHN0LT52YWx1ZSA9IHNrYi0+dGNfY2xhc3NpZDsKK30KKyNlbmRpZgorCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyAqIFJvdXRpbmcKKyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKworI2lmZGVmIENPTkZJR19ORVRfQ0xTX1JPVVRFCitNRVRBX0NPTExFQ1RPUihpbnRfcnRjbGFzc2lkKQoreworCWlmICh1bmxpa2VseShza2ItPmRzdCA9PSBOVUxMKSkKKwkJKmVyciA9IC0xOworCWVsc2UKKwkJZHN0LT52YWx1ZSA9IHNrYi0+ZHN0LT50Y2xhc3NpZDsKK30KKyNlbmRpZgorCitNRVRBX0NPTExFQ1RPUihpbnRfcnRpaWYpCit7CisJaWYgKHVubGlrZWx5KHNrYi0+ZHN0ID09IE5VTEwpKQorCQkqZXJyID0gLTE7CisJZWxzZQorCQlkc3QtPnZhbHVlID0gKChzdHJ1Y3QgcnRhYmxlKikgc2tiLT5kc3QpLT5mbC5paWY7Cit9CisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorICogTWV0YSB2YWx1ZSBjb2xsZWN0b3JzIGFzc2lnbm1lbnQgdGFibGUKKyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKworc3RydWN0IG1ldGFfb3BzCit7CisJdm9pZAkJKCpnZXQpKHN0cnVjdCBza19idWZmICosIHN0cnVjdCB0Y2ZfcGt0X2luZm8gKiwKKwkJCSAgICAgICBzdHJ1Y3QgbWV0YV92YWx1ZSAqLCBzdHJ1Y3QgbWV0YV9vYmogKiwgaW50ICopOworfTsKKworLyogTWV0YSB2YWx1ZSBvcGVyYXRpb25zIHRhYmxlIGxpc3RpbmcgYWxsIG1ldGEgdmFsdWUgY29s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sKKworc3RhdGljIGlubGluZSBzdHJ1Y3QgbWV0YV9vcHMgKiBtZXRhX29wcyhzdHJ1Y3QgbWV0YV92YWx1ZSAqdmFsKQoreworCXJldHVybiAmX19tZXRhX29wc1ttZXRhX3R5cGUodmFsKV1bbWV0YV9pZCh2YWwpXTsKK30KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgKiBUeXBlIHNwZWNpZmljIG9wZXJhdGlvbnMgZm9yIFRDRl9NRVRBX1RZUEVfVkFSCisgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisKK3N0YXRpYyBpbnQgbWV0YV92YXJfY29tcGFyZShzdHJ1Y3QgbWV0YV9vYmogKmEsIHN0cnVjdCBtZXRhX29iaiAqYikKK3sKKwlpbnQgciA9IGEtPmxlbiAtIGItPmxlbjsKKworCWlmIChyID09IDApCisJCXIgPSBtZW1jbXAoKHZvaWQgKikgYS0+dmFsdWUsICh2b2lkICopIGItPnZhbHVlLCBhLT5sZW4pOworCisJcmV0dXJuIHI7Cit9CisKK3N0YXRpYyBpbnQgbWV0YV92YXJfY2hhbmdlKHN0cnVjdCBtZXRhX3ZhbHVlICpkc3QsIHN0cnVjdCBydGF0dHIgKnJ0YSkKK3sKKwlpbnQgbGVuID0gUlRBX1BBWUxPQUQocnRhKTsKKworCWRzdC0+dmFsID0gKHVuc2lnbmVkIGxvbmcpIGttYWxsb2MobGVuLCBHRlBfS0VSTkVMKTsKKwlpZiAoZHN0LT52YWwgPT0gMFVMKQorCQlyZXR1cm4gLUVOT01FTTsKKwltZW1jcHkoKHZvaWQgKikgZHN0LT52YWwsIFJUQV9EQVRBKHJ0YSksIGxlbik7CisJZHN0LT5sZW4gPSBsZW47CisJcmV0dXJuIDA7Cit9CisKK3N0YXRpYyB2b2lkIG1ldGFfdmFyX2Rlc3Ryb3koc3RydWN0IG1ldGFfdmFsdWUgKnYpCit7CisJaWYgKHYtPnZhbCkKKwkJa2ZyZWUoKHZvaWQgKikgdi0+dmFsKTsKK30KKworc3RhdGljIHZvaWQgbWV0YV92YXJfYXBwbHlfZXh0cmFzKHN0cnVjdCBtZXRhX3ZhbHVlICp2LAorCQkJCSAgc3RydWN0IG1ldGFfb2JqICpkc3QpCit7CisJaW50IHNoaWZ0ID0gdi0+aGRyLnNoaWZ0OworCisJaWYgKHNoaWZ0ICYmIHNoaWZ0IDwgZHN0LT5sZW4pCisJCWRzdC0+bGVuIC09IHNoaWZ0OworfQorCitzdGF0aWMgaW50IG1ldGFfdmFyX2R1bXAoc3RydWN0IHNrX2J1ZmYgKnNrYiwgc3RydWN0IG1ldGFfdmFsdWUgKnYsIGludCB0bHYpCit7CisJaWYgKHYtPnZhbCAmJiB2LT5sZW4pCisJCVJUQV9QVVQoc2tiLCB0bHYsIHYtPmxlbiwgKHZvaWQgKikgdi0+dmFsKTsKKwlyZXR1cm4gMDsKKworcnRhdHRyX2ZhaWx1cmU6CisJcmV0dXJuIC0xOworfQorCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyAqIFR5cGUgc3BlY2lmaWMgb3BlcmF0aW9ucyBmb3IgVENGX01FVEFfVFlQRV9JTlQKKyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKworc3RhdGljIGludCBtZXRhX2ludF9jb21wYXJlKHN0cnVjdCBtZXRhX29iaiAqYSwgc3RydWN0IG1ldGFfb2JqICpiKQoreworCS8qIExldCBnY2Mgb3B0aW1pemUgaXQsIHRoZSB1bmxpa2VseSBpcyBub3QgcmVhbGx5IGJhc2VkIG9uCisJICogc29tZSBudW1iZXJzIGJ1dCBqdW1wIGZyZWUgY29kZSBmb3IgbWlzbWF0Y2hl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GFuZ2UgPSBtZXRhX3Zhcl9jaGFuZ2UsCisJCS5hcHBseV9leHRyYXMgPSBtZXRhX3Zhcl9hcHBseV9leHRyYXMsCisJCS5kdW1wID0gbWV0YV92YXJfZHVtcAorCX0sCisJW1RDRl9NRVRBX1RZUEVfSU5UXSA9IHsKKwkJLmNvbXBhcmUgPSBtZXRhX2ludF9jb21wYXJlLAorCQkuY2hhbmdlID0gbWV0YV9pbnRfY2hhbmdlLAorCQkuYXBwbHlfZXh0cmFzID0gbWV0YV9pbnRfYXBwbHlfZXh0cmFzLAorCQkuZHVtcCA9IG1ldGFfaW50X2R1bXAKKwl9Cit9OworCitzdGF0aWMgaW5saW5lIHN0cnVjdCBtZXRhX3R5cGVfb3BzICogbWV0YV90eXBlX29wcyhzdHJ1Y3QgbWV0YV92YWx1ZSAqdikKK3sKKwlyZXR1cm4gJl9fbWV0YV90eXBlX29wc1ttZXRhX3R5cGUodildOworfQorCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyAqIENvcmUKKyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKworc3RhdGljIGlubGluZSBpbnQgbWV0YV9nZXQoc3RydWN0IHNrX2J1ZmYgKnNrYiwgc3RydWN0IHRjZl9wa3RfaW5mbyAqaW5mbywgCisJCQkgICBzdHJ1Y3QgbWV0YV92YWx1ZSAqdiwgc3RydWN0IG1ldGFfb2JqICpkc3QpCit7CisJaW50IGVyciA9IDA7CisKKwlpZiAobWV0YV9pZCh2KSA9PSBUQ0ZfTUVUQV9JRF9WQUxVRSkgeworCQlkc3QtPnZhbHVlID0gdi0+dmFsOworCQlkc3QtPmxlbiA9IHYtPmxlbjsKKwkJcmV0dXJuIDA7CisJfQorCisJbWV0YV9vcHModiktPmdldChza2IsIGluZm8sIHYsIGRzdCwgJmVycik7CisJ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Y2Ugc3RhcnRpbmcgd2l0aCBCMS4KKyAqIAorICogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqCisgKiBIb3cgdG8gd3JpdGUgYW4gZW1hdGNoIGluIDYwIHNlY29uZHMKKyAqIC0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLQorICogCisgKiAgIDEpIFByb3ZpZGUgYSBtYXRjaGVyIGZ1bmN0aW9uOgorICogICAgICBzdGF0aWMgaW50IG15X21hdGNoKHN0cnVjdCBza19idWZmICpza2IsIHN0cnVjdCB0Y2ZfZW1hdGNoICptLAorICogICAgICAgICAgICAgICAgICAgICAgICAgIHN0cnVjdCB0Y2ZfcGt0X2luZm8gKmluZm8pCisgKiAgICAgIHsKKyAqICAgICAgCXN0cnVjdCBteWRhdGEgKmQgPSAoc3RydWN0IG15ZGF0YSAqKSBtLT5kYXRhOworICoKKyAqICAgICAgCWlmICguLi5tYXRjaGluZyBnb2VzIGhlcmUuLi4pCisgKiAgICAgIAkJcmV0dXJuIDE7CisgKiAgICAgIAllbHNlCisgKiAgICAgIAkJcmV0dXJuIDA7CisgKiAgICAgIH0KKyAqCisgKiAgIDIpIEZpbGwgb3V0IGEgc3RydWN0IHRjZl9lbWF0Y2hfb3BzOgorICogICAgICBzdGF0aWMgc3RydWN0IHRjZl9lbWF0Y2hfb3BzIG15X29wcyA9IHsKKyAqICAgICAgCS5raW5kID0gdW5pcXVlIGlkLAorICogICAgICAJLmRhdGFsZW4gPSBzaXplb2Yoc3RydWN0IG15ZGF0YSksCisgKiAgICAgIAkubWF0Y2ggPSBteV9tYXRjaCwKKyAqICAgICAgCS5vd25lciA9IFRISVNfTU9EVUxFLAorICogICAgICB9OworICoKKyAqICAgMykgUmVnaXN0ZXIvVW5yZWdpc3RlciB5b3VyIGVtYXRjaDoKKyAqICAgICAgc3RhdGljIGludCBfX2luaXQgaW5pdF9teV9lbWF0Y2godm9pZCkKKyAqICAgICAgeworICogICAgICAJcmV0dXJuIHRjZl9lbV9yZWdpc3RlcigmbXlfb3BzKTsKKyAqICAgICAgfQorICoKKyAqICAgICAgc3RhdGljIHZvaWQgX19leGl0IGV4aXRfbXlfZW1hdGNoKHZvaWQpCisgKiAgICAgIHsKKyAqICAgICAgCXJldHVybiB0Y2ZfZW1fdW5yZWdpc3RlcigmbXlfb3BzKTsKKyAqICAgICAgfQorICoKKyAqICAgICAgbW9kdWxlX2luaXQoaW5pdF9teV9lbWF0Y2gpOworICogICAgICBtb2R1bGVfZXhpdChleGl0X215X2VtYXRjaCk7CisgKgorICogICA0KSBCeSBub3cgeW91IHNob3VsZCBoYXZlIHR3byBtb3JlIHNlY29uZHMgbGVmdCwgYmFyZWx5IGVub3VnaCB0bworICogICAgICBvcGVuIHVwIGEgYmVlciB0byB3YXRjaCB0aGUgY29tcGlsYXRpb24gZ29pbmcuCisgKi8KKworI2luY2x1ZGUgPGxpbnV4L2NvbmZpZy5oPgorI2luY2x1ZGUgPGxpbnV4L21vZHVsZS5oPgorI2luY2x1ZGUgPGxpbnV4L3R5cGVzLmg+CisjaW5jbHVkZSA8bGludXgva2VybmVsLmg+CisjaW5jbHVkZSA8bGludXgvc2NoZWQuaD4KKyNpbmNsdWRlIDxsaW51eC9tbS5oPgorI2luY2x1ZGUgPGxpbnV4L2Vycm5vLmg+CisjaW5jbHVkZSA8bGludXgvaW50ZXJydXB0Lmg+CisjaW5jbHVkZSA8bGludXgvcnRuZXRsaW5rLmg+CisjaW5jbHVkZSA8bGludXgvc2tidWZmLmg+CisjaW5jbHVkZSA8bmV0L3BrdF9jbHMuaD4KKyNpbmNsdWRlIDxjb25maWcvbmV0L2VtYXRjaC9zdGFjay5oPgorCitzdGF0aWMgTElTVF9IRUFEKGVtYXRjaF9vcHMpOworc3RhdGljIERFRklORV9SV0xPQ0soZW1hdGNoX21vZF9sb2NrKTsKKworc3RhdGljIGlubGluZSBzdHJ1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Btb2R1bGVzLiBJdCBpcyBwdXJlIFNNUCBsb2NrLiAqLworc3RhdGljIERFRklORV9SV0xPQ0socWRpc2NfbW9kX2xvY2spOworCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyAqCVF1ZXVlaW5nIGRpc2NpcGxpbmVzIG1hbmlwdWxhdGlvbi4JKgorICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKworCisvKiBUaGUgbGlzdCBvZiBhbGwgaW5zdGFsbGVkIHF1ZXVlaW5nIGRpc2NpcGxpbmVzLiAqLworCitzdGF0aWMgc3RydWN0IFFkaXNjX29wcyAqcWRpc2NfYmFzZTsKKworLyogUmVnaXN0ZXIvdXJlZ2lzdGVyIHF1ZXVlaW5nIGRpc2NpcGxpbmUgKi8KKworaW50IHJlZ2lzdGVyX3FkaXNjKHN0cnVjdCBRZGlzY19vcHMgKnFvcHMpCit7CisJc3RydWN0IFFkaXNjX29wcyAqcSwgKipxcDsKKwlpbnQgcmMgPSAtRUVYSVNUOworCisJd3JpdGVfbG9jaygmcWRpc2NfbW9kX2xvY2spOworCWZvciAocXAgPSAmcWRpc2NfYmFzZTsgKHEgPSAqcXApICE9IE5VTEw7IHFwID0gJnEtPm5leHQpCisJCWlmICghc3RyY21wKHFvcHMtPmlkLCBxLT5pZCkpCisJCQlnb3RvIG91dDsKKworCWlmIChxb3BzLT5lbnF1ZXVlID09IE5VTEwpCisJCXFvcHMtPmVucXVldWUgPSBub29wX3FkaXNjX29wcy5lbnF1ZXVlOworCWlmIChxb3BzLT5yZXF1ZXVlID09IE5VTEwpCisJCXFvcHMtPnJlcXVldWUgPSBub29wX3FkaXNjX29wcy5yZXF1ZXVlOworCWlmIChxb3BzLT5kZXF1ZXVlID09IE5VTEwpCisJCXFvcHMtPmRlcXVldWUgPSBub29wX3FkaXNjX29wcy5kZXF1ZXVlOworCisJcW9wcy0+bmV4dCA9IE5VTEw7CisJ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0NCKGNiLT5za2IpLnBpZCwKKwkJCQkJICBjYi0+bmxoLT5ubG1zZ19zZXEsIE5MTV9GX01VTFRJLCBSVE1fTkVXUURJU0MpIDw9IDApIHsKKwkJCQlyZWFkX3VubG9ja19iaCgmcWRpc2NfdHJlZV9sb2NrKTsKKwkJCQlnb3RvIGRvbmU7CisJCQl9CisJCQlxX2lkeCsrOworCQl9CisJCXJlYWRfdW5sb2NrX2JoKCZxZGlzY190cmVlX2xvY2spOworCX0KKworZG9uZToKKwlyZWFkX3VubG9jaygmZGV2X2Jhc2VfbG9jayk7CisKKwljYi0+YXJnc1swXSA9IGlkeDsKKwljYi0+YXJnc1sxXSA9IHFfaWR4OworCisJcmV0dXJuIHNrYi0+bGVuOworfQorCisKKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorICoJVHJhZmZpYyBjbGFzc2VzIG1hbmlwdWxhdGlvbi4JCSoKKyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisKKworCitzdGF0aWMgaW50IHRjX2N0bF90Y2xhc3Moc3RydWN0IHNrX2J1ZmYgKnNrYiwgc3RydWN0IG5sbXNnaGRyICpuLCB2b2lkICphcmcpCit7CisJc3RydWN0IHRjbXNnICp0Y20gPSBOTE1TR19EQVRBKG4pOworCXN0cnVjdCBydGF0dHIgKip0Y2EgPSBhcmc7CisJc3RydWN0IG5ldF9kZXZpY2UgKmRldjsKKwlzdHJ1Y3QgUWRpc2MgKnEgPSBOVUxMOworCXN0cnVjdCBRZGlzY19jbGFzc19vcHMgKmNvcHM7CisJdW5zaWduZWQgbG9uZyBjbCA9IDA7CisJdW5zaWduZWQgbG9uZyBuZXdfY2w7CisJdTMyIHBpZCA9IHRjbS0+dGNtX3BhcmVudDsKKwl1MzIgY2xpZCA9IHRjbS0+dGNtX2hhbmRsZTsKKwl1MzIgcWlkID0gVENfSF9NQUooY2xpZCk7CisJaW50IGVycjsKKworCWlmIC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TYgICAgICAgICAxLjYgICAgICAgIDAuMTYgICAgICAgMC4wMTYKKyAqICB1cy9ieXRlICAgICAgIDgwICAgICAgICAgOCAgICAgICAgICAwLjggICAgICAgIDAuMDggICAgICAgMC4wMDgKKyAqICAxLjI3dXMvYnl0ZSAgIDYzICAgICAgICAgNi4zICAgICAgICAwLjYzICAgICAgIDAuMDYzICAgICAgMC4wMDYzCisgKi8KKyNkZWZpbmUJU01fU0hJRlQJMjAKKyNkZWZpbmUJSVNNX1NISUZUCTE4CisKKyNkZWZpbmUJU01fTUFTSwkJKCgxVUxMIDw8IFNNX1NISUZUKSAtIDEpCisjZGVmaW5lCUlTTV9NQVNLCSgoMVVMTCA8PCBJU01fU0hJRlQpIC0gMSkKKworc3RhdGljIGlubGluZSB1NjQKK3NlZ194MnkodTY0IHgsIHU2NCBzbSkKK3sKKwl1NjQgeTsKKworCS8qCisJICogY29tcHV0ZQorCSAqCXkgPSB4ICogc20gPj4gU01fU0hJRlQKKwkgKiBidXQgZGl2aWRlIGl0IGZvciB0aGUgdXBwZXIgYW5kIGxvd2VyIGJpdHMgdG8gYXZvaWQgb3ZlcmZsb3cKKwkgKi8KKwl5ID0gKHggPj4gU01fU0hJRlQpICogc20gKyAoKCh4ICYgU01fTUFTSykgKiBzbSkgPj4gU01fU0hJRlQpOworCXJldHVybiB5OworfQorCitzdGF0aWMgaW5saW5lIHU2NAorc2VnX3kyeCh1NjQgeSwgdTY0IGlzbSkKK3sKKwl1NjQgeDsKKworCWlmICh5ID09IDApCisJCXggPSAwOworCWVsc2UgaWYgKGlzbSA9PSBIVF9JTkZJTklUWSkKKwkJeCA9IEhUX0lORklOSVRZOworCWVsc2UgeworCQl4ID0gKHkgPj4gSVNNX1NISUZUKSAqIGlzbQorCQkgICAgKyAoKCh5ICYgSVNNX01BU0spICogaXNtKSA+PiBJU01fU0hJRlQpOworCX0KKwlyZXR1cm4geDsKK30KKworLyogQ29udmVydCBtIChicHMpIGludG8gc20gKGJ5dGVzL3BzY2hlZCB1cykgKi8KK3N0YXRpYyB1NjQKK20yc20odTMyIG0pCit7CisJdTY0IHNtOworCisJc20gPSAoKHU2NCltIDw8IFNNX1NISUZUKTsKKwlzbSArPSBQU0NIRURfSklGRklFMlVTKEhaKSAtIDE7CisJZG9fZGl2KHNtLCBQU0NIRURfSklGRklFMlVTKEhaKSk7CisJcmV0dXJuIHNtOworfQorCisvKiBjb252ZXJ0IG0gKGJwcykgaW50byBpc20gKHBzY2hlZCB1cy9ieXRlKSAqLworc3RhdGljIHU2NAorbTJpc20odTMyIG0pCit7CisJdTY0IGlzbTsKKworCWlmIChtID09IDApCisJCWlzbSA9IEhUX0lORklOSVRZOworCWVsc2UgeworCQlpc20gPSAoKHU2NClQU0NIRURfSklGRklFMlVTKEhaKSA8PCBJU01fU0hJRlQpOworCQlpc20gKz0gbSAtIDE7CisJCWRvX2Rpdihpc20sIG0pOworCX0KKwlyZXR1cm4gaXNtOworfQorCisvKiBjb252ZXJ0IGQgKHVzKSBpbnRvIGR4IChwc2NoZWQgdXMpICovCitzdGF0aWMgdTY0CitkMmR4KHUzMiBkKQoreworCXU2NCBkeDsKKworCWR4ID0gKCh1NjQpZCAqIFBTQ0hFRF9KSUZGSUUyVVMoSFopKTsKKwlkeCArPSAxMDAwMDAwIC0gMTsKKwlkb19kaXYoZHgsIDEwMDAwMDApOworCXJldHVybiBkeDsKK30KKworLyogY29udmVydCBzbSAoYnl0ZXMvcHNjaGVkIHVzKSBpbnRvIG0gKGJwcykgKi8KK3N0YXRpYyB1MzIKK3NtMm0odTY0IHNtKQoreworCXU2NCBtOworCisJbSA9IChzbSAqIFBTQ0hFRF9KSUZGSUUyVVMoSFopKSA+PiBTTV9TSElGVDsKKwlyZXR1cm4gKHUzMiltOworfQorCisvKiBjb252ZXJ0IGR4IChwc2NoZWQgdXMpIGludG8gZCAodXMpICovCitzdGF0aWMgdTMyCitkeDJkKHU2NCBkeCkKK3sKKwl1NjQgZDsKKworCWQgPSBkeCAqIDEwMDAw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dCBuZl9ob29rX29wcyBpbmc2X29wcyA9IHsKKwkuaG9vayAgICAgICAgICAgPSBpbmdfaG9vaywKKwkub3duZXIJCT0gVEhJU19NT0RVTEUsCisJLnBmICAgICAgICAgICAgID0gUEZfSU5FVDYsCisJLmhvb2tudW0gICAgICAgID0gTkZfSVA2X1BSRV9ST1VUSU5HLAorCS5wcmlvcml0eSAgICAgICA9IE5GX0lQNl9QUklfRklMVEVSICsgMSwKK307CisKKyNlbmRpZgorI2VuZGlmCisKK3N0YXRpYyBpbnQgaW5ncmVzc19pbml0KHN0cnVjdCBRZGlzYyAqc2NoLHN0cnVjdCBydGF0dHIgKm9wdCkKK3sKKwlzdHJ1Y3QgaW5ncmVzc19xZGlzY19kYXRhICpwID0gUFJJVihzY2gpOworCisvKiBNYWtlIHN1cmUgZWl0aGVyIG5ldGZpbHRlciBvciBwcmVmZXJhYmx5IENMU19BQ1QgaXMKKyogY29tcGlsZWQgaW4gKi8KKyNpZm5kZWYgQ09ORklHX05FVF9DTFNfQUNUCisjaWZuZGVmIENPTkZJR19ORVRGSUxURVIKKwlwcmludGsoIllvdSBNVVNUIGNvbXBpbGUgY2xhc3NpZmllciBhY3Rpb25zIGludG8gdGhlIGtlcm5lbFxuIik7CisJcmV0dXJuIC1FSU5WQUw7CisjZWxzZQorCXByaW50aygiSW5ncmVzcyBzY2hlZHVsZXI6IENsYXNzaWZpZXIgYWN0aW9ucyBwcmVmZXJlZCBvdmVyIG5ldGZpbHRlclxuIik7CisjZW5kaWYKKyNlbmRpZgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKKyNpZm5kZWYgQ09ORklHX05FVF9DTFNfQUNUCisjaWZkZWYgQ09ORklHX05FVEZJTFRFUgorCWlmICghbmZfcmVnaXN0ZXJlZCkgeworCQlpZiAobmZfcmVnaXN0ZXJfaG9vaygmaW5nX29wcykgPCAwKSB7CisJCQlwcmludGs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KKwkgKiBTSE9VTEQgaW5jbHVkZSBhbGwgb2YgaXRzIGFkZHJlc3NlcyB3aXRoIGxldmVsIGdyZWF0ZXIKKwkgKiB0aGFuIG9yIGVxdWFsIHRvIEwuCisJICovCisJaWYgKGFkZHJfc2NvcGUgPD0gc2NvcGUpCisJCXJldHVybiAxOworCisJcmV0dXJuIDA7Cit9CisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorICogM3JkIExldmVsIEFic3RyYWN0aW9ucworICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworCisvKiBXaGF0IGlzIHRoZSBzY29wZSBvZiAnYWRkcic/ICAqLworc2N0cF9zY29wZV90IHNjdHBfc2NvcGUoY29uc3QgdW5pb24gc2N0cF9hZGRyICphZGRyKQoreworCXN0cnVjdCBzY3RwX2FmICphZjsKKworCWFmID0gc2N0cF9nZXRfYWZfc3BlY2lmaWMoYWRkci0+c2Euc2FfZmFtaWx5KTsKKwlpZiAoIWFmKQorCQlyZXR1cm4gU0NUUF9TQ09QRV9VTlVTQUJMRTsKKworCXJldHVybiBhZi0+c2NvcGUoKHVuaW9uIHNjdHBfYWRkciAqKWFkZHIpOworfQpkaWZmIC0tZ2l0IGEvbmV0L3NjdHAvY2h1bmsuYyBiL25ldC9zY3RwL2NodW5rLmMKbmV3IGZpbGUgbW9kZSAxMDA2NDQKaW5kZXggMDAwMDAwMC4uMGMyYWI3OAotLS0gL2Rldi9udWxsCisrKyBiL25ldC9zY3RwL2NodW5rLmMKQEAgLTAsMCArMSwzMDkgQEAKKy8qIFNDVFAga2VybmVsIHJlZmVyZW5jZSBJbXBsZW1lbnRhdGlvbgorICogKEMpIENvcHlyaWdodCBJQk0gQ29ycC4gMjAwMywgMjAwNAorICoKKyAqIFRoaXMgZmlsZSBpcyBwYXJ0IG9mIHRoZSBTQ1RQIGtlc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ZmluZSBDUkMzMkNfUE9MWSAweDFFREM2RjQxCisjZGVmaW5lIENSQzMyQyhjLGQpIChjPShjPj44KV5jcmNfY1soY14oZCkpJjB4RkZdKQorLyogKiAqICogKiAqICogKiAqICogKiAqICogKiAqICogKiAqICogKiAqICogKiAqICogKiAqICogKiAqICogKiAqLworLyogQ29weXJpZ2h0IDIwMDEsIEQuIE90aXMuICBVc2UgdGhpcyBwcm9ncmFtLCBjb2RlIG9yIHRhYmxlcyAgICAqLworLyogZXh0cmFjdGVkIGZyb20gaXQsIGFzIGRlc2lyZWQgd2l0aG91dCByZXN0cmljdGlvbi4gICAgICAgICAgICAqLworLyogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqLworLyogMzIgQml0IFJlZmxlY3RlZCBDUkMgdGFibGUgZ2VuZXJhdGlvbiBmb3IgU0NUUC4gICAgICAgICAgICAgICAqLworLyogVG8gYWNjb21tb2RhdGUgc2VyaWFsIGJ5dGUgZGF0YSBiZWluZyBzaGlmdGVkIG91dCBsZWFzdCAgICAgICAqLworLyogc2lnbmlmaWNhbnQgYml0IGZpcnN0LCB0aGUgdGFibGUncyAzMiBiaXQgd29yZHMgYXJlIHJlZmxlY3RlZCAqLworLyogd2hpY2ggZmxpcHMgYm90aCBieXRlIGFuZCBiaXQgTVMgYW5kIExTIHBvc2l0aW9ucy4gIFRoZSBDUkMgICAqLworLyogaXMgY2FsY3VsYXRlZCBNUyBiaXRzIGZpcnN0IGZyb20gdGhlIHBlcnNwZWN0aXZlIG9mIHRoZSBzZXJpYWwqLworLyogc3RyZWFtLiAgVGhlIHheMzIgdGVybSBpcyBpbXBsaWVkIGFuZCB0aGUgeF4wIHRlcm0gbWF5IGFsc28gICAqLworLyogYmUgc2hvd24gYXMgKzEuICBUaGUgcG9seW5vbWlhbCBjb2RlIHVzZWQgaXMgMHgxRURDNkY0MS4gICAgICAqLworLyogQ2FzdGFnbm9saTkzICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqLworLyogeF4zMit4XjI4K3heMjcreF4yNit4XjI1K3heMjMreF4yMit4XjIwK3heMTkreF4xOCt4XjE0K3heMTMrICAqLworLyogeF4xMSt4XjEwK3heOSt4XjgreF42K3heMCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqLworLyogR3V5IENhc3RhZ25vbGkgU3RlZmFuIEJyYWV1ZXIgYW5kIE1hcnRpbiBIZXJybWFuICAgICAgICAgICAgICAqLworLyogIk9wdGltaXphdGlvbiBvZiBDeWNsaWMgUmVkdW5kYW5jeS1DaGVjayBDb2RlcyAgICAgICAgICAgICAgICAqLworLyogd2l0aCAyNCBhbmQgMzIgUGFyaXR5IEJpdHMiLCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqLworLyogSUVFRSBUcmFuc2FjdGlvbnMgb24gQ29tbXVuaWNhdGlvbnMsIFZvbC40MSwgTm8uNiwgSnVuZSAxOTkzICAqLworLyogKiAqICogKiAqICogKiAqICogKiAqICogKiAqICogKiAqICogKiAqICogKiAqICogKiAqICogKiAqICogKiAqLworc3RhdGljIGNvbnN0IF9fdTMyIGNyY19jWzI1Nl0gPSB7CisJMHgwMDAwMDAwMCwgMHhGMjZCODMwMywgMHhFMTNCNzBGNywgMHgxMzUwRjNGNCwKKwkweEM3OUE5NzFGLCAweDM1RjExNDFDLCAweDI2QTFFN0U4LCAweEQ0Q0E2NEVCLAorCTB4OEFEOTU4Q0YsIDB4NzhCMkRCQ0MsIDB4NkJFMjI4MzgsIDB4OTk4OUFCM0IsCisJMHg0RDQzQ0ZEMCwgMHhCRjI4NENEMywgMHhBQzc4QkYyNywgMHg1RTEzM0MyNCwKKwkweDEwNUVDNzZGLCAweEUyMzU0NDZDLCAweEYxNjVCNzk4LCAweDAzMEUzNDlCLAorCTB4RDdDNDUwNzAsIDB4MjVBRkQzNzMsIDB4MzZGRjIwODcsIDB4QzQ5NEEzODQsCisJM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luaXRpYXRpb24gKElOSVQpICgxKQorICoKKyAqIFRoaXMgY2h1bmsgaXMgdXNlZCB0byBpbml0aWF0ZSBhIFNDVFAgYXNzb2NpYXRpb24gYmV0d2VlbiB0d28KKyAqIGVuZHBvaW50cy4gVGhlIGZvcm1hdCBvZiB0aGUgSU5JVCBjaHVuayBpcyBzaG93biBiZWxvdzoKKyAqCisgKiAgICAgMCAgICAgICAgICAgICAgICAgICAxICAgICAgICAgICAgICAgICAgIDIgICAgICAgICAgICAgICAgICAgMworICogICAgIDAgMSAyIDMgNCA1IDYgNyA4IDkgMCAxIDIgMyA0IDUgNiA3IDggOSAwIDEgMiAzIDQgNSA2IDcgOCA5IDAgMQorICogICAgKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSsKKyAqICAgIHwgICBUeXBlID0gMSAgICB8ICBDaHVuayBGbGFncyAgfCAgICAgIENodW5rIExlbmd0aCAgICAgICAgICAgICB8CisgKiAgICArLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKworICogICAgfCAgICAgICAgICAgICAgICAgICAgICAgICBJbml0aWF0ZSBUYWcgICAgICAgICAgICAgICAgICAgICAgICAgIHwKKyAqICAgICstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rCisgKiAgICB8ICAgICAgICAgICBBZHZlcnRpc2VkIFJlY2VpdmVyIFdpbmRvdyBDcmVkaXQgKGFfcnduZCkgICAgICAgICAgfAorICogICAgKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSsKKyAqICAgIHwgIE51bWJlciBvZiBPdXRib3VuZCBTdHJlYW1zICAgfCAgTnVtYmVyIG9mIEluYm91bmQgU3RyZWFtcyAgICB8CisgKiAgICArLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKworICogICAgfCAgICAgICAgICAgICAgICAgICAgICAgICAgSW5pdGlhbCBUU04gICAgICAgICAgICAgICAgICAgICAgICAgIHwKKyAqICAgICstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rCisgKiAgICBcICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXAorICogICAgLyAgICAgICAgICAgICAgT3B0aW9uYWwvVmFyaWFibGUtTGVuZ3RoIFBhcmFtZXRlcnMgICAgICAgICAgICAgIC8KKyAqICAgIFwgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCisgKiAgICArLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKworICoKKyAqCisgKiBUaGUgSU5JVCBjaHVuayBjb250YWlucyB0aGUgZm9sbG93aW5nIHBhcmFtZXRlcnMuIFVubGVzcyBvdGhlcndpc2UKKyAqIG5vdGVkLCBlYWNoIHBhcmFtZXRlciBNVVNUIG9ubHkgYmUgaW5jbHVkZWQgb25jZSBpbiB0aGUgSU5JVCBjaHVuay4KKyAqCisgKiBGaXhlZCBQYXJhbWV0ZXJzICAgICAgICAgICAgICAgICAgICAgU3RhdHVzCisgKiAtLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tCisgKiBJbml0aWF0ZSBUYWcgICAgICAgICAgICAgICAgICAgICAgICBNYW5kYXRvcnkKKyAqIEFkdmVydGlzZWQgUmVjZWl2ZXIgV2luZG93IENyZWRpdCAgIE1hbmRhdG9yeQorICogTnVtYmVyIG9mIE91dG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NodW5rOgorCWtmcmVlKGNvb2tpZSk7Citub21lbV9jb29raWU6CisJaWYgKGFkZHJzLnYpCisJCWtmcmVlKGFkZHJzLnYpOworCXJldHVybiByZXR2YWw7Cit9CisKKy8qIDMuMy4xMSBDb29raWUgRWNobyAoQ09PS0lFIEVDSE8pICgxMCk6CisgKgorICogVGhpcyBjaHVuayBpcyB1c2VkIG9ubHkgZHVyaW5nIHRoZSBpbml0aWFsaXphdGlvbiBvZiBhbiBhc3NvY2lhdGlvbi4KKyAqIEl0IGlzIHNlbnQgYnkgdGhlIGluaXRpYXRvciBvZiBhbiBhc3NvY2lhdGlvbiB0byBpdHMgcGVlciB0byBjb21wbGV0ZQorICogdGhlIGluaXRpYWxpemF0aW9uIHByb2Nlc3MuIFRoaXMgY2h1bmsgTVVTVCBwcmVjZWRlIGFueSBEQVRBIGNodW5rCisgKiBzZW50IHdpdGhpbiB0aGUgYXNzb2NpYXRpb24sIGJ1dCBNQVkgYmUgYnVuZGxlZCB3aXRoIG9uZSBvciBtb3JlIERBVEEKKyAqIGNodW5rcyBpbiB0aGUgc2FtZSBwYWNrZXQuCisgKgorICogICAgICAwICAgICAgICAgICAgICAgICAgIDEgICAgICAgICAgICAgICAgICAgMiAgICAgICAgICAgICAgICAgICAzCisgKiAgICAgIDAgMSAyIDMgNCA1IDYgNyA4IDkgMCAxIDIgMyA0IDUgNiA3IDggOSAwIDEgMiAzIDQgNSA2IDcgOCA5IDAgMQorICogICAgICstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rCisgKiAgICAgfCAgIFR5cGUgPSAxMCAgIHxDaHVuayAgRmxhZ3MgICB8ICAgICAgICAgTGVuZ3RoICAgICAgICAgICAgICAgIHwKKyAqICAgICArLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKworICogICAgIC8gICAgICAgICAgICAgICAgICAgICBDb29raWUgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvCisgKiAgICAgXCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKKyAqICAgICArLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKworICoKKyAqIENodW5rIEZsYWdzOiA4IGJpdAorICoKKyAqICAgU2V0IHRvIHplcm8gb24gdHJhbnNtaXQgYW5kIGlnbm9yZWQgb24gcmVjZWlwdC4KKyAqCisgKiBMZW5ndGg6IDE2IGJpdHMgKHVuc2lnbmVkIGludGVnZXIpCisgKgorICogICBTZXQgdG8gdGhlIHNpemUgb2YgdGhlIGNodW5rIGluIGJ5dGVzLCBpbmNsdWRpbmcgdGhlIDQgYnl0ZXMgb2YKKyAqICAgdGhlIGNodW5rIGhlYWRlciBhbmQgdGhlIHNpemUgb2YgdGhlIENvb2tpZS4KKyAqCisgKiBDb29raWU6IHZhcmlhYmxlIHNpemUKKyAqCisgKiAgIFRoaXMgZmllbGQgbXVzdCBjb250YWluIHRoZSBleGFjdCBjb29raWUgcmVjZWl2ZWQgaW4gdGhlCisgKiAgIFN0YXRlIENvb2tpZSBwYXJhbWV0ZXIgZnJvbSB0aGUgcHJldmlvdXMgSU5JVCBBQ0suCisgKgorICogICBBbiBpbXBsZW1lbnRhdGlvbiBTSE9VTEQgbWFrZSB0aGUgY29va2llIGFzIHNtYWxsIGFzIHBvc3NpYmxlCisgKiAgIHRvIGluc3VyZSBpbnRlcm9wZXJhYmlsaXR5LgorICovCitzdHJ1Y3Qgc2N0cF9jaHVuayAqc2N0cF9tYWtlX2Nvb2tpZV9lY2hvKGNvbnN0IHN0cnVjdCBzY3RwX2Fzc29jaWF0aW9uICphc29jLAorCQkJCSAgICBjb25zdCBzdHJ1Y3Qgc2N0cF9jaHVuayAqY2h1bmspCit7CisJc3RydWN0IH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1c2VkIG9ubHkgZHVyaW5nIHRoZSBpbml0aWFsaXphdGlvbiBvZiBhbgorICogYXNzb2NpYXRpb24uICBJdCBpcyB1c2VkIHRvIGFja25vd2xlZGdlIHRoZSByZWNlaXB0IG9mIGEgQ09PS0lFCisgKiBFQ0hPIGNodW5rLiAgVGhpcyBjaHVuayBNVVNUIHByZWNlZGUgYW55IERBVEEgb3IgU0FDSyBjaHVuayBzZW50CisgKiB3aXRoaW4gdGhlIGFzc29jaWF0aW9uLCBidXQgTUFZIGJlIGJ1bmRsZWQgd2l0aCBvbmUgb3IgbW9yZSBEQVRBCisgKiBjaHVua3Mgb3IgU0FDSyBjaHVuayBpbiB0aGUgc2FtZSBTQ1RQIHBhY2tldC4KKyAqCisgKiAgICAgIDAgICAgICAgICAgICAgICAgICAgMSAgICAgICAgICAgICAgICAgICAyICAgICAgICAgICAgICAgICAgIDMKKyAqICAgICAgMCAxIDIgMyA0IDUgNiA3IDggOSAwIDEgMiAzIDQgNSA2IDcgOCA5IDAgMSAyIDMgNCA1IDYgNyA4IDkgMCAxCisgKiAgICAgKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSsKKyAqICAgICB8ICAgVHlwZSA9IDExICAgfENodW5rICBGbGFncyAgIHwgICAgIExlbmd0aCA9IDQgICAgICAgICAgICAgICAgfAorICogICAgICstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rCisgKgorICogQ2h1bmsgRmxhZ3M6IDggYml0cworICoKKyAqICAgU2V0IHRvIHplcm8gb24gdHJhbnNtaXQgYW5kIGlnbm9yZWQgb24gcmVjZWlwdC4KKyAqLworc3RydWN0IHNjdHBfY2h1bmsgKnNjdHBfbWFrZV9jb29raWVfYWNrKGNvbnN0IHN0cnVjdCBzY3RwX2Fzc29jaWF0aW9uICphc29jLAorCQkJCSAgIGNvbn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kIHRoZSBDV1IgYml0LiAgRm9yCisgKiAgU0NUUCB0aGUgc2FtZSBpbmRpY2F0aW9uIGlzIG1hZGUgYnkgaW5jbHVkaW5nIHRoZSBDV1IgY2h1bmsuCisgKiAgVGhpcyBjaHVuayBjb250YWlucyBvbmUgZGF0YSBlbGVtZW50LCBpLmUuIHRoZSBUU04gbnVtYmVyIHRoYXQKKyAqICB3YXMgc2VudCBpbiB0aGUgRUNORSBjaHVuay4gIFRoaXMgZWxlbWVudCByZXByZXNlbnRzIHRoZSBsb3dlc3QKKyAqICBUU04gbnVtYmVyIGluIHRoZSBkYXRhZ3JhbSB0aGF0IHdhcyBvcmlnaW5hbGx5IG1hcmtlZCB3aXRoIHRoZQorICogIENFIGJpdC4KKyAqCisgKiAgICAgMCAgICAgICAgICAgICAgICAgICAxICAgICAgICAgICAgICAgICAgIDIgICAgICAgICAgICAgICAgICAgMworICogICAgIDAgMSAyIDMgNCA1IDYgNyA4IDkgMCAxIDIgMyA0IDUgNiA3IDggOSAwIDEgMiAzIDQgNSA2IDcgOCA5IDAgMQorICogICAgKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSsKKyAqICAgIHwgQ2h1bmsgVHlwZT0xMyB8IEZsYWdzPTAwMDAwMDAwfCAgICBDaHVuayBMZW5ndGggPSA4ICAgICAgICAgICB8CisgKiAgICArLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKworICogICAgfCAgICAgICAgICAgICAgICAgICAgICBMb3dlc3QgVFNOIE51bWJlciAgICAgICAgICAgICAgICAgICAgICAgIHwKKyAqICAgICstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rCisgKgorICogICAgIE5vdGU6IFRoZSBDV1IgaXMgY29uc2lkZXJlZCBhIENvbn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IGlzIHJlcGx5aW5nLgorCSAqCisJICovCisJaWYgKGNodW5rKQorCQlyZXR2YWwtPnRyYW5zcG9ydCA9IGNodW5rLT50cmFuc3BvcnQ7CisKK25vZGF0YToKKwlyZXR1cm4gcmV0dmFsOworfQorCisvKiBDcmVhdGUgYW4gT3BlcmF0aW9uIEVycm9yIGNodW5rLiAgKi8KK3N0cnVjdCBzY3RwX2NodW5rICpzY3RwX21ha2Vfb3BfZXJyb3IoY29uc3Qgc3RydWN0IHNjdHBfYXNzb2NpYXRpb24gKmFzb2MsCisJCQkJIGNvbnN0IHN0cnVjdCBzY3RwX2NodW5rICpjaHVuaywKKwkJCQkgX191MTYgY2F1c2VfY29kZSwgY29uc3Qgdm9pZCAqcGF5bG9hZCwKKwkJCQkgc2l6ZV90IHBheWxlbikKK3sKKwlzdHJ1Y3Qgc2N0cF9jaHVuayAqcmV0dmFsOworCisJcmV0dmFsID0gc2N0cF9tYWtlX29wX2Vycm9yX3NwYWNlKGFzb2MsIGNodW5rLCBwYXlsZW4pOworCWlmICghcmV0dmFsKQorCQlnb3RvIG5vZGF0YTsKKworCXNjdHBfaW5pdF9jYXVzZShyZXR2YWwsIGNhdXNlX2NvZGUsIHBheWxvYWQsIHBheWxlbik7CisKK25vZGF0YToKKwlyZXR1cm4gcmV0dmFsOworfQorCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyAqIDJuZCBMZXZlbCBBYnN0cmFjdGlvbnMKKyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKworLyogVHVybiBhbiBza2IgaW50byBhIGNodW5rLgorICogRklYTUU6IEV2ZW50dWFsbHkgbW92ZSB0aGUgc3RydWN0dXJlIGRpcmVjdGx5IGluc2lkZSB0aGUgc2tiLT5jYltdLgorICovCitzdHJ1Y3Qgc2N0cF9jaHVuayAqc2N0cF9jaH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Ul9NQUxGT1JNRUQ7CisJZ290byBmYWlsOworfQorCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyAqIDNyZCBMZXZlbCBBYnN0cmFjdGlvbnMKKyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKworc3RydWN0IF9fc2N0cF9taXNzaW5nIHsKKwlfX3UzMiBudW1fbWlzc2luZzsKKwlfX3UxNiB0eXBlOworfSAgX19hdHRyaWJ1dGVfXygocGFja2VkKSk7CisKKy8qCisgKiBSZXBvcnQgYSBtaXNzaW5nIG1hbmRhdG9yeSBwYXJhbWV0ZXIuCisgKi8KK3N0YXRpYyBpbnQgc2N0cF9wcm9jZXNzX21pc3NpbmdfcGFyYW0oY29uc3Qgc3RydWN0IHNjdHBfYXNzb2NpYXRpb24gKmFzb2MsCisJCQkJICAgICAgc2N0cF9wYXJhbV90IHBhcmFtdHlwZSwKKwkJCQkgICAgICBzdHJ1Y3Qgc2N0cF9jaHVuayAqY2h1bmssCisJCQkJICAgICAgc3RydWN0IHNjdHBfY2h1bmsgKiplcnJwKQoreworCXN0cnVjdCBfX3NjdHBfbWlzc2luZyByZXBvcnQ7CisJX191MTYgbGVuOworCisJbGVuID0gV09SRF9ST1VORChzaXplb2YocmVwb3J0KSk7CisKKwkvKiBNYWtlIGFuIEVSUk9SIGNodW5rLCBwcmVwYXJpbmcgZW5vdWdoIHJvb20gZm9yCisJICogcmV0dXJuaW5nIG11bHRpcGxlIHVua25vd24gcGFyYW1ldGVycy4KKwkgKi8KKwlpZiAoISplcnJwKQorCQkqZXJycCA9IHNjdHBfbWFrZV9vcF9lcnJvcl9zcGFjZShhc29jLCBjaHVuaywgbGVuKTsKKworCWlmICgqZXJycCkgeworCQlyZXBvcnQubnVtX21pc3NpbmcgPSBodG9ubCgxKTsKKwkJcmVwb3J0LnR5cGUgPSBw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b24gQ2hhbmdlIENodW5rIChBU0NPTkYpCisgKiAgICAgIDAgICAgICAgICAgICAgICAgICAgMSAgICAgICAgICAgICAgICAgICAyICAgICAgICAgICAgICAgICAgIDMKKyAqICAgICAgMCAxIDIgMyA0IDUgNiA3IDggOSAwIDEgMiAzIDQgNSA2IDcgOCA5IDAgMSAyIDMgNCA1IDYgNyA4IDkgMCAxCisgKiAgICAgKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSsKKyAqICAgICB8IFR5cGUgPSAweEMxICAgfCAgQ2h1bmsgRmxhZ3MgIHwgICAgICBDaHVuayBMZW5ndGggICAgICAgICAgICAgfAorICogICAgICstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rCisgKiAgICAgfCAgICAgICAgICAgICAgICAgICAgICAgU2VyaWFsIE51bWJlciAgICAgICAgICAgICAgICAgICAgICAgICAgIHwKKyAqICAgICArLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKworICogICAgIHwgICAgICAgICAgICAgICAgICAgIEFkZHJlc3MgUGFyYW1ldGVyICAgICAgICAgICAgICAgICAgICAgICAgICB8CisgKiAgICAgKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSsKKyAqICAgICB8ICAgICAgICAgICAgICAgICAgICAgQVNDT05GIFBhcmFtZXRlciAjMSAgICAgICAgICAgICAgICAgICAgICAgfAorICogICAgICstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rCisgKiAgICAgXCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKKyAqICAgICAvICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuLi4uICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLworICogICAgIFwgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCisgKiAgICAgKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSsKKyAqICAgICB8ICAgICAgICAgICAgICAgICAgICAgQVNDT05GIFBhcmFtZXRlciAjTiAgICAgICAgICAgICAgICAgICAgICAgfAorICogICAgICArLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKworICoKKyAqIEFkZHJlc3MgUGFyYW1ldGVyIGFuZCBvdGhlciBwYXJhbWV0ZXIgd2lsbCBub3QgYmUgd3JhcHBlZCBpbiB0aGlzIGZ1bmN0aW9uIAorICovCitzdGF0aWMgc3RydWN0IHNjdHBfY2h1bmsgKnNjdHBfbWFrZV9hc2NvbmYoc3RydWN0IHNjdHBfYXNzb2NpYXRpb24gKmFzb2MsCisJCQkJCSAgIHVuaW9uIHNjdHBfYWRkciAqYWRkciwKKwkJCQkJICAgaW50IHZwYXJhbV9sZW4pCit7CisJc2N0cF9hZGRpcGhkcl90IGFzY29uZjsKKwlzdHJ1Y3Qgc2N0cF9jaHVuayAqcmV0dmFsOworCWludCBsZW5ndGggPSBzaXplb2YoYXNjb25mKSArIHZwYXJhbV9sZW47CisJdW5pb24gc2N0cF9hZGRyX3BhcmFtIGFkZHJwYXJhbTsKKwlpbnQgYWRkcmxlbjsKKwlzdHJ1Y3Qgc2N0cF9hZiAqYWYgPSBzY3RwX2dldF9hZl9zcGVjaWZpYyhhZGRyLT52NC5zaW5fZmFtaWx5KTsKKworCWFkZHJsZW4gPSBhZi0+dG9fYWRkcl9wYXJhbShhZGRyLCAmYWRkcnBhcmFtKTsKKwlpZiAoIWFkZHJsZW4pCisJCXJldHVybiBOVUxMOworCWxlbmd0aCArPSBhZGRybGVuOworCisJLyogQ3JlYXRlIHRoZSBjaHVuay4gICovCisJcmV0dmFsID0gc2N0cF9tYWtlX2NodW5rKGFzb2MsIFNDVFBfQ0lEX0FTQ09ORiwgMCwgbGVuZ3RoKTsKKwlpZiAoIXJldHZhbCkKKwkJcmV0dXJuIE5VTEw7CisKKwlhc2NvbmYuc2VyaWFsID0gaHRvbmwoYXNvYy0+YWRkaXBfc2VyaWFsKyspOworCisJcmV0dmFsLT5zdWJoLmFkZGlwX2hkciA9CisJCXNjdHBfYWRkdG9fY2h1bmsocmV0dmFsLCBzaXplb2YoYXNjb25mKSwgJmFzY29uZik7CisJcmV0dmFsLT5wYXJhbV9oZHIudiA9CisJCXNjdHBfYWRkdG9fY2h1bmsocmV0dmFsLCBhZGRybGVuLCAmYWRkcnBhcmFtKTsKKworCXJldHVybiByZXR2YWw7Cit9CisKKy8qIEFERElQCisgKiAzLjIuMSBBZGQgSVAgQWRkcmVzcworICogCTAgICAgICAgICAgICAgICAgICAgMSAgICAgICAgICAgICAgICAgICAyICAgICAgICAgICAgICAgICAgIDMKKyAqIAkwIDEgMiAzIDQgNSA2IDcgOCA5IDAgMSAyIDMgNCA1IDYgNyA4IDkgMCAxIDIgMyA0IDUgNiA3IDggOSAwIDEKKyAqICAgICArLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKworICogICAgIHwgICAgICAgIFR5cGUgPSAweEMwMDEgICAgICAgICAgfCAgICBMZW5ndGggPSBWYXJpYWJsZSAgICAgICAgICB8CisgKiAgICAgKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSsKKyAqICAgICB8ICAgICAgICAgICAgICAgQVNDT05GLVJlcXVlc3QgQ29ycmVsYXRpb24gSUQgICAgICAgICAgICAgICAgICAgfAorICogICAgICstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rCisgKiAgICAgfCAgICAgICAgICAgICAgICAgICAgICAgQWRkcmVzcyBQYXJhbWV0ZXIgICAgICAgICAgICAgICAgICAgICAgIHwKKyAqICAgICArLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKworICoKKyAqIDMuMi4yIERlbGV0ZSBJUCBBZGRyZXNzCisgKiAJMCAgICAgICAgICAgICAgICAgICAxICAgICAgICAgICAgICAgICAgIDIgICAgICAgICAgICAgICAgICAgMworICogCTAgMSAyIDMgNCA1IDYgNyA4IDkgMCAxIDIgMyA0IDUgNiA3IDggOSAwIDEgMiAzIDQgNSA2IDcgOCA5IDAgMQorICogICAgICstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rCisgKiAgICAgfCAgICAgICAgVHlwZSA9IDB4QzAwMiAgICAgICAgICB8ICAgIExlbmd0aCA9IFZhcmlhYmxlICAgICAgICAgIHwKKyAqICAgICArLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKworICogICAgIHwgICAgICAgICAgICAgICBBU0NPTkYtUmVxdWVzdCBDb3JyZWxhdGlvbiBJRCAgICAgICAgICAgICAgICAgICB8CisgKiAgICAgKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSsKKyAqICAgICB8ICAgICAgICAgICAgICAgICAgICAgICBBZGRyZXNzIFBhcmFtZXRlciAgICAgICAgICAgICAgICAgICAgICAgfAorICogICAgICstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLS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gICAgICAgICAgICAgICAyICAgICAgICAgICAgICAgICAgIDMKKyAqCTAgMSAyIDMgNCA1IDYgNyA4IDkgMCAxIDIgMyA0IDUgNiA3IDggOSAwIDEgMiAzIDQgNSA2IDcgOCA5IDAgMQorICogICAgICstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rCisgKiAgICAgfCAgICAgICAgVHlwZSA9MHhDMDA0ICAgICAgICAgICB8ICAgIExlbmd0aCA9IFZhcmlhYmxlICAgICAgICAgIHwKKyAqICAgICArLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKworICogICAgIHwgICAgICAgICAgICAgICBBU0NPTkYtUmVxdWVzdCBDb3JyZWxhdGlvbiBJRCAgICAgICAgICAgICAgICAgICB8CisgKiAgICAgKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSsKKyAqICAgICB8ICAgICAgICAgICAgICAgICAgICAgICBBZGRyZXNzIFBhcmFtZXRlciAgICAgICAgICAgICAgICAgICAgICAgfAorICogICAgICstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rCisgKgorICogQ3JlYXRlIGFuIEFTQ09ORiBjaHVuayB3aXRoIFNldCBQcmltYXJ5IElQIGFkZHJlc3MgcGFyYW1ldGVyLiAKKyAqLworc3RydWN0IHNjdHBfY2h1bmsgKnNjdHBfbWFrZV9hc2NvbmZfc2V0X3ByaW0oc3RydWN0IHNjdHBfYXNzb2NpYXRpb24gKmFzb2MsCisJCQkJCSAgICAgdW5pb24gc2N0cF9hZGRyICphZGRyKQoreworCXNjdHBfYWRkaXBfcGFyYW1fdAlwYXJhbTsKKwlzdHJ1Y3Qgc2N0cF9jaHVuayAJKnJldHZhbDsKKwlpbnQgCQkJbGVuID0gc2l6ZW9mKHBhcmFtKTsKKwl1bmlvbiBzY3RwX2FkZHJfcGFyYW0JYWRkcnBhcmFtOworCWludAkJCWFkZHJsZW47CisJc3RydWN0IHNjdHBfYWYJCSphZiA9IHNjdHBfZ2V0X2FmX3NwZWNpZmljKGFkZHItPnY0LnNpbl9mYW1pbHkpOworCisJYWRkcmxlbiA9IGFmLT50b19hZGRyX3BhcmFtKGFkZHIsICZhZGRycGFyYW0pOworCWlmICghYWRkcmxlbikKKwkJcmV0dXJuIE5VTEw7CisJbGVuICs9IGFkZHJsZW47CisKKwkvKiBDcmVhdGUgdGhlIGNodW5rIGFuZCBtYWtlIGFzY29uZiBoZWFkZXIuICovCisJcmV0dmFsID0gc2N0cF9tYWtlX2FzY29uZihhc29jLCBhZGRyLCBsZW4pOworCWlmICghcmV0dmFsKQorCQlyZXR1cm4gTlVMTDsKKworCXBhcmFtLnBhcmFtX2hkci50eXBlID0gU0NUUF9QQVJBTV9TRVRfUFJJTUFSWTsKKwlwYXJhbS5wYXJhbV9oZHIubGVuZ3RoID0gaHRvbnMobGVuKTsKKwlwYXJhbS5jcnJfaWQgPSAwOworCisJc2N0cF9hZGR0b19jaHVuayhyZXR2YWwsIHNpemVvZihwYXJhbSksICZwYXJhbSk7CisJc2N0cF9hZGR0b19jaHVuayhyZXR2YWwsIGFkZHJsZW4sICZhZGRycGFyYW0pOworCisJcmV0dXJuIHJldHZhbDsKK30KKworLyogQURESVAgMy4xLjIgQWRkcmVzcyBDb25maWd1cmF0aW9uIEFja25vd2xlZGdlbWVudCBDaHVuayAoQVNDT05GLUFDSykKKyAqICAgICAgMCAgICAgICAgICAgICAgICAgICAxICAgICAgICAgICAgICAgICAgIDIgICAgICAgICAgICAgICAgICAgMworICogICAgICAwIDEgMiAzIDQgNSA2IDcgOCA5IDAgMSAyIDMgNCA1IDYgNyA4IDkgMCAxIDIgMyA0IDUgNiA3IDggOSAwIDEKKyAqICAgICArLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKworICogICAgIHwgVHlwZSA9IDB4ODAgICB8ICBDaHVuayBGbGFncyAgfCAgICAgIENodW5rIExlbmd0aCAgICAgICAgICAgICB8CisgKiAgICAgKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSsKKyAqICAgICB8ICAgICAgICAgICAgICAgICAgICAgICBTZXJpYWwgTnVtYmVyICAgICAgICAgICAgICAgICAgICAgICAgICAgfAorICogICAgICstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rCisgKiAgICAgfCAgICAgICAgICAgICAgICAgQVNDT05GIFBhcmFtZXRlciBSZXNwb25zZSMxICAgICAgICAgICAgICAgICAgIHwKKyAqICAgICArLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKworICogICAgIFwgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCisgKiAgICAgLyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLi4uLiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8KKyAqICAgICBcICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXAorICogICAgICstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rCisgKiAgICAgfCAgICAgICAgICAgICAgICAgQVNDT05GIFBhcmFtZXRlciBSZXNwb25zZSNOICAgICAgICAgICAgICAgICAgIHwKKyAqICAgICArLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy0rLSstKy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OworCQlicmVhazsKKworCWNhc2UgU0NUUF9ESVNQT1NJVElPTl9CVUc6CisJCXByaW50ayhLRVJOX0VSUiAic2N0cCBidWcgaW4gc3RhdGUgJWQsICIKKwkJICAgICAgICJldmVudF90eXBlICVkLCBldmVudF9pZCAlZFxuIiwKKwkJICAgICAgIHN0YXRlLCBldmVudF90eXBlLCBzdWJ0eXBlLmNodW5rKTsKKwkJQlVHKCk7CisJCWJyZWFrOworCisJZGVmYXVsdDoKKwkJcHJpbnRrKEtFUk5fRVJSICJzY3RwIGltcG9zc2libGUgZGlzcG9zaXRpb24gJWQgIgorCQkgICAgICAgImluIHN0YXRlICVkLCBldmVudF90eXBlICVkLCBldmVudF9pZCAlZFxuIiwKKwkJICAgICAgIHN0YXR1cywgc3RhdGUsIGV2ZW50X3R5cGUsIHN1YnR5cGUuY2h1bmspOworCQlCVUcoKTsKKwkJYnJlYWs7CisJfTsKKworYmFpbDoKKwlyZXR1cm4gZXJyb3I7Cit9CisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorICogMm5kIExldmVsIEFic3RyYWN0aW9ucworICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworCisvKiBUaGlzIGlzIHRoZSBzaWRlLWVmZmVjdCBpbnRlcnByZXRlci4gICovCitzdGF0aWMgaW50IHNjdHBfY21kX2ludGVycHJldGVyKHNjdHBfZXZlbnRfdCBldmVudF90eXBlLAorCQkJCXNjdHBfc3VidHlwZV90IHN1YnR5cGUsCisJCQkJc2N0cF9zdGF0ZV90IHN0YXRlLAorCQkJCXN0cnVjdCBzY3RwX2VuZHBvaW50ICplcCwKKwkJCQlzdHJ1Y3Qgc2N0cF9hc3NvY2lhdGlvbiAqYXNvYywKKwkJCQl2b2lkICpldmVudF9hcmcsCisJCQkgCXNjdHBfZGlzcG9zaXRpb25fdCBzdGF0d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5kIExldmVsIEFic3RyYWN0aW9ucworICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworCisvKiBQdWxsIHRoZSBTQUNLIGNodW5rIGJhc2VkIG9uIHRoZSBTQUNLIGhlYWRlci4gKi8KK3N0YXRpYyBzdHJ1Y3Qgc2N0cF9zYWNraGRyICpzY3RwX3NtX3B1bGxfc2FjayhzdHJ1Y3Qgc2N0cF9jaHVuayAqY2h1bmspCit7CisJc3RydWN0IHNjdHBfc2Fja2hkciAqc2FjazsKKwl1bnNpZ25lZCBpbnQgbGVuOworCV9fdTE2IG51bV9ibG9ja3M7CisJX191MTYgbnVtX2R1cF90c25zOworCisJLyogUHJvdGVjdCBvdXJzZWx2ZXMgZnJvbSByZWFkaW5nIHRvbyBmYXIgaW50bworCSAqIHRoZSBza2IgZnJvbSBhIGJvZ3VzIHNlbmRlci4KKwkgKi8KKwlzYWNrID0gKHN0cnVjdCBzY3RwX3NhY2toZHIgKikgY2h1bmstPnNrYi0+ZGF0YTsKKworCW51bV9ibG9ja3MgPSBudG9ocyhzYWNrLT5udW1fZ2FwX2Fja19ibG9ja3MpOworCW51bV9kdXBfdHNucyA9IG50b2hzKHNhY2stPm51bV9kdXBfdHNucyk7CisJbGVuID0gc2l6ZW9mKHN0cnVjdCBzY3RwX3NhY2toZHIpOworCWxlbiArPSAobnVtX2Jsb2NrcyArIG51bV9kdXBfdHNucykgKiBzaXplb2YoX191MzIpOworCWlmIChsZW4gPiBjaHVuay0+c2tiLT5sZW4pCisJCXJldHVybiBOVUxMOworCisJc2tiX3B1bGwoY2h1bmstPnNrYiwgbGVuKTsKKworCXJldHVybiBzYWNrOworfQorCisvKiBDcmVhdGUgYW4gQUJPUlQgcGFja2V0IHRvIGJlIHNlbnQgYXMgYSByZXNwb25zZSwgd2l0aCB0aGUgc3BlY2lmaWVkCisgKiBlcnJvciBjYXVzZXMuCisgKi8KK3N0YXRpYyBzdHJ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NlIG91ciBob2xkIG9uIHRoZSBlbmRwb2ludC4gKi8KKwllcCA9IHNjdHBfc2soc2spLT5lcDsKKwlzY3RwX2VuZHBvaW50X2ZyZWUoZXApOworCisJcmV0dXJuIDA7Cit9CisKKy8qIEFQSSA0LjEuNyBzaHV0ZG93bigpIC0gVENQIFN0eWxlIFN5bnRheAorICogICAgIGludCBzaHV0ZG93bihpbnQgc29ja2V0LCBpbnQgaG93KTsKKyAqCisgKiAgICAgc2QgICAgICAtIHRoZSBzb2NrZXQgZGVzY3JpcHRvciBvZiB0aGUgYXNzb2NpYXRpb24gdG8gYmUgY2xvc2VkLgorICogICAgIGhvdyAgICAgLSBTcGVjaWZpZXMgdGhlIHR5cGUgb2Ygc2h1dGRvd24uICBUaGUgIHZhbHVlcyAgYXJlCisgKiAgICAgICAgICAgICAgIGFzIGZvbGxvd3M6CisgKiAgICAgICAgICAgICAgIFNIVVRfUkQKKyAqICAgICAgICAgICAgICAgICAgICAgRGlzYWJsZXMgZnVydGhlciByZWNlaXZlIG9wZXJhdGlvbnMuIE5vIFNDVFAKKyAqICAgICAgICAgICAgICAgICAgICAgcHJvdG9jb2wgYWN0aW9uIGlzIHRha2VuLgorICogICAgICAgICAgICAgICBTSFVUX1dSCisgKiAgICAgICAgICAgICAgICAgICAgIERpc2FibGVzIGZ1cnRoZXIgc2VuZCBvcGVyYXRpb25zLCBhbmQgaW5pdGlhdGVzCisgKiAgICAgICAgICAgICAgICAgICAgIHRoZSBTQ1RQIHNodXRkb3duIHNlcXVlbmNlLgorICogICAgICAgICAgICAgICBTSFVUX1JEV1IKKyAqICAgICAgICAgICAgICAgICAgICAgRGlzYWJsZXMgZnVydGhlciBzZW5kICBhbmQgIHJlY2VpdmUgIG9wZXJhdGlvbnMKKyAqICAgICAgICAgICAgICAgICAgICAgYW5kIGluaXRpYXRlcyB0aGUgU0NUUCBzaHV0ZG93biBzZXF1ZW5jZS4KKyAqLworU0NUUF9TVEFUSUMgdm9pZCBzY3RwX3NodXR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Yml0IGlzIHNldC4gIFRoaXMgY291bGQgY2F1c2UgYSBsb3N0IEkvTworCQkgKiBzaWduYWwuICB0Y3BfcG9sbCgpIGhhcyBhIHJhY2UgYnJlYWtlciBmb3IgdGhpcyByYWNlCisJCSAqIGNvbmRpdGlvbi4gIEJhc2VkIG9uIHRoZWlyIGltcGxlbWVudGF0aW9uLCB3ZSBwdXQKKwkJICogaW4gdGhlIGZvbGxvd2luZyBjb2RlIHRvIGNvdmVyIGl0IGFzIHdlbGwuCisJCSAqLworCQlpZiAoc2N0cF93cml0ZWFibGUoc2spKQorCQkJbWFzayB8PSBQT0xMT1VUIHwgUE9MTFdSTk9STTsKKwl9CisJcmV0dXJuIG1hc2s7Cit9CisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorICogMm5kIExldmVsIEFic3RyYWN0aW9ucworICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworCitzdGF0aWMgc3RydWN0IHNjdHBfYmluZF9idWNrZXQgKnNjdHBfYnVja2V0X2NyZWF0ZSgKKwlzdHJ1Y3Qgc2N0cF9iaW5kX2hhc2hidWNrZXQgKmhlYWQsIHVuc2lnbmVkIHNob3J0IHNudW0pCit7CisJc3RydWN0IHNjdHBfYmluZF9idWNrZXQgKnBwOworCisJcHAgPSBrbWVtX2NhY2hlX2FsbG9jKHNjdHBfYnVja2V0X2NhY2hlcCwgU0xBQl9BVE9NSUMpOworCVNDVFBfREJHX09CSkNOVF9JTkMoYmluZF9idWNrZXQpOworCWlmIChwcCkgeworCQlwcC0+cG9ydCA9IHNudW07CisJCXBwLT5mYXN0cmV1c2UgPSAwOworCQlJTklUX0hMSVNUX0hFQUQoJnBwLT5vd25lcik7CisJCWlmICgocHAtPm5leHQgPSBoZWFkLT5jaGFpbikgIT0gTlVMTCkKKwkJCXBwLT5uZXh0LT5wcHJldi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dGhlIGVuZCBvZiB0aGUgbWFwLgorCSAqLworCWlmIChUU05fbHQodHNuLCBtYXAtPmJhc2VfdHNuKSkKKwkJcmV0dXJuOworCWlmICghVFNOX2x0KHRzbiwgbWFwLT5iYXNlX3RzbiArIG1hcC0+bGVuICsgbWFwLT5sZW4pKQorCQlyZXR1cm47CisKKwkvKiBCdW1wIHRoZSBtYXguICAqLworCWlmIChUU05fbHQobWFwLT5tYXhfdHNuX3NlZW4sIHRzbikpCisJCW1hcC0+bWF4X3Rzbl9zZWVuID0gdHNuOworCisJLyogQXNzZXJ0OiBUU04gaXMgaW4gcmFuZ2UuICAqLworCWdhcCA9IHRzbiAtIG1hcC0+YmFzZV90c24gKyAxOworCisJLyogTWFyayB0aGUgVFNOcyBhcyByZWNlaXZlZC4gICovCisJaWYgKGdhcCA8PSBtYXAtPmxlbikKKwkJbWVtc2V0KG1hcC0+dHNuX21hcCwgMHgwMSwgZ2FwKTsKKwllbHNlIHsKKwkJbWVtc2V0KG1hcC0+dHNuX21hcCwgMHgwMSwgbWFwLT5sZW4pOworCQltZW1zZXQobWFwLT5vdmVyZmxvd19tYXAsIDB4MDEsIChnYXAgLSBtYXAtPmxlbikpOworCX0KKworCS8qIEdvIGZpeHVwIGFueSBpbnRlcm5hbCBUU04gbWFwcGluZyB2YXJpYWJsZXMgaW5jbHVkaW5nCisJICogY3VtdWxhdGl2ZV90c25fYWNrX3BvaW50LgorCSAqLworCXNjdHBfdHNubWFwX3VwZGF0ZShtYXApOworfQorCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyAqIDJuZCBMZXZlbCBBYnN0cmFjdGlvbnMKKyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKworLyogVGhpcyBwcml2YXRlIGhlbHBlciBmdW5jdGlvbiB1cGRhdGVzIHRoZSB0c25tYXAgYnV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MCA7IGkgPCBjb3VudCA7IGkrKykKKyAgICAgICAgICAgICAgICB0b3RfbGVuICs9IHZlY3RvcltpXS5pb3ZfbGVuOworCXJldHVybiBzb2NrX3JlYWR2X3dyaXRldihWRVJJRllfUkVBRCwgZmlsZS0+Zl9kZW50cnktPmRfaW5vZGUsCisJCQkJIGZpbGUsIHZlY3RvciwgY291bnQsIHRvdF9sZW4pOworfQorCisKKy8qCisgKiBBdG9taWMgc2V0dGluZyBvZiBpb2N0bCBob29rcyB0byBhdm9pZCByYWNlCisgKiB3aXRoIG1vZHVsZSB1bmxvYWQuCisgKi8KKworc3RhdGljIERFQ0xBUkVfTVVURVgoYnJfaW9jdGxfbXV0ZXgpOworc3RhdGljIGludCAoKmJyX2lvY3RsX2hvb2spKHVuc2lnbmVkIGludCBjbWQsIHZvaWQgX191c2VyICphcmcpID0gTlVMTDsKKwordm9pZCBicmlvY3RsX3NldChpbnQgKCpob29rKSh1bnNpZ25lZCBpbnQsIHZvaWQgX191c2VyICopKQoreworCWRvd24oJmJyX2lvY3RsX211dGV4KTsKKwlicl9pb2N0bF9ob29rID0gaG9vazsKKwl1cCgmYnJfaW9jdGxfbXV0ZXgpOworfQorRVhQT1JUX1NZTUJPTChicmlvY3RsX3NldCk7CisKK3N0YXRpYyBERUNMQVJFX01VVEVYKHZsYW5faW9jdGxfbXV0ZXgpOworc3RhdGljIGludCAoKnZsYW5faW9jdGxfaG9vaykodm9pZCBfX3VzZXIgKmFyZyk7CisKK3ZvaWQgdmxhbl9pb2N0bF9zZXQoaW50ICgqaG9vaykodm9pZCBfX3VzZXIgKikpCit7CisJZG93bigmdmxhbl9pb2N0bF9tdXRleCk7CisJdmxhbl9pb2N0bF9ob29rID0gaG9vazsKKwl1cCgmdmxhbl9pb2N0bF9tdXRleCk7Cit9CitFWFBPUlRfU1lNQk9MKHZsYW5faW9jdGxfc2V0KTsKKworc3RhdGljIERFQ0xBUkVfTVVURVgoZGxjaV9pb2N0bF9tdXRleCk7CitzdGF0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RwcmludGsoIlxuIik7CisJY3AgPSAodTggKikgcDsKKwkKKwlmb3IgKGkgPSAwOyBpIDwgbGVuZ3RoOyBpICs9IDB4MTApIHsKKwkJZHByaW50aygiICAlMDR4OiAiLCAodV9pbnQpKGkgKyBvZmZzZXQpKTsKKwkJam0gPSBsZW5ndGggLSBpOworCQlqbSA9IGptID4gMTYgPyAxNiA6IGptOworCQkKKwkJZm9yIChqID0gMDsgaiA8IGptOyBqKyspIHsKKwkJCWlmICgoaiAlIDIpID09IDEpCisJCQkJZHByaW50aygiJTAyeCAiLCAodV9pbnQpY3BbaStqXSk7CisJCQllbHNlCisJCQkJZHByaW50aygiJTAyeCIsICh1X2ludCljcFtpK2pdKTsKKwkJfQorCQlmb3IgKDsgaiA8IDE2OyBqKyspIHsKKwkJCWlmICgoaiAlIDIpID09IDEpCisJCQkJZHByaW50aygiICAgIik7CisJCQllbHNlCisJCQkJZHByaW50aygiICAiKTsKKwkJfQorCQlkcHJpbnRrKCIgIik7CisJCQorCQlmb3IgKGogPSAwOyBqIDwgam07IGorKykgeworCQkJYyA9IGNwW2kral07CisJCQljID0gaXNwcmludChjKSA/IGMgOiAnLic7CisJCQlkcHJpbnRrKCIlYyIsIGMpOworCQl9CisJCWRwcmludGsoIlxuIik7CisJfQorfQorCitFWFBPUlRfU1lNQk9MKHByaW50X2hleGwpOworCitzdGF0aWMgaW5saW5lIHN0cnVjdCBnc3NfY2xfY3R4ICoKK2dzc19nZXRfY3R4KHN0cnVjdCBnc3NfY2xfY3R4ICpjdHgpCit7CisJYXRvbWljX2luYygmY3R4LT5jb3VudCk7CisJcmV0dXJuIGN0eDsKK30KKworc3RhdGljIGlubGluZSB2b2lkCitnc3NfcHV0X2N0eChzdHJ1Y3QgZ3NzX2NsX2N0eCAqY3R4KQoreworCWlmIChhdG9taWNfZGVjX2FuZF90ZXN0KCZjdHgtPmNvdW50KSkKKwkJZ3NzX2Rlc3Ryb3lfY3R4KGN0eCk7Cit9CisKK3N0YXRpYyB2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kICphY3JlZCwgaW50IGZsYWdzKQoreworCXJldHVybiBnZXRfcnBjY3JlZCgmbnVsbF9jcmVkKTsKK30KKworLyoKKyAqIERlc3Ryb3kgY3JlZCBoYW5kbGUuCisgKi8KK3N0YXRpYyB2b2lkCitudWxfZGVzdHJveV9jcmVkKHN0cnVjdCBycGNfY3JlZCAqY3JlZCkKK3sKK30KKworLyoKKyAqIE1hdGNoIGNyZWQgaGFuZGxlIGFnYWluc3QgY3VycmVudCBwcm9jZXNzCisgKi8KK3N0YXRpYyBpbnQKK251bF9tYXRjaChzdHJ1Y3QgYXV0aF9jcmVkICphY3JlZCwgc3RydWN0IHJwY19jcmVkICpjcmVkLCBpbnQgdGFza2ZsYWdzKQoreworCXJldHVybiAxOworfQorCisvKgorICogTWFyc2hhbCBjcmVkZW50aWFsLgorICovCitzdGF0aWMgdTMyICoKK251bF9tYXJzaGFsKHN0cnVjdCBycGNfdGFzayAqdGFzaywgdTMyICpwKQoreworCSpwKysgPSBodG9ubChSUENfQVVUSF9OVUxMKTsKKwkqcCsrID0gMDsKKwkqcCsrID0gaHRvbmwoUlBDX0FVVEhfTlVMTCk7CisJKnArKyA9IDA7CisKKwlyZXR1cm4gcDsKK30KKworLyoKKyAqIFJlZnJlc2ggY3JlZGVudGlhbC4gVGhpcyBpcyBhIG5vLW9wIGZvciBBVVRIX05VTEwKKyAqLworc3RhdGljIGludAorbnVsX3JlZnJlc2goc3RydWN0IHJwY190YXNrICp0YXNrKQoreworCXRhc2stPnRrX21zZy5ycGNfY3JlZC0+Y3JfZmxhZ3MgfD0gUlBDQVVUSF9DUkVEX1VQVE9EQVRFOworCXJldHVybiAwOworfQorCitzdGF0aWMgdTMyICoKK251bF92YWxpZGF0ZShzdHJ1Y3QgcnBjX3Rhc2sgKnRhc2ssIHUzMiAqcCkKK3sKKwlycGNfYXV0aGZsYXZvcl90CWZsYXZvcjsKKwl1MzIJCQlzaXplOworCisJZmxhdm9yID0gbnRvaGwoKnArKyk7CisJaWYgKG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GMgfHwgbGVuIDwxKSBsZW4gPSAtMTsKKwllbHNlIHsKKwkJKmJwKysgPSAnICc7CisJCWxlbi0tOworCX0KKwkqYnBwID0gYnA7CisJKmxwID0gbGVuOworfQorCit2b2lkIHF3b3JkX2FkZGhleChjaGFyICoqYnBwLCBpbnQgKmxwLCBjaGFyICpidWYsIGludCBibGVuKQoreworCWNoYXIgKmJwID0gKmJwcDsKKwlpbnQgbGVuID0gKmxwOworCisJaWYgKGxlbiA8IDApIHJldHVybjsKKworCWlmIChsZW4gPiAyKSB7CisJCSpicCsrID0gJ1xcJzsKKwkJKmJwKysgPSAneCc7CisJCWxlbiAtPSAyOworCQl3aGlsZSAoYmxlbiAmJiBsZW4gPj0gMikgeworCQkJdW5zaWduZWQgY2hhciBjID0gKmJ1ZisrOworCQkJKmJwKysgPSAnMCcgKyAoKGMmMHhmMCk+PjQpICsgKGM+PTB4YTApKignYSctJzknLTEpOworCQkJKmJwKysgPSAnMCcgKyAoYyYweDBmKSArICgoYyYweDBmKT49MHgwYSkqKCdhJy0nOSctMSk7CisJCQlsZW4gLT0gMjsKKwkJCWJsZW4tLTsKKwkJfQorCX0KKwlpZiAoYmxlbiB8fCBsZW48MSkgbGVuID0gLTE7CisJZWxzZSB7CisJCSpicCsrID0gJyAnOworCQlsZW4tLTsKKwl9CisJKmJwcCA9IGJwOworCSpscCA9IGxlbjsKK30KKworc3RhdGljIHZvaWQgd2Fybl9ub19saXN0ZW5lcihzdHJ1Y3QgY2FjaGVfZGV0YWlsICpkZXRhaWwpCit7CisJaWYgKGRldGFpbC0+bGFzdF93YXJuICE9IGRldGFpbC0+bGFzdF9jbG9zZSkgeworCQlkZXRhaWwtPmxhc3Rfd2FybiA9IGRldGFpbC0+bGFzdF9jbG9zZTsKKwkJaWYgKGRldGFpbC0+d2Fybl9ub19saXN0ZW5lcikKKwkJCWRldGFpbC0+d2Fybl9ub19saXN0ZW5lcihkZXRhaWwpOworCX0KK30KKworLyoKKyAqIHJlZ2lzdGVy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ghdGFzaykKKwkJZ290byBjbGVhbnVwOworCisJcnBjX2luaXRfdGFzayh0YXNrLCBjbG50LCBjYWxsYmFjaywgZmxhZ3MpOworCisJLyogUmVwbGFjZSB0a19yZWxlYXNlICovCisJdGFzay0+dGtfcmVsZWFzZSA9IHJwY19kZWZhdWx0X2ZyZWVfdGFzazsKKworCWRwcmludGsoIlJQQzogJTRkIGFsbG9jYXRlZCB0YXNrXG4iLCB0YXNrLT50a19waWQpOworCXRhc2stPnRrX2ZsYWdzIHw9IFJQQ19UQVNLX0RZTkFNSUM7CitvdXQ6CisJcmV0dXJuIHRhc2s7CisKK2NsZWFudXA6CisJLyogQ2hlY2sgd2hldGhlciB0byByZWxlYXNlIHRoZSBjbGllbnQgKi8KKwlpZiAoY2xudCkgeworCQlwcmludGsoInJwY19uZXdfdGFzazogZmFpbGVkLCB1c2Vycz0lZCwgb25lc2hvdD0lZFxuIiwKKwkJCWF0b21pY19yZWFkKCZjbG50LT5jbF91c2VycyksIGNsbnQtPmNsX29uZXNob3QpOworCQlhdG9taWNfaW5jKCZjbG50LT5jbF91c2Vycyk7IC8qIHByZXRlbmQgd2Ugd2VyZSB1c2VkIC4uLiAqLworCQlycGNfcmVsZWFzZV9jbGllbnQoY2xudCk7CisJfQorCWdvdG8gb3V0OworfQorCit2b2lkIHJwY19yZWxlYXNlX3Rhc2soc3RydWN0IHJwY190YXNrICp0YXNrKQoreworCWRwcmludGsoIlJQQzogJTRkIHJlbGVhc2UgdGFza1xuIiwgdGFzay0+dGtfcGlkKTsKKworI2lmZGVmIFJQQ19ERUJVRworCUJVR19PTih0YXNrLT50a19tYWdpYyAhPSBSUENfVEFTS19NQUdJQ19JRCk7CisjZW5kaWYKKworCS8qIFJlbW92ZSBmcm9tIGdsb2JhbCB0YXNrIGxpc3QgKi8KKwlzcGluX2xvY2soJnJwY19zY2hlZF9sb2NrKTsKKwlsaXN0X2RlbCgmdGFzay0+dGtfdGFzayk7CisJc3Bpbl91bmxvY2soJnJwY19zY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dF9oZWFkICpsaXN0LCBzdHJ1Y3Qgc29jayAqc2spCit7CisJQlVHX1RSQVAoc2tfdW5oYXNoZWQoc2spKTsKKwlza19hZGRfbm9kZShzaywgbGlzdCk7Cit9CisKK3N0YXRpYyBpbmxpbmUgdm9pZCB1bml4X3JlbW92ZV9zb2NrZXQoc3RydWN0IHNvY2sgKnNrKQoreworCXdyaXRlX2xvY2soJnVuaXhfdGFibGVfbG9jayk7CisJX191bml4X3JlbW92ZV9zb2NrZXQoc2spOworCXdyaXRlX3VubG9jaygmdW5peF90YWJsZV9sb2NrKTsKK30KKworc3RhdGljIGlubGluZSB2b2lkIHVuaXhfaW5zZXJ0X3NvY2tldChzdHJ1Y3QgaGxpc3RfaGVhZCAqbGlzdCwgc3RydWN0IHNvY2sgKnNrKQoreworCXdyaXRlX2xvY2soJnVuaXhfdGFibGVfbG9jayk7CisJX191bml4X2luc2VydF9zb2NrZXQobGlzdCwgc2spOworCXdyaXRlX3VubG9jaygmdW5peF90YWJsZV9sb2NrKTsKK30KKworc3RhdGljIHN0cnVjdCBzb2NrICpfX3VuaXhfZmluZF9zb2NrZXRfYnluYW1lKHN0cnVjdCBzb2NrYWRkcl91biAqc3VubmFtZSwKKwkJCQkJICAgICAgaW50IGxlbiwgaW50IHR5cGUsIHVuc2lnbmVkIGhhc2gpCit7CisJc3RydWN0IHNvY2sgKnM7CisJc3RydWN0IGhsaXN0X25vZGUgKm5vZGU7CisKKwlza19mb3JfZWFjaChzLCBub2RlLCAmdW5peF9zb2NrZXRfdGFibGVbaGFzaCBeIHR5cGVdKSB7CisJCXN0cnVjdCB1bml4X3NvY2sgKnUgPSB1bml4X3NrKHMpOworCisJCWlmICh1LT5hZGRyLT5sZW4gPT0gbGVuICYmCisJCSAgICAhbWVtY21wKHUtPmFkZHItPm5hbWUsIHN1bm5hbWUsIGxlbikpCisJCQlnb3RvIGZvdW5kOworCX0KKwlzID0gTlVMTDsKK2ZvdW5kOgorCXJldHVybiBzOworfQorCitzdGF0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VkIGFyZSBzdGlsbCBhbGl2ZS5cbiIsIHNrLCBhdG9taWNfcmVhZCgmdW5peF9ucl9zb2NrcykpOworI2VuZGlmCit9CisKK3N0YXRpYyBpbnQgdW5peF9yZWxlYXNlX3NvY2sgKHN0cnVjdCBzb2NrICpzaywgaW50IGVtYnJpb24pCit7CisJc3RydWN0IHVuaXhfc29jayAqdSA9IHVuaXhfc2soc2spOworCXN0cnVjdCBkZW50cnkgKmRlbnRyeTsKKwlzdHJ1Y3QgdmZzbW91bnQgKm1udDsKKwlzdHJ1Y3Qgc29jayAqc2twYWlyOworCXN0cnVjdCBza19idWZmICpza2I7CisJaW50IHN0YXRlOworCisJdW5peF9yZW1vdmVfc29ja2V0KHNrKTsKKworCS8qIENsZWFyIHN0YXRlICovCisJdW5peF9zdGF0ZV93bG9jayhzayk7CisJc29ja19vcnBoYW4oc2spOworCXNrLT5za19zaHV0ZG93biA9IFNIVVRET1dOX01BU0s7CisJZGVudHJ5CSAgICAgPSB1LT5kZW50cnk7CisJdS0+ZGVudHJ5ICAgID0gTlVMTDsKKwltbnQJICAgICA9IHUtPm1udDsKKwl1LT5tbnQJICAgICA9IE5VTEw7CisJc3RhdGUgPSBzay0+c2tfc3RhdGU7CisJc2stPnNrX3N0YXRlID0gVENQX0NMT1NFOworCXVuaXhfc3RhdGVfd3VubG9jayhzayk7CisKKwl3YWtlX3VwX2ludGVycnVwdGlibGVfYWxsKCZ1LT5wZWVyX3dhaXQpOworCisJc2twYWlyPXVuaXhfcGVlcihzayk7CisKKwlpZiAoc2twYWlyIT1OVUxMKSB7CisJCWlmIChzay0+c2tfdHlwZSA9PSBTT0NLX1NUUkVBTSB8fCBzay0+c2tfdHlwZSA9PSBTT0NLX1NFUVBBQ0tFVCkgeworCQkJdW5peF9zdGF0ZV93bG9jayhza3BhaXIpOworCQkJLyogTm8gbW9yZSB3cml0ZXMgKi8KKwkJCXNrcGFpci0+c2tfc2h1dGRvd24gPSBTSFVURE9XTl9NQVNLOworCQkJa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lmICh1bml4X3BlZXIoc2spID09IG90aGVyKSB7CisJCQl1bml4X3BlZXIoc2spPU5VTEw7CisJCQl1bml4X3N0YXRlX3d1bmxvY2soc2spOworCisJCQl1bml4X2RncmFtX2Rpc2Nvbm5lY3RlZChzaywgb3RoZXIpOworCQkJc29ja19wdXQob3RoZXIpOworCQkJZXJyID0gLUVDT05OUkVGVVNFRDsKKwkJfSBlbHNlIHsKKwkJCXVuaXhfc3RhdGVfd3VubG9jayhzayk7CisJCX0KKworCQlvdGhlciA9IE5VTEw7CisJCWlmIChlcnIpCisJCQlnb3RvIG91dF9mcmVlOworCQlnb3RvIHJlc3RhcnQ7CisJfQorCisJZXJyID0gLUVQSVBFOworCWlmIChvdGhlci0+c2tfc2h1dGRvd24gJiBSQ1ZfU0hVVERPV04pCisJCWdvdG8gb3V0X3VubG9jazsKKworCWlmIChzay0+c2tfdHlwZSAhPSBTT0NLX1NFUVBBQ0tFVCkgeworCQllcnIgPSBzZWN1cml0eV91bml4X21heV9zZW5kKHNrLT5za19zb2NrZXQsIG90aGVyLT5za19zb2NrZXQpOworCQlpZiAoZXJyKQorCQkJZ290byBvdXRfdW5sb2NrOworCX0KKworCWlmICh1bml4X3BlZXIob3RoZXIpICE9IHNrICYmCisJICAgIChza2JfcXVldWVfbGVuKCZvdGhlci0+c2tfcmVjZWl2ZV9xdWV1ZSkgPgorCSAgICAgb3RoZXItPnNrX21heF9hY2tfYmFja2xvZykpIHsKKwkJaWYgKCF0aW1lbykgeworCQkJZXJyID0gLUVBR0FJTjsKKwkJCWdvdG8gb3V0X3VubG9jazsKKwkJfQorCisJCXRpbWVvID0gdW5peF93YWl0X2Zvcl9wZWVyKG90aGVyLCB0aW1lbyk7CisKKwkJZXJyID0gc29ja19pbnRyX2Vycm5vKHRpbWVvKTsKKwkJaWYgKHNpZ25hbF9wZW5kaW5nKGN1cnJlbnQpKQorCQkJZ290byBvdXRfZnJlZTsKKworCQlnb3RvIHJlc3RhcnQ7CisJfQorCisJc2tiX3F1ZXVlX3RhaWwoJm90aGVyLT5za19yZWNlaXZlX3F1ZXVlLCBza2IpOworCXVuaXhfc3RhdGVfcnVubG9jayhvdGhlcik7CisJb3RoZXItPnNrX2RhdGFfcmVhZHkob3RoZXIsIGxlbik7CisJc29ja19wdXQob3RoZXIpOworCXNjbV9kZXN0cm95KHNpb2NiLT5zY20pOworCXJldHVybiBsZW47CisKK291dF91bmxvY2s6CisJdW5peF9zdGF0ZV9ydW5sb2NrKG90aGVyKTsKK291dF9mcmVlOgorCWtmcmVlX3NrYihza2IpOworb3V0OgorCWlmIChvdGhlcikKKwkJc29ja19wdXQob3RoZXIpOworCXNjbV9kZXN0cm95KHNpb2NiLT5zY20pOworCXJldHVybiBlcnI7Cit9CisKKwkJCitzdGF0aWMgaW50IHVuaXhfc3RyZWFtX3NlbmRtc2coc3RydWN0IGtpb2NiICpraW9jYiwgc3RydWN0IHNvY2tldCAqc29jaywKKwkJCSAgICAgICBzdHJ1Y3QgbXNnaGRyICptc2csIHNpemVfdCBsZW4pCit7CisJc3RydWN0IHNvY2tfaW9jYiAqc2lvY2IgPSBraW9jYl90b19zaW9jYihraW9jYik7CisJc3RydWN0IHNvY2sgKnNrID0gc29jay0+c2s7CisJc3RydWN0IHNvY2sgKm90aGVyID0gTlVMTDsKKwlzdHJ1Y3Qgc29ja2FkZHJfdW4gKnN1bmFkZHI9bXNnLT5tc2dfbmFtZTsKKwlpbnQgZXJyLHNpemU7CisJc3RydWN0IHNrX2J1ZmYgKnNrYjsKKwlpbnQgc2VudD0wOworCXN0cnVjdCBzY21fY29va2llIHRtcF9zY207CisKKwlpZiAoTlVMTCA9PSBzaW9jYi0+c2NtKQorCQlzaW9jYi0+c2NtID0gJnRtcF9zY207CisJZXJyID0gc2NtX3NlbmQoc29jaywgbXNnLCBzaW9jYi0+c2NtKTsKKwlpZiAoZXJyIDwgMCkKKwkJcmV0dXJuIGVycjsKKworCWVyciA9IC1FT1BOT1RTVVBQOworCWlmIChtc2ctPm1zZ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CQlzZW50Kz1zaXplOworCX0KKwlzb2NrX3B1dChvdGhlcik7CisKKwlzY21fZGVzdHJveShzaW9jYi0+c2NtKTsKKwlzaW9jYi0+c2NtID0gTlVMTDsKKworCXJldHVybiBzZW50OworCitwaXBlX2Vycl9mcmVlOgorCXVuaXhfc3RhdGVfcnVubG9jayhvdGhlcik7CisJa2ZyZWVfc2tiKHNrYik7CitwaXBlX2VycjoKKwlpZiAoc2VudD09MCAmJiAhKG1zZy0+bXNnX2ZsYWdzJk1TR19OT1NJR05BTCkpCisJCXNlbmRfc2lnKFNJR1BJUEUsY3VycmVudCwwKTsKKwllcnIgPSAtRVBJUEU7CitvdXRfZXJyOgorICAgICAgICBpZiAob3RoZXIpCisJCXNvY2tfcHV0KG90aGVyKTsKKwlzY21fZGVzdHJveShzaW9jYi0+c2NtKTsKKwlzaW9jYi0+c2NtID0gTlVMTDsKKwlyZXR1cm4gc2VudCA/IDogZXJyOworfQorCitzdGF0aWMgaW50IHVuaXhfc2VxcGFja2V0X3NlbmRtc2coc3RydWN0IGtpb2NiICpraW9jYiwgc3RydWN0IHNvY2tldCAqc29jaywKKwkJCQkgIHN0cnVjdCBtc2doZHIgKm1zZywgc2l6ZV90IGxlbikKK3sKKwlpbnQgZXJyOworCXN0cnVjdCBzb2NrICpzayA9IHNvY2stPnNrOworCQorCWVyciA9IHNvY2tfZXJyb3Ioc2spOworCWlmIChlcnIpCisJCXJldHVybiBlcnI7CisKKwlpZiAoc2stPnNrX3N0YXRlICE9IFRDUF9FU1RBQkxJU0hFRCkKKwkJcmV0dXJuIC1FTk9UQ09OTjsKKworCWlmIChtc2ctPm1zZ19uYW1lbGVuKQorCQltc2ctPm1zZ19uYW1lbGVuID0gMDsKKworCXJldHVybiB1bml4X2RncmFtX3NlbmRtc2coa2lvY2IsIHNvY2ssIG1zZywgbGVuKTsKK30KKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA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ciB0aGUgdGVybXMgb2YgdGhlIEdOVSBHZW5lcmFsIFB1YmxpYyBMaWNlbnNlCisqCQlhcyBwdWJsaXNoZWQgYnkgdGhlIEZyZWUgU29mdHdhcmUgRm91bmRhdGlvbjsgZWl0aGVyIHZlcnNpb24KKyoJCTIgb2YgdGhlIExpY2Vuc2UsIG9yIChhdCB5b3VyIG9wdGlvbikgYW55IGxhdGVyIHZlcnNpb24uCisqID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyogRHVlIENyZWRpdDoKKyogICAgICAgICAgICAgICBXYW5waXBlIHNvY2tldCBsYXllciBpcyBiYXNlZCBvbiBQYWNrZXQgYW5kIAorKiAgICAgICAgICAgICAgIHRoZSBYMjUgc29ja2V0IGxheWVycy4gVGhlIGFib3ZlIHNvY2tldHMgd2VyZSAKKyogICAgICAgICAgICAgICB1c2VkIGZvciB0aGUgc3BlY2lmaWMgdXNlIG9mIFNhbmdvbWEgVGVjaG5vbG9pZ2VzIAorKiAgICAgICAgICAgICAgIEFQSSBwcm9ncmFtcy4gCisqICAgICAgICAgICAgICAgUGFja2V0IHNvY2tldCBBdXRob3JzOiBSb3NzIEJpcm8sIEZyZWQgTi4gdmFuIEtlbXBlbiBhbmQgCisqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBBbGFuIENveC4KKyogICAgICAgICAgICAgICBYMjUgc29ja2V0IEF1dGhvcjogSm9uYXRoYW4gTmF5bG9yLgorKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisqIE1hciAxNSwgMjAwMiAgQXJuYWxkbyBDLiBNZWxvICBvIFVzZSB3cF9zaygpLT5udW0sIGFzIGl0IGlzbnQgYW55bW9yZSBpbiBzb2NrCisqIEFwciAyNSwgMjAwMCAgTmVuYWQgQ29yYmljICAgICBvIEFkZGVkIHRoZSBhYmlsaXR5IHRvIHNlbmQgemVybyBsZW5ndGggcGFja2V0cy4KKyogTWFyIDEzLCAyMDAwICBOZW5hZCBDb3JiaWMJIG8gQWRkZWQgYSB0eCBidWZmZXIgY2hlY2sgdmlhIGlvY3RsIGNhbGwuCisqIE1hciAwNiwgMjAwMCAgTmVuYWQgQ29yYmljICAgICBvIEZpeGVkIHRoZSBjb3JydXB0IHNvY2sgbGNuIHByb2JsZW0uCisqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFNlcnZlciBhbmQgY2xpZW50IGFwcGxpY2F0b24gY2FuIHJ1bgorKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaW11bHRhbmVvdXNseSB3aXRob3V0IGNvbmZsaWN0cy4KKyogRmViIDI5LCAyMDAwICBOZW5hZCBDb3JiaWMgICAgIG8gQWRkZWQgc3VwcG9ydCBmb3IgUFZDIHByb3RvY29scywgc3VjaCBhcworKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDSERMQywgRnJhbWUgUmVsYXkgYW5kIEhETEMgQVBJLgorKiBKYW4gMTcsIDIwMDAgCU5lbmFkIENvcmJpYwkgbyBJbml0aWFsIHZlcnNpb24sIGJhc2VkIG9uIEFGX1BBQ0tFVCBzb2NrZXQuCisqCQkJICAgICAgICAgICBYMjVBUEkgc3VwcG9ydCBvbmx5LiAKKyoKKyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKworI2luY2x1ZGUgPGxpbnV4L2NvbmZpZy5oPgorI2luY2x1ZGUgPGxpbnV4L3R5cGVzLmg+CisjaW5jbHVkZSA8bGludXgvc2NoZWQuaD4KKyNpbmNsdWRlIDxsaW51eC9tbS5oPgorI2luY2x1ZGUgPGxpbnV4L2ZjbnRsLmg+CisjaW5jbHVkZSA8bGludXgvc29ja2V0Lmg+CisjaW5jbHVkZSA8bGludXgvaW4u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RhdGlzdGljcyB3aWxsIGJlIGdlbmVyYXRlZC4gCisgKi8KKworCisvKiBUaGUgY29kZSBiZWxvdyBpcyB1c2VkIHRvIHRlc3QgbWVtb3J5IGxlYWtzLiBJdCBwcmludHMgb3V0CisgKiBhIG1lc3NhZ2UgZXZlcnkgdGltZSBrbWFsbG9jIGFuZCBrZnJlZSBzeXN0ZW0gY2FsbHMgZ2V0IGV4ZWN1dGVkLgorICogSWYgdGhlIGNhbGxzIG1hdGNoIHRoZXJlIGlzIG5vIGxlYWsgOikKKyAqLworCisvKioqKioqKioqKipGT1IgREVCVUdHSU5HIFBVUlBPU0VTKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisjZGVmaW5lIEtNRU1fU0FGRVRZWk9ORSA4CisKK3N0YXRpYyB2b2lkICogZGJnX2ttYWxsb2ModW5zaWduZWQgaW50IHNpemUsIGludCBwcmlvLCBpbnQgbGluZSkgeworCXZvaWQgKiB2ID0ga21hbGxvYyhzaXplLHByaW8pOworCXByaW50ayhLRVJOX0lORk8gImxpbmUgJWQgIGttYWxsb2MoJWQsJWQpID0gJXBcbiIsbGluZSxzaXplLHByaW8sdik7CisJcmV0dXJuIHY7Cit9CitzdGF0aWMgdm9pZCBkYmdfa2ZyZWUodm9pZCAqIHYsIGludCBsaW5lKSB7CisJcHJpbnRrKEtFUk5fSU5GTyAibGluZSAlZCAga2ZyZWUoJXApXG4iLGxpbmUsdik7CisJa2ZyZWUodik7Cit9CisKKyNkZWZpbmUga21hbGxvYyh4LHkpIGRiZ19rbWFsbG9jKHgseSxfX0xJTkVfXykKKyNkZWZpbmUga2ZyZWUoeCkgZGJnX2tmcmVlKHgsX19MSU5FX18pCisqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisKKworLyogTGlzdCBvZiBhbGwgd2FucGlwZSBzb2NrZXRzLiAqLworSExJU1RfSEVBRCh3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a2ZyZWVfc2tiKHNrYik7CisJCQlicmVhazsKKwkJY2FzZSBXQU5fUEFDS0VUX0VSUjoKKwkJCXNrLT5za19zdGF0ZSA9IGNoYW4tPnN0YXRlOworCQkJaWYgKHNvY2tfcXVldWVfZXJyX3NrYihzayxza2IpPDApeworCQkJCXJldHVybiAtRU5PTUVNOworCQkJfQorCQkJYnJlYWs7CisJCWRlZmF1bHQ6CisJCQlwcmludGsoS0VSTl9JTkZPICJ3YW5zb2NrOiBCSCBJbGxlZ2FsIFBhY2tldCBUeXBlIERyb3BwaW5nXG4iKTsKKwkJCWtmcmVlX3NrYihza2IpOyAKKwkJCWJyZWFrOworCX0KKworLy8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/CisvLwlpZiAoc2stPnNrX3N0YXRlID09IFdBTlNPQ0tfRElTQ09OTkVDVEVEKXsKKy8vCQlpZiAoc2stPnNrX3phcHBlZCkgeworLy8JCQkvL3ByaW50ayhLRVJOX0lORk8gIndhbnNvY2s6IERpc2Nvbm5lY3RlZCwga2lsbGluZyBlYXJseVxuIik7CisvLwkJCXdhbnBpcGVfdW5saW5rX2RyaXZlcihzayk7CisvLwkJCXNrLT5za19ib3VuZF9kZXZfaWYgPSAwOworLy8JCX0KKy8vCX0KKworCXJldHVybiAwOworfQorCisvKj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogd2FucGlwZV9saXN0ZW5fcmN2CisgKgorICoJV2FucGlwZSBMSVNURU4gc29ja2V0IGJvdHRvbSBoYWxmIGhhbmRsZXIuICBUaGlzIGZ1bmN0aW9uCisgKiAgICAgIGlzIGNhbGxlZCBieSB0aGUgV0FOUElQRSBkZXZpY2UgZHJpdmVycyB0byBxdWV1ZSBhbgorICogICAgICBpbmNvbWluZyBjYWxsIGludG8gdGhlIHNvY2tldCBsaXN0ZW5pbmcgcXVldWUuIAorICogICAgICBPbmNlIHRoZSBwYWNrZXQgaXMgcXVldWVkLCB0aGUgd2FpdGluZyBhY2NlcHQoKSBwcm9jZXNzIAorICogICAgICBpcyB3b2tlbiB1cC4KKyAqCisgKiAgICAgIER1cmluZyBzb2NrZXQgYmluZCwgdGhpcyBmdW5jdGlvbiBpcyBib3VuZGVkIGludG8KKyAqICAgICAgV0FOUElQRSBkcml2ZXIgcHJpdmF0ZS4gCisgKiAKKyAqICAgICAgSU1QT1JUQU5UIE5PVEU6CisgKiAgICAgICAgICBUaGUgYWNjZXB0IGNhbGwoKSBpcyB3YWl0aW5nIGZvciBhbiBza2IgcGFja2V0CisgKiAgICAgICAgICB3aGljaCBjb250YWlucyBhIHBvaW50ZXIgdG8gYSBkZXZpY2Ugc3RydWN0dXJlLgorICoKKyAqICAgICAgICAgIFdoZW4gd2UgZG8gYSBiaW5kIHRvIGEgZGV2aWNlIHN0cnVjdHJlLCB3ZSAKKyAqICAgICAgICAgIGJpbmQgYSBuZXdseSBjcmVhdGVkIHNvY2tldCBpbnRvICJjaGFuLT5zayIuICBUaHVzLCAKKyAqICAgICAgICAgIHdoZW4gYWNjZXB0IHJlY2VpdmVzIHRoZSBza2IgcGFja2V0LCBpdCB3aWxsIGtub3cgCisgKiAgICAgICAgICBmcm9tIHdoaWNoIGRldiBpdCBjYW1lIGZvcm0sIGFuZCBpbiB0dXJuIGl0IHdpbGwga25vdworICogICAgICAgICAgdGhlIGFkZHJlc3Mgb2YgdGhlIG5ldyBzb2NrLgorICoKKyAqICAJTk9URTogVGhpcyBmdW5jdGlvbiBnZXRzIGNhbGxlZCBmcm9tIGRyaXZlciBJU1IuCisgKj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ki8KKworc3RhdGljIGludCB3YW5waXBlX2xpc3Rlbl9yY3YgKHN0cnVjdCBza19idWZmICpza2IsICBzdHJ1Y3Qgc29jayAqc2spCit7CisJd2FucGlwZV9vcHQgKndwID0gd3Bfc2soc2spLCAqbmV3d3A7CisJc3RydWN0I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wuICBIb3dldmVyLCB3ZSB1c2UKKwkgKiB0aGUgZGV2IGZpZWxkIGluIHRoZSBhY2NlcHQgZnVuY3Rpb24uKi8gCisJaWYgKGF0b21pY19yZWFkKCZzay0+c2tfcm1lbV9hbGxvYykgKyBza2ItPnRydWVzaXplID49IAorCSAgICAodW5zaWduZWQpc2stPnNrX3JjdmJ1ZikgeworCisgICAgICAgICAJd2FucGlwZV91bmxpbmtfZHJpdmVyKG5ld3NrKTsKKwkJd2FucGlwZV9raWxsX3NvY2tfaXJxIChuZXdzayk7CisJCS0tc2stPnNrX2Fja19iYWNrbG9nOworCQlyZXR1cm4gLUVOT01FTTsKKwl9CQorCisJc2tiX3NldF9vd25lcl9yKHNrYiwgc2spOworCXNrYl9xdWV1ZV90YWlsKCZzay0+c2tfcmVjZWl2ZV9xdWV1ZSwgc2tiKTsKKwlzay0+c2tfZGF0YV9yZWFkeShzaywgc2tiLT5sZW4pOworCQorCXJldHVybiAwOworfQorCisKKworLyo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIHdhbnBpcGVfbWFrZV9uZXcKKyAqCisgKglDcmVhdGUgYSBuZXcgc29jaywgYW5kIGFsbG9jYXRlIGEgd2FucGlwZSBwcml2YXRlCisgKiAgICAgIHN0cnVjdHVyZSB0byBpdC4gQWxzbywgY29weSB0aGUgaW1wb3J0YW50IGRhdGEKKyAqICAgICAgZnJvbSB0aGUgb3JpZ2luYWwgc29jayB0byB0aGUgbmV3IHNvY2suCisgKgorICogICAgICBUaGlzIGZ1bmN0aW9uIGlzIHVzZWQgYnkgd2FucGlwZV9saXN0ZW5fcmN2KCkgbGlzdGVuCisgKiAgICAgIGJvdHRvbSBoYWxmIGhhbmRsZXIuICBBIGNvcHkgb2YgdGhlIGxpc3RlbmluZyBzb2NrCisgKiAgICAgIGlzIGNyZWF0ZWQgdXNpbmcgdGhpcyBmdW5jdGlvbi4KKyAqCisgKj09PT09PT09P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90byB3YW5waXBlX3Byb3RvID0geworCS5uYW1lCSAgPSAiV0FOUElQRSIsCisJLm93bmVyCSAgPSBUSElTX01PRFVMRSwKKwkub2JqX3NpemUgPSBzaXplb2Yoc3RydWN0IHNvY2spLAorfTsKKworLyo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIHdhbnBpcGVfbWFrZV9uZXcKKyAqCisgKglBbGxvY2F0ZSBtZW1vcnkgZm9yIHRoZSBhIG5ldyBzb2NrLCBhbmQgc29jaworICogICAgICBwcml2YXRlIGRhdGEuICAKKyAqCQorICoJSW5jcmVtZW50IHRoZSBtb2R1bGUgdXNlIGNvdW50LgorICogICAgICAgCQorICogICAgICBUaGlzIGZ1bmN0aW9uIGlzIHVzZWQgYnkgd2FucGlwZV9jcmVhdGUoKSBhbmQgCisgKiAgICAgIHdhbnBpcGVfbWFrZV9uZXcoKSBmdW5jdGlvbnMuIAorICoKKyAqPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0qLworCitzdGF0aWMgc3RydWN0IHNvY2sgKndhbnBpcGVfYWxsb2Nfc29ja2V0KHZvaWQpCit7CisJc3RydWN0IHNvY2sgKnNrOworCXN0cnVjdCB3YW5waXBlX29wdCAqd2FuX29wdDsKKworCWlmICgoc2sgPSBza19hbGxvYyhQRl9XQU5QSVBFLCBHRlBfQVRPTUlDLCAmd2FucGlwZV9wcm90bywgMSkpID09IE5VTEwpCisJCXJldHVybiBOVUxMOworCisJaWYgKCh3YW5fb3B0ID0ga21hbGxvYyhzaXplb2Yoc3RydWN0IHdhbnBpcGVfb3B0KSwgR0ZQX0FUT01JQykpID09IE5VTEwpIHsKKwkJc2tfZnJlZShzayk7CisJCXJldHVybiBOVUxMOworCX0KKwltZW1zZXQod2FuX29wdCwgMHgwMCwgc2l6ZW9mKHN0cnVjdCB3YW5waXBlX29wdCkpOworCisJd3Bfc2soc2sp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FDRShkZXYpKTsKKwlza2ItPm5oLnJhdyA9IHNrYi0+ZGF0YTsKKworCS8qIFJldHVybnMgLUVGQVVMVCBvbiBlcnJvciAqLworCWVyciA9IG1lbWNweV9mcm9taW92ZWMoc2tiX3B1dChza2IsbGVuKSwgbXNnLT5tc2dfaW92LCBsZW4pOworCWlmIChlcnIpeworCQlnb3RvIG91dF9mcmVlOworCX0KKworCWlmIChkZXYtPmhhcmRfaGVhZGVyKSB7CisJCWludCByZXM7CisJCWVyciA9IC1FSU5WQUw7CisJCXJlcyA9IGRldi0+aGFyZF9oZWFkZXIoc2tiLCBkZXYsIG50b2hzKHByb3RvKSwgYWRkciwgTlVMTCwgbGVuKTsKKwkJaWYgKHJlczwwKXsKKwkJCWdvdG8gb3V0X2ZyZWU7CisJCX0KKwl9CisKKwlza2ItPnByb3RvY29sID0gcHJvdG87CisJc2tiLT5kZXYgPSBkZXY7CisJc2tiLT5wcmlvcml0eSA9IHNrLT5za19wcmlvcml0eTsKKwlza2ItPnBrdF90eXBlID0gV0FOX1BBQ0tFVF9EQVRBOworCisJZXJyID0gLUVORVRET1dOOworCWlmICghKGRldi0+ZmxhZ3MgJiBJRkZfVVApKQorCQlnb3RvIG91dF9mcmVlOworCisJaWYgKGF0b21pY19yZWFkKCZzay0+c2tfd21lbV9hbGxvYykgKyBza2ItPnRydWVzaXplID4KKwkgICAgKHVuc2lnbmVkIGludClzay0+c2tfc25kYnVmKXsKKwkJa2ZyZWVfc2tiKHNrYik7CisJCXJldHVybiAtRU5PQlVGUzsKKwl9CisKKwlza2JfcXVldWVfdGFpbCgmc2stPnNrX3dyaXRlX3F1ZXVlLHNrYik7CisJYXRvbWljX2luYygmd3AtPnBhY2tldF9zZW50KTsKKworCWlmICghKHRlc3RfYW5kX3NldF9iaXQoMCwgJndwLT50aW1lcikpKQorCQltb2RfdGltZXIoJndwLT50eF90aW1lciwgamlmZmllcyArIDEpOworCQorCXJldHVybihsZW4pOworCitvdXRfZnJlZToKKwlrZnJl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09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIHdhbnBpcGVfZGVzdHJveV90aW1lciAKKyAqCisgKglVc2VkIGJ5IHdhbnBpcGVfcmVsZWFzZSwgdG8gZGVsYXkgcmVsZWFzZSBvZgorICogICAgICB0aGUgc29ja2V0LgorICo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PSovCisKK3N0YXRpYyB2b2lkIHdhbnBpcGVfZGVzdHJveV90aW1lcih1bnNpZ25lZCBsb25nIGRhdGEpCit7CisJc3RydWN0IHNvY2sgKnNrPShzdHJ1Y3Qgc29jayAqKWRhdGE7CisJd2FucGlwZV9vcHQgKndwID0gd3Bfc2soc2spOworCisJaWYgKCghYXRvbWljX3JlYWQoJnNrLT5za193bWVtX2FsbG9jKSAmJgorCSAgICAgIWF0b21pY19yZWFkKCZzay0+c2tfcm1lbV9hbGxvYykpIHx8CisJICAgICgrK3dwLT5mb3JjZSA9PSA1KSkgeworCisJCWlmIChhdG9taWNfcmVhZCgmc2stPnNrX3dtZW1fYWxsb2MpIHx8CisJCSAgICBhdG9taWNfcmVhZCgmc2stPnNrX3JtZW1fYWxsb2MpKQorCQkJcHJpbnRrKEtFUk5fSU5GTyAid2Fuc29jazogV2FybmluZywgUGFja2V0IERpc2NhcmRlZCBkdWUgdG8gc29jayBzaHV0ZG93biFcbiIpOworCisJCWtmcmVlKHdwKTsKKwkJd3Bfc2soc2spID0gTlVMTDsKKwkJCisJCWlmIChhdG9taWNfcmVhZCgmc2stPnNrX3JlZmNudCkgIT0gMSkgeworCQkJYXRvbWljX3NldCgmc2stPnNrX3JlZmNudCwgMSk7CisJCQlEQkdfUFJJTlRLKEtFUk5fSU5GTyAid2Fuc29jazogRXJyb3IsIHdyb25nIHJlZmVyZW5jZSBjb3VudDogJWkgISA6ZGVsYXkuXG4iLAorCQkJCQlhdG9taWNfcmVhZCgmc2stPnNrX3JlZmNudCkpOworCQl9CisJCXNvY2tfcHV0KHNrKTsKKwkJYXRvbWljX2RlYygmd2FucGlwZV9zb2Nrc19ucik7CisJCXJldHVybjsKKwl9CisKKwlzay0+c2tfdGltZXIuZXhwaXJlcyA9IGppZmZpZXMgKyA1ICogSFo7CisJYWRkX3RpbWVyKCZzay0+c2tfdGltZXIpOworCXByaW50ayhLRVJOX0lORk8gIndhbnNvY2s6IHBhY2tldCBzayBkZXN0cm95IGRlbGF5ZWRcbiIpOworfQorCisvKj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogd2FucGlwZV91bmxpbmtfZHJpdmVyCisgKgorICogCVdoZW4gdGhlIHNvY2tldCBpcyByZWxlYXNlZCwgdGhpcyBmdW5jdGlvbiBpcyAKKyAqICAgICAgdXNlZCB0byByZW1vdmUgbGlua3MgdGhhdCBiaW5kIHRoZSBzb2NrIGFuZCB0aGUKKyAqICAgICAgZHJpdmVyIHRvZ2V0aGVyLiAgCisgKj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ki8KK3N0YXRpYyB2b2lkIHdhbnBpcGVfdW5saW5rX2RyaXZlciAoc3RydWN0IHNvY2sgKnNrKQoreworCXN0cnVjdCBuZXRfZGV2aWNlICpkZXY7CisJd2FucGlwZV9jb21tb25fdCAqY2hhbj1OVUxMOworCisJc29ja19yZXNldF9mbGFnKHNrLCBTT0NLX1pBUFBFRCk7CisJc2stPnNrX3N0YXRlID0gV0FOU09DS19ESVNDT05ORUNURUQ7CisJd3Bfc2soc2spLT5kZXYgPSBOVUxMOworCisJZGV2ID0gZGV2X2dldF9ieV9pbmRleChzay0+c2tfYm91bmRfZGV2X2lmKTsKKwlpZiAoIWRldil7CisJCXByaW50ayhLRVJOX0lORk8gIndhbnNvY2s6IE5vIGRldiBvbiByZWxlYXNlXG4iKTsKKwkJcmV0dXJuOworCX0JCQkKKwlkZXZfcHV0KGRldik7CisKKwlpZiAoKGNoYW4gPSBkZXYtPnByaXYpID09IE5VTEwpeworCQlwcmludGsoS0VSTl9JTkZPICJ3YW5zb2NrOiBObyBQcml2IEFyZWEgb24gcmVsZWFzZVxuIik7CisJCXJldHVybjsKKwl9CisKKwlzZXRfYml0KDAsJmNoYW4tPmNvbW1vbl9jcml0aWNhbCk7CisJY2hhbi0+c2s9TlVMTDsKKwljaGFuLT5mdW5jPU5VTEw7CisJY2hhbi0+bWJveD1OVUxMOworCWNoYW4tPnR4X3RpbWVyPU5VTEw7CisJY2xlYXJfYml0KDAsJmNoYW4tPmNvbW1vbl9jcml0aWNhbCk7CisJcmVsZWFzZV9kZXZpY2UoZGV2KTsKKwkKKwlyZXR1cm47Cit9CisKKy8qPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiB3YW5waXBlX2xpbmtfZHJpdmVyCisgKgorICogCVVwb24gc3VjY2Vzc2Z1bCBiaW5kKCksIHNvY2sgaXMgbGlua2VkIHRvIGEgZHJpdmVyCisgKiAgICAgIGJ5IGJpbmRpbmcgaW4gdGhlIHdhbnBpcGVfcmN2KCkgYm90dG9tIGhhbGYgaGFuZGxlcgorICogICAgICB0byB0aGUgZHJpdmVyIGZ1bmN0aW9uIHBvaW50ZXIsIGFzIHdlbGwgYXMgc29jayBhbmQKKyAqICAgICAgc29jayBtYWlsYm94IGFkZHJlc3Nlcy4gIFRoaXMgd2F5IGRyaXZlciBjYW4gcGFzcworICogICAgICBkYXRhIHVwIHRoZSBzb2NrZXQuCisgKj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ki8KKworc3RhdGljIHZvaWQgd2FucGlwZV9saW5rX2RyaXZlcihzdHJ1Y3QgbmV0X2RldmljZSAqZGV2LCBzdHJ1Y3Qgc29jayAqc2spCit7CisJd2FucGlwZV9vcHQgKndwID0gd3Bfc2soc2spOworCXdhbnBpcGVfY29tbW9uX3QgKmNoYW4gPSBkZXYtPnByaXY7CisJaWYgKCFjaGFuKQorCQlyZXR1cm47CisJc2V0X2JpdCgwLCZjaGFuLT5jb21tb25fY3JpdGljYWwpOworCWNoYW4tPnNrPXNrOworCWNoYW4tPmZ1bmM9d2FucGlwZV9yY3Y7CisJY2hhbi0+bWJveCA9IHdwLT5tYm94OworCWNoYW4tPnR4X3RpbWVyID0gJndwLT50eF90aW1lcjsKKwl3cC0+ZGV2ID0gZGV2OworCXNvY2tfc2V0X2ZsYWcoc2ssIFNPQ0tfWkFQUEVEKTsKKwljbGVhcl9iaXQoMCwmY2hhbi0+Y29tbW9uX2NyaXRpY2FsKTsKK30KKworCisvKj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogcmVsZWFzZV9kZXZpY2UKKyAqCisgKiAgIAlEdXJpbmcgc29jayByZWxlYXNlLCBjbGVhciBhIGNyaXRpY2FsIGJpdCwgd2hpY2ggCisgKiAgICAgIG1hcmtzIHRoZSBkZXZpY2UgYSBiZWluZyB0YWtlbi4KKyAqPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0qLworCisKK3N0YXRpYyB2b2lkIHJlbGVhc2VfZGV2aWNlKHN0cnVjdCBuZXRfZGV2aWNlICpkZXYpCit7CisJd2FucGlwZV9jb21tb25fdCAqY2hhbj1kZXYtPnByaXY7CisJY2xlYXJfYml0KDAsKHZvaWQqKSZjaGFuLT5yd19iaW5kKTsKK30KKworLyo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIHdhbnBpcGVfcmVsZWFzZQorICoKKyAqCUNsb3NlIGEgUEFDS0VUIHNvY2tldC4gVGhpcyBpcyBmYWlybHkgc2ltcGxlLiBXZSAKKyAqICAgICAgaW1tZWRpYXRlbHkgZ28gdG8gJ2Nsb3NlZCcgc3RhdGUgYW5kIHJl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cmludGsoS0VSTl9JTkZPICJ3YW5zb2NrOiBLaWxsaW5nIGluIFRpbWVyIFIgJWkgLCBXICVpXG4iLAorCQkJYXRvbWljX3JlYWQoJnNrLT5za19ybWVtX2FsbG9jKSwKKwkJCWF0b21pY19yZWFkKCZzay0+c2tfd21lbV9hbGxvYykpOworCQlzay0+c2tfdGltZXIuZGF0YQk9ICh1bnNpZ25lZCBsb25nKXNrOworCQlzay0+c2tfdGltZXIuZXhwaXJlcwk9IGppZmZpZXMgKyBIWjsKKwkJc2stPnNrX3RpbWVyLmZ1bmN0aW9uCT0gd2FucGlwZV9kZXN0cm95X3RpbWVyOworCQlhZGRfdGltZXIoJnNrLT5za190aW1lcik7CisJCXJldHVybiAwOworCX0KKworCWtmcmVlKHdwKTsKKwl3cF9zayhzaykgPSBOVUxMOworCisJaWYgKGF0b21pY19yZWFkKCZzay0+c2tfcmVmY250KSAhPSAxKSB7CisJCURCR19QUklOVEsoS0VSTl9JTkZPICJ3YW5zb2NrOiBFcnJvciwgd3JvbmcgcmVmZXJlbmNlIGNvdW50OiAlaSAhOnJlbGVhc2UuXG4iLAorCQkJCQlhdG9taWNfcmVhZCgmc2stPnNrX3JlZmNudCkpOworCQlhdG9taWNfc2V0KCZzay0+c2tfcmVmY250LCAxKTsKKwl9CisJc29ja19wdXQoc2spOworCWF0b21pY19kZWMoJndhbnBpcGVfc29ja3NfbnIpOworCXJldHVybiAwOworfQorCisvKj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogY2hlY2tfd3JpdGVfcXVldWUKKyAqCisgKiAgCUR1cmluZyBzb2NrIHNodXRkb3duLCBpZiB0aGUgc29jayBzdGF0ZSBpcyAKKyAqICAgICAgV0FOU09DS19DT05ORUNURUQgYW5kIHRoZXJlIGlzIHRyYW5zbWl0IGRhdGEgCisgKiAgICAgIHBlbmRpbmcuIFdhaXQgdW50aWwgZGF0YSBpcyByZWxlYXNlZCAKKyAqICAgICAgYmVmb3JlIHByb2NlZWRpbmcuCisgKj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ki8KKworc3RhdGljIHZvaWQgY2hlY2tfd3JpdGVfcXVldWUoc3RydWN0IHNvY2sgKnNrKQoreworCisJaWYgKHNrLT5za19zdGF0ZSAhPSBXQU5TT0NLX0NPTk5FQ1RFRCkKKwkJcmV0dXJuOworCisJaWYgKCFhdG9taWNfcmVhZCgmc2stPnNrX3dtZW1fYWxsb2MpKQorCQlyZXR1cm47CisKKwlwcmludGsoS0VSTl9JTkZPICJ3YW5zb2NrOiBNQUpPUiBFUlJPUiwgRGF0YSBsb3N0IG9uIHNvY2sgcmVsZWFzZSAhISFcbiIpOworCit9CisKKy8qPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiByZWxlYXNlX2RyaXZlcgorICoKKyAqCVRoaXMgZnVuY3Rpb24gaXMgY2FsbGVkIGR1cmluZyBzb2NrIHNodXRkb3duLCB0byAKKyAqICAgICAgcmVsZWFzZSBhbnkgcmVzb3VyY2VzIGFuZCBsaW5rcyB0aGF0IGJpbmQgdGhlIHNvY2sKKyAqICAgICAgdG8gdGhlIGRyaXZlci4gIEl0IGFsc28gY2hhbmdlcyB0aGUgc3RhdGUgb2YgdGhlCisgKiAgICAgIHNvY2sgdG8gV0FOU09DS19ESVNDT05ORUNURUQKKyAqPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0qLworCitzdGF0aWMgdm9pZCByZWxlYXNlX2RyaXZlcihzdHJ1Y3Qgc29jayAqc2spCit7CisJd2FucGlwZV9vcHQgKndwOworCXN0cnVjdCBza19idWZmICpza2I9TlVMTDsKKwlzdHJ1Y3Qgc29jayAqZGVhZHNrPU5VTEw7CisKKwlpZiAoc2stPnNrX3N0YXRlID09IFdBTlNPQ0tfTElTVEVOIHx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VkLCBzdGFydCB0aGUgdGltZXIgd2hpY2ggd2lsbCAKKyAqICAgICAgZW52b2tlIHRoZSBraWxsIHJvdXRpbmVzIGZvciBwZW5kaW5nIHNvY2tzLgorICo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PSovCisKKworc3RhdGljIHZvaWQgc3RhcnRfY2xlYW51cF90aW1lciAoc3RydWN0IHNvY2sgKnNrKQoreworCWRlbF90aW1lcigmc2stPnNrX3RpbWVyKTsKKwlzay0+c2tfdGltZXIuZGF0YQk9ICh1bnNpZ25lZCBsb25nKXNrOworCXNrLT5za190aW1lci5leHBpcmVzCT0gamlmZmllcyArIEhaOworCXNrLT5za190aW1lci5mdW5jdGlvbgk9IHdhbnBpcGVfa2lsbF9zb2NrX3RpbWVyOworCWFkZF90aW1lcigmc2stPnNrX3RpbWVyKTsKK30KKworCisvKj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogIHdhbnBpcGVfa2lsbF9zb2NrCisgKgorICoJVGhpcyBpcyBhIGZ1bmN0aW9uIHdoaWNoIHBlcmZvcm1zIGFjdHVhbCBraWxsaW5nCisgKiAgICAgIG9mIHRoZSBzb2NrLiAgSXQgcmVsZWFzZXMgc29ja2V0IHJlc291cmNlcywKKyAqICAgICAgYW5kIHVubGlua3MgdGhlIHNvY2sgZnJvbSB0aGUgZHJpdmVyLiAKKyAqPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0qLworCitzdGF0aWMgdm9pZCB3YW5waXBlX2tpbGxfc29ja190aW1lciAodW5zaWduZWQgbG9uZyBkYXRhKQoreworCisJc3RydWN0IHNvY2sgKnNrID0gKHN0cnVjdCBzb2NrICopZGF0YTsKKwlzdHJ1Y3Qgc29jayAqKnNrcDsKKworCWlmICghc2spCisJCXJldHVybjsKKworCS8qIFRoaXMgZnVuY3Rpb24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hZCgmc2stPnNrX3dtZW1fYWxsb2MpKSB7CisJCWRlbF90aW1lcigmc2stPnNrX3RpbWVyKTsKKwkJcHJpbnRrKEtFUk5fSU5GTyAid2Fuc29jazogS2lsbGluZyBTT0NLIGluIFRpbWVyXG4iKTsKKwkJc2stPnNrX3RpbWVyLmRhdGEJPSAodW5zaWduZWQgbG9uZylzazsKKwkJc2stPnNrX3RpbWVyLmV4cGlyZXMJPSBqaWZmaWVzICsgSFo7CisJCXNrLT5za190aW1lci5mdW5jdGlvbgk9IHdhbnBpcGVfZGVzdHJveV90aW1lcjsKKwkJYWRkX3RpbWVyKCZzay0+c2tfdGltZXIpOworCQlyZXR1cm47CisJfQorCisJaWYgKHdwX3NrKHNrKSkgeworCQlrZnJlZSh3cF9zayhzaykpOworCQl3cF9zayhzaykgPSBOVUxMOworCX0KKworCWlmIChhdG9taWNfcmVhZCgmc2stPnNrX3JlZmNudCkgIT0gMSkgeworCQlhdG9taWNfc2V0KCZzay0+c2tfcmVmY250LCAxKTsKKwkJREJHX1BSSU5USyhLRVJOX0lORk8gIndhbnNvY2s6IEVycm9yLCB3cm9uZyByZWZlcmVuY2UgY291bnQ6ICVpICEgOnRpbWVyLlxuIiwKKwkJCQkJYXRvbWljX3JlYWQoJnNrLT5za19yZWZjbnQpKTsKKwl9CisJc29ja19wdXQoc2spOworCWF0b21pY19kZWMoJndhbnBpcGVfc29ja3NfbnIpOworCXJldHVybjsKK30KKworc3RhdGljIHZvaWQgd2FucGlwZV9raWxsX3NvY2tfYWNjZXB0IChzdHJ1Y3Qgc29jayAqc2spCit7CisKKwlzdHJ1Y3Qgc29jayAqKnNrcDsKKworCWlmICghc2spCisJCXJldHVybjsKKworCS8qIFRoaXMgZnVuY3Rpb24gY2FuIGJlIGNhbGxlZCBmcm9tIGludGVycnVwdC4gV2UgbXVzdCB1c2UKKwkgKiBhcHByb3ByaWF0ZSBsb2NrcyAqLworCQorCXdyaXRlX2xvY2soJndhbnBpcGVfc2tsaXN0X2xvY2spOworCXNrX2RlbF9ub2RlX2luaXQoc2spOworCXdyaXRlX3VubG9jaygmd2FucGlwZV9za2xpc3RfbG9jayk7CisKKwlzay0+c2tfc29ja2V0ID0gTlVMTDsKKworCisJaWYgKHdwX3NrKHNrKSkgeworCQlrZnJlZSh3cF9zayhzaykpOworCQl3cF9zayhzaykgPSBOVUxMOworCX0KKworCWlmIChhdG9taWNfcmVhZCgmc2stPnNrX3JlZmNudCkgIT0gMSkgeworCQlhdG9taWNfc2V0KCZzay0+c2tfcmVmY250LCAxKTsKKwkJREJHX1BSSU5USyhLRVJOX0lORk8gIndhbnNvY2s6IEVycm9yLCB3cm9uZyByZWZlcmVuY2UgY291bnQ6ICVpICEgOnRpbWVyLlxuIiwKKwkJCQkJYXRvbWljX3JlYWQoJnNrLT5za19yZWZjbnQpKTsKKwl9CisJc29ja19wdXQoc2spOworCWF0b21pY19kZWMoJndhbnBpcGVfc29ja3NfbnIpOworCXJldHVybjsKK30KKworCitzdGF0aWMgdm9pZCB3YW5waXBlX2tpbGxfc29ja19pcnEgKHN0cnVjdCBzb2NrICpzaykKK3sKKworCWlmICghc2spCisJCXJldHVybjsKKworCXNrLT5za19zb2NrZXQgPSBOVUxMOworCisJaWYgKHdwX3NrKHNrKSkgeworCQlrZnJlZSh3cF9zayhzaykpOworCQl3cF9zayhzaykgPSBOVUxMOworCX0KKworCWlmIChhdG9taWNfcmVhZCgmc2stPnNrX3JlZmNudCkgIT0gMSkgeworCQlhdG9taWNfc2V0KCZzay0+c2tfcmVmY250LCAxKTsKKwkJREJHX1BSSU5USyhLRVJOX0lORk8gIndhbnNvY2s6IEVycm9yLCB3cm9uZyByZWZlcmVuY2UgY291bnQ6ICVpICE6bGlzdGVuLlxuIiwKKwkJCQkJYXRvbWljX3JlYWQoJnNrLT5za19yZWZjbnQpKTsKKwl9CisJc29ja19wdXQoc2spOworCWF0b21pY19kZWMoJndhbnBpcGVfc29ja3NfbnIpOworfQorCisKKy8qPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiAgd2FucGlwZV9kb19iaW5kCisgKgorICogCUJvdHRvbSBoYWxmIG9mIHRoZSBiaW5kaW5nIHN5c3RlbSBjYWxsLgorICogICAgICBPbmNlIHRoZSB3YW5waXBlX2JpbmQoKSBmdW5jdGlvbiBjaGVja3MgIHRoZQorICogICAgICBsZWdhbGl0eSBvZiB0aGUgY2FsbCwgdGhpcyBmdW5jdGlvbiBiaW5kcyB0aGUKKyAqICAgICAgc29jayB0byB0aGUgZHJpdmVyLgorICo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PSovCisKK3N0YXRpYyBpbnQgd2FucGlwZV9kb19iaW5kKHN0cnVjdCBzb2NrICpzaywgc3RydWN0IG5ldF9kZXZpY2UgKmRldiwKKwkJCSAgIGludCBwcm90b2NvbCkKK3sKKwl3YW5waXBlX29wdCAqd3AgPSB3cF9zayhzayk7CisJd2FucGlwZV9jb21tb25fdCAqY2hhbj1OVUxMOworCWludCBlcnI9MDsKKworCWlmIChzb2NrX2ZsYWcoc2ssIFNPQ0tfWkFQUEVEKSkgeworCQllcnIgPSAtRUFMUkVBRFk7CisJCWdvdG8gYmluZF91bmxvY2tfZXhpdDsKKwl9CisKKwl3cC0+bnVtID0gcHJvdG9jb2w7CisKKwlpZiAocHJvdG9jb2wgPT0gMCl7CisJCXJlbGVhc2VfZGV2aWNlKGRldik7CisJCWVyciA9IC1FSU5WQUw7CisJCWdvdG8gYmluZF91bmxvY2tfZXhpdDsKKwl9CisKKwlpZiAoZGV2KSB7CisJCWlmIChkZXYtPmZsYWdzJklGRl9VUCkgeworCQkJY2hhbj1kZXYtPnByaXY7CisJCQlzay0+c2tfc3RhdGUgPSBjaGFuLT5zdGF0ZTsKKworCQkJaWYgKHdwLT5udW0gPT0gaHRvbnMoWDI1X1BST1QpICYmIAorCQkJICAgIHNrLT5za19zdGF0ZSAhPSBXQU5TT0NLX0RJU0NPTk5FQ1RFRCAmJiAKKwkJCSAgICBzay0+c2tfc3RhdGUgIT0gV0FOU09DS19DT05ORUNUSU5HKSB7CisJCQkJREJHX1BSSU5USyhLRVJOX0lORk8gCisJCQkJCSJ3YW5zb2NrOiBCaW5kaW5nIHRvIERldmljZSBub3QgRElTQ09OTkVDVEVEICVpXG4iLAorCQkJCQkJc2stPnNrX3N0YXRlKTsKKwkJCQlyZWxlYXNlX2RldmljZShkZXYpOworCQkJCWVyciA9IC1FQUdBSU47CisJCQkJZ290byBiaW5kX3VubG9ja19leGl0OworCQkJfQorCisJCQl3YW5waXBlX2xpbmtfZHJpdmVyKGRldixzayk7CisJCQlzay0+c2tfYm91bmRfZGV2X2lmID0gZGV2LT5pZmluZGV4OworCisJCQkvKiBYMjUgU3BlY2lmaWMgb3B0aW9uICovCisJCQlpZiAod3AtPm51bSA9PSBodG9ucyhYMjVfUFJPVCkpCisJCQkJd3Bfc2soc2spLT5zdmMgPSBjaGFuLT5zdmM7CisKKwkJfSBlbHNlIHsKKwkJCXNrLT5za19lcnIgPSBFTkVURE9XTjsKKwkJCXNrLT5za19lcnJvcl9yZXBvcnQoc2spOworCQkJcmVsZWFzZV9kZXZpY2UoZGV2KTsKKwkJCWVyciA9IC1FSU5WQUw7CisJCX0KKwl9IGVsc2UgeworCQllcnIgPSAtRU5PREVWOworCX0KK2JpbmRfdW5sb2NrX2V4aXQ6CisJLyogRklYTUUgd2hlcmUgaXMgdGhpcyBsb2NrICovCisKKwlyZXR1cm4gZXJyOworfQorCisvKj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogIHdhbnBpcGVfYmluZAorICoKKyAqICAgICAgQklORCgpIFN5c3RlbSBjYWxsLCB3aGljaCBpcyBib3VuZCB0byB0aGUgQUZfV0FOUElQRQorICogICAgICBvcGVyYXRpb25zIHN0cnVjdHVyZS4gIEl0IGNoZWNrcyBmb3IgY29ycmV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CisKKwlyZXR1cm4gd2FucGlwZV9kb19iaW5kKHNrLCBkZXYsIHNsbC0+c2xsX3Byb3RvY29sID8gOiB3cC0+bnVtKTsKK30KKworLyo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIGdldF9hdG9taWNfZGV2aWNlCisgKgkKKyAqCVNldHMgYSBiaXQgYXRvbWljYWxseSB3aGljaCBpbmRpY2F0ZXMgdGhhdCAKKyAqICAgICAgdGhlIGludGVyZmFjZSBpcyB0YWtlbi4gVGhpcyBhdm9pZHMgcmFjZSBjb25kaXRpb25zLgorICo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PSovCisKKworc3RhdGljIGlubGluZSBpbnQgZ2V0X2F0b21pY19kZXZpY2Uoc3RydWN0IG5ldF9kZXZpY2UgKmRldikKK3sKKwl3YW5waXBlX2NvbW1vbl90ICpjaGFuID0gZGV2LT5wcml2OworCWlmICghdGVzdF9hbmRfc2V0X2JpdCgwLCh2b2lkICopJmNoYW4tPnJ3X2JpbmQpKXsKKwkJcmV0dXJuIDA7CisJfQorCXJldHVybiAxOworfQorCisvKj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogY2hlY2tfZGV2CisgKgkKKyAqICAJQ2hlY2sgdGhhdCBkZXZpY2UgbmFtZSBiZWxvbmdzIHRvIGEgcGFydGljdWxhciBjYXJkLgorICo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PSovCisKK3N0YXRpYyBpbnQgY2hlY2tfZGV2KHN0cnVjdCBuZXRfZGV2aWNlICpkZXYsIHNkbGFfdCAqY2FyZCkKK3sKKwlzdHJ1Y3QgbmV0X2RldmljZSogdG1wX2RldjsKKworCWZvciAodG1wX2RldiA9IGNhcmQtPndhbmRldi5kZXY7IHRtcF9kZXY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NvY2stPnN0YXRlID0gU1NfVU5DT05ORUNURUQ7CisKKwlpZiAoKHNrID0gd2FucGlwZV9hbGxvY19zb2NrZXQoKSkgPT0gTlVMTCkKKwkJcmV0dXJuIC1FTk9CVUZTOworCisJc2stPnNrX3JldXNlID0gMTsKKwlzb2NrLT5vcHMgPSAmd2FucGlwZV9vcHM7CisJc29ja19pbml0X2RhdGEoc29jayxzayk7CisKKwlzb2NrX3Jlc2V0X2ZsYWcoc2ssIFNPQ0tfWkFQUEVEKTsKKwlzay0+c2tfZmFtaWx5CSAgICA9IFBGX1dBTlBJUEU7CisJd3Bfc2soc2spLT5udW0JICAgID0gcHJvdG9jb2w7CisJc2stPnNrX3N0YXRlCSAgICA9IFdBTlNPQ0tfRElTQ09OTkVDVEVEOworCXNrLT5za19hY2tfYmFja2xvZyAgPSAwOworCXNrLT5za19ib3VuZF9kZXZfaWYgPSAwOworCisJYXRvbWljX2luYygmd2FucGlwZV9zb2Nrc19ucik7CisJCisJLyogV2UgbXVzdCBkaXNhYmxlIGludGVycnVwdHMgYmVjYXVzZSB0aGUgSVNSCisJICogY2FuIGFsc28gY2hhbmdlIHRoZSBsaXN0ICovCisJc2V0X2JpdCgxLCZ3YW5waXBlX3R4X2NyaXRpY2FsKTsKKwl3cml0ZV9sb2NrKCZ3YW5waXBlX3NrbGlzdF9sb2NrKTsKKwlza19hZGRfbm9kZShzaywgJndhbnBpcGVfc2tsaXN0KTsKKwl3cml0ZV91bmxvY2soJndhbnBpcGVfc2tsaXN0X2xvY2spOworCWNsZWFyX2JpdCgxLCZ3YW5waXBlX3R4X2NyaXRpY2FsKTsKKworCXJldHVybigwKTsKK30KKworCisvKj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogIHdhbnBpcGVfcmVjdm1zZworICoJCisgKglQdWxsIGEgcGFja2V0IGZyb20gb3VyIHJlY2VpdmUgcXVldWUgYW5kIGhhbmQgaXQgCisgKiAgICAgI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LWVudHJhbmN5IGlzc3VlcyBmcm9tIHVzLgorCSAqLworCWVyciA9IChmbGFncyZNU0dfVFJVTkMpID8gc2tiLT5sZW4gOiBjb3BpZWQ7CisKK291dF9mcmVlOgorCXNrYl9mcmVlX2RhdGFncmFtKHNrLCBza2IpOworb3V0OgorCXJldHVybiBlcnI7Cit9CisKKworLyo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqICB3YW5waXBlX3dha2V1cF9kcml2ZXIKKyAqCQorICogCUlmIHNvY2tldCByZWNlaXZlIGJ1ZmZlciBpcyBmdWxsIGFuZCBkcml2ZXIgY2Fubm90CisgKiAgICAgIHBhc3MgZGF0YSB1cCB0aGUgc29jaywgaXQgc2V0cyBhIHBhY2tldF9ibG9jayBmbGFnLgorICogICAgICBUaGlzIGZ1bmN0aW9uIGNoZWNrIHRoYXQgZmxhZyBhbmQgaWYgc29jayByZWNlaXZlIAorICogICAgICBxdWV1ZSBoYXMgcm9vbSBpdCBraWNrcyB0aGUgZHJpdmVyIEJIIGhhbmRsZXIuIAorICoKKyAqIAlUaGlzIHdheSwgZHJpdmVyIGRvZXNuJ3QgaGF2ZSB0byBwb2xsIHRoZSBzb2NrIAorICogICAgICByZWNlaXZlIHF1ZXVlLgorICo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PSovCisKK3N0YXRpYyB2b2lkIHdhbnBpcGVfd2FrZXVwX2RyaXZlcihzdHJ1Y3Qgc29jayAqc2spCit7CisJc3RydWN0IG5ldF9kZXZpY2UgKmRldiA9IE5VTEw7CisJd2FucGlwZV9jb21tb25fdCAqY2hhbj1OVUxMOworCisJZGV2ID0gZGV2X2dldF9ieV9pbmRleChzay0+c2tfYm91bmRfZGV2X2lmKTsKKwlpZiAoIWRldikKKwkJcmV0dXJuOworCisJZGV2X3B1dChkZXYpOworCisJaWYgKChjaGFuID0gZGV2LT5wcml2KSA9PSBOVUxMKQorCQlyZXR1cm47CisJCisJaWYgKGF0b21pY19yZWFkKCZjaGFuLT5yZWNlaXZlX2Jsb2NrKSl7ICAKKwkJaWYgKGF0b21pY19yZWFkKCZzay0+c2tfcm1lbV9hbGxvYykgPAorCQkgICAgKCh1bnNpZ25lZClzay0+c2tfcmN2YnVmICogMC45KSkgeworCQkJcHJpbnRrKEtFUk5fSU5GTyAid2Fuc29jazogUXVldWluZyB0YXNrIGZvciB3YW5waXBlXG4iKTsKKwkJCWF0b21pY19zZXQoJmNoYW4tPnJlY2VpdmVfYmxvY2ssMCk7CisJCQl3YW5waXBlX3F1ZXVlX3RxKCZjaGFuLT53YW5waXBlX3Rhc2spOworCQkJd2FucGlwZV9tYXJrX2JoKCk7CisJCX0KKwl9CQorfQkKKworLyo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqICB3YW5waXBlX2dldG5hbWUKKyAqCQorICogCUkgZG9uJ3Qga25vdyB3aGF0IHRvIGRvIHdpdGggdGhpcyB5ZXQuIAorICogICAgICBVc2VyIGNhbiB1c2UgdGhpcyBmdW5jdGlvbiB0byBnZXQgc29jayBhZGRyZXNzCisgKiAgICAgIGluZm9ybWF0aW9uLiBOb3QgdmVyeSB1c2VmdWwgZm9yIFNhbmdvbWEncyBwdXJwb3Nlcy4KKyAqPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0qLworCisKK3N0YXRpYyBpbnQgd2FucGlwZV9nZXRuYW1lKHN0cnVjdCBzb2NrZXQgKnNvY2ssIHN0cnVjdCBzb2NrYWRkciAqdWFkZHIsCisJCQkgIGludCAqdWFkZHJfbGVuLCBpbnQgcGVlcikKK3sKKwlzdHJ1Y3QgbmV0X2RldmljZSAqZGV2OworCXN0cnVjdCBzb2NrICpzayA9IHNvY2stPnNrOworCXN0cnVjdCB3YW5fc29ja2FkZHJfbGwgKnNsbC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AqCisgKj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ki8KKworc3RhdGljIGludCB3YW5waXBlX25vdGlmaWVyKHN0cnVjdCBub3RpZmllcl9ibG9jayAqdGhpcywgdW5zaWduZWQgbG9uZyBtc2csIHZvaWQgKmRhdGEpCit7CisJc3RydWN0IHNvY2sgKnNrOworCWhsaXN0X25vZGUgKm5vZGU7CisJc3RydWN0IG5ldF9kZXZpY2UgKmRldiA9IChzdHJ1Y3QgbmV0X2RldmljZSAqKWRhdGE7CisKKwlza19mb3JfZWFjaChzaywgbm9kZSwgJndhbnBpcGVfc2tsaXN0KSB7CisJCXN0cnVjdCB3YW5waXBlX29wdCAqcG8gPSB3cF9zayhzayk7CisKKwkJaWYgKCFwbykKKwkJCWNvbnRpbnVlOworCQlpZiAoZGV2ID09IE5VTEwpCisJCQljb250aW51ZTsKKwkJCisJCXN3aXRjaCAobXNnKSB7CisJCWNhc2UgTkVUREVWX0RPV046CisJCWNhc2UgTkVUREVWX1VOUkVHSVNURVI6CisJCQlpZiAoZGV2LT5pZmluZGV4ID09IHNrLT5za19ib3VuZF9kZXZfaWYpIHsKKwkJCQlwcmludGsoS0VSTl9JTkZPICJ3YW5zb2NrOiBEZXZpY2UgZG93biAlc1xuIixkZXYtPm5hbWUpOworCQkJCWlmIChzb2NrX2ZsYWcoc2ssIFNPQ0tfWkFQUEVEKSkgeworCQkJCQl3YW5waXBlX3VubGlua19kcml2ZXIoc2spOworCQkJCQlzay0+c2tfZXJyID0gRU5FVERPV047CisJCQkJCXNrLT5za19lcnJvcl9yZXBvcnQoc2spOworCQkJCX0KKworCQkJCWlmIChtc2cgPT0gTkVUREVWX1VOUkVHSVNURVIpIHsKKwkJCQkJcHJpbnRrKEtFUk5fSU5GTyAid2Fuc29jazogVW5yZWdpc3RlcmluZyBEZXZpY2U6ICVzXG4iLAorCQkJCQkJIAkgIGRldi0+bmFtZSk7CisJCQkJCXdhbnBpcGVfdW5saW5rX2RyaXZlcihzayk7CisJCQkJCXNrLT5za19ib3VuZF9kZXZfaWYgPSAwOworCQkJCX0KKwkJCX0KKwkJCWJyZWFrOworCQljYXNlIE5FVERFVl9VUDoKKwkJCWlmIChkZXYtPmlmaW5kZXggPT0gc2stPnNrX2JvdW5kX2Rldl9pZiAmJgorCQkJICAgIHBvLT5udW0gJiYgIXNvY2tfZmxhZyhzaywgU09DS19aQVBQRUQpKSB7CisJCQkJcHJpbnRrKEtFUk5fSU5GTyAid2Fuc29jazogUmVnaXN0ZXJpbmcgRGV2aWNlOiAlc1xuIiwKKwkJCQkJCWRldi0+bmFtZSk7CisJCQkJd2FucGlwZV9saW5rX2RyaXZlcihkZXYsc2spOworCQkJfQorCQkJYnJlYWs7CisJCX0KKwl9CisJcmV0dXJuIE5PVElGWV9ET05FOworfQorCisvKj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogIHdhbnBpcGVfaW9jdGwKKyAqCQorICogCUV4ZWN1dGUgYSB1c2VyIGNvbW1hbmRzLCBhbmQgc2V0IHNvY2tldCBvcHRpb25zLgorICoKKyAqIEZJWE1FOiBNb3JlIHRob3VnaHQgc2hvdWxkIGdvIGludG8gdGhpcyBmdW5jdGlvbi4KKyAqCisgKj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ki8KKworc3RhdGljIGludCB3YW5waXBlX2lvY3RsKHN0cnVjdCBzb2NrZXQgKnNvY2ssIHVuc2lnbmVkIGludCBjbWQsIHVuc2lnbmVkIGxvbmcgYXJnKQoreworCXN0cnVjdCBzb2NrICpzayA9IHNvY2stPnNrOworCWludCBlcnI7CisKKwlzd2l0Y2goY21kKSAKKwl7CisJCWNhc2UgU0lPQ0dTVEFNUDoKKwkJCXJldHVybiBzb2NrX2dldF90aW1lc3RhbXAoc2ssIChzdHJ1Y3QgdGltZXZhbCBfX3VzZXIgKil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GFncyB8PSBPX05PTkJMT0NLOworCQkJcmV0dXJuIDA7CisJCisjaWZkZWYgQ09ORklHX0lORVQKKwkJY2FzZSBTSU9DQUREUlQ6CisJCWNhc2UgU0lPQ0RFTFJUOgorCQljYXNlIFNJT0NEQVJQOgorCQljYXNlIFNJT0NHQVJQOgorCQljYXNlIFNJT0NTQVJQOgorCQljYXNlIFNJT0NEUkFSUDoKKwkJY2FzZSBTSU9DR1JBUlA6CisJCWNhc2UgU0lPQ1NSQVJQOgorCQljYXNlIFNJT0NHSUZBRERSOgorCQljYXNlIFNJT0NTSUZBRERSOgorCQljYXNlIFNJT0NHSUZCUkRBRERSOgorCQljYXNlIFNJT0NTSUZCUkRBRERSOgorCQljYXNlIFNJT0NHSUZORVRNQVNLOgorCQljYXNlIFNJT0NTSUZORVRNQVNLOgorCQljYXNlIFNJT0NHSUZEU1RBRERSOgorCQljYXNlIFNJT0NTSUZEU1RBRERSOgorCQljYXNlIFNJT0NTSUZGTEFHUzoKKwkJCXJldHVybiBpbmV0X2RncmFtX29wcy5pb2N0bChzb2NrLCBjbWQsIGFyZyk7CisjZW5kaWYKKworCQlkZWZhdWx0OgorCQkJcmV0dXJuIGRldl9pb2N0bChjbWQsKHZvaWQgX191c2VyICopIGFyZyk7CisJfQorCS8qTk9UUkVBQ0hFRCovCit9CisKKy8qPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiAgd2FucGlwZV9kZWJ1ZworICoJCisgKglUaGlzIGZ1bmN0aW9uIHdpbGwgcGFzcyB1cCBpbmZvcm1hdGlvbiBhYm91dCBhbGwKKyAqICAgICAgYWN0aXZlIHNvY2tldHMuCisgKgorICogRklYTUU6IE1vcmUgdGhvdWdodCBzaG91bGQgZ28gaW50byB0aGlzIGZ1bmN0aW9uLgorICoKKyAqPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0qLworCitzdGF0aW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ItPmNtZC5sZW5ndGggPiAwKXsKKwkJaWYgKG1ib3hfcHRyLT5jbWQubGVuZ3RoID4gWDI1X01BWF9EQVRBKQorCQkJcmV0dXJuIC1FSU5WQUw7CisKKwkJaWYgKGNvcHlfdG9fdXNlcih1c3JfZGF0YS0+ZGF0YSwgbWJveF9wdHItPmRhdGEsIG1ib3hfcHRyLT5jbWQubGVuZ3RoKSl7CisJCQlwcmludGsoS0VSTl9JTkZPICJ3YW5zb2NrOiBDb3B5IGZhaWxlZCAhISFcbiIpOworCQkJcmV0dXJuIC1FRkFVTFQ7CisJCX0KKwl9CisJcmV0dXJuIDA7Cit9IAorCisvKj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogIHNldF9pb2N0bF9jbWQKKyAqCQorICoJQmVmb3JlIGNvbW1hbmQgY2FuIGJlIGV4ZWN1dGUsIHNvY2tldCBNQk9YIG11c3QKKyAqICAgICAgYmUgY3JlYXRlZCwgYW5kIGluaXRpYWxpemVkIHdpdGggdXNlciBkYXRhLgkKKyAqPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0qLworCitzdGF0aWMgaW50IHNldF9pb2N0bF9jbWQgKHN0cnVjdCBzb2NrICpzaywgdm9pZCAqYXJnKQoreworCXgyNWFwaV90ICp1c3JfZGF0YSA9ICh4MjVhcGlfdCAqKWFyZzsKKwltYm94X2NtZF90ICptYm94X3B0cjsKKwlpbnQgZXJyOworCisJaWYgKCF3cF9zayhzayktPm1ib3gpIHsKKwkJdm9pZCAqbWJveF9wdHI7CisJCXN0cnVjdCBuZXRfZGV2aWNlICpkZXYgPSBkZXZfZ2V0X2J5X2luZGV4KHNrLT5za19ib3VuZF9kZXZfaWYpOworCQlpZiAoIWRldikKKwkJCXJldHVybiAtRU5PREVWOworCisJCWRldl9wdXQoZGV2KTsKKwkJCisJCWlmICgobWJveF9wdHIgPSBrbWFsbG9jK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94X3B0ci0+ZGF0YSwgdXNyX2RhdGEtPmRhdGEsIG1ib3hfcHRyLT5jbWQubGVuZ3RoKSl7CisJCQlwcmludGsoS0VSTl9JTkZPICJDb3B5IGZhaWxlZFxuIik7CisJCQlyZXR1cm4gLUVGQVVMVDsKKwkJfQorCX0KKwlyZXR1cm4gMDsKK30KKworCisvKj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIHdhbnBpcGVfcG9sbAorICoKKyAqCURhdGFncmFtIHBvbGw6IEFnYWluIHRvdGFsbHkgZ2VuZXJpYy4gVGhpcyBhbHNvIGhhbmRsZXMKKyAqCXNlcXVlbmNlZCBwYWNrZXQgc29ja2V0cyBwcm92aWRpbmcgdGhlIHNvY2tldCByZWNlaXZlIHF1ZXVlCisgKglpcyBvbmx5IGV2ZXIgaG9sZGluZyBkYXRhIHJlYWR5IHRvIHJlY2VpdmUuCisgKgorICoJTm90ZTogd2hlbiB5b3UgX2Rvbid0XyB1c2UgdGhpcyByb3V0aW5lIGZvciB0aGlzIHByb3RvY29sLAorICoJYW5kIHlvdSB1c2UgYSBkaWZmZXJlbnQgd3JpdGUgcG9saWN5IGZyb20gc29ja193cml0ZWFibGUoKQorICoJdGhlbiBwbGVhc2Ugc3VwcGx5IHlvdXIgb3duIHdyaXRlX3NwYWNlIGNhbGxiYWNrLgorICo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0qLworCit1bnNpZ25lZCBpbnQgd2FucGlwZV9wb2xsKHN0cnVjdCBmaWxlICogZmlsZSwgc3RydWN0IHNvY2tldCAqc29jaywgcG9sbF90YWJsZSAqd2FpdCkKK3sKKwlzdHJ1Y3Qgc29jayAqc2sgPSBzb2NrLT5zazsKKwl1bnNpZ25lZCBpbnQgbWFzazsKKworCSsrd3Bfc2soc2spLT5wb2xsX2NudDsKKworCXBvbGxfd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ICAqIHRyYW5zbWl0IHF1ZXVlICovCisKKwlpZiAod3Bfc2soc2spLT5udW0gPT0gaHRvbnMoWDI1X1BST1QpKSB7CisJCWlmIChhdG9taWNfcmVhZCgmd3Bfc2soc2spLT5wYWNrZXRfc2VudCkpCisJCQlyZXR1cm4gbWFzazsKKwl9CisKKwkvKiB3cml0YWJsZT8gKi8KKwlpZiAoc29ja193cml0ZWFibGUoc2spKXsKKwkJbWFzayB8PSBQT0xMT1VUIHwgUE9MTFdSTk9STSB8IFBPTExXUkJBTkQ7CisJfWVsc2V7CisJCXNldF9iaXQoU09DS19BU1lOQ19OT1NQQUNFLCAmc2stPnNrX3NvY2tldC0+ZmxhZ3MpOworCX0KKwkJCisJcmV0dXJuIG1hc2s7Cit9CisKKy8qPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogd2FucGlwZV9saXN0ZW4KKyAqCisgKglYMjVBUEkgU3BlY2lmaWMgZnVuY3Rpb24uIFNldCBhIHNvY2tldCBpbnRvIExJU1RFTklORyAgTU9ERS4KKyAqPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ki8KKworCitzdGF0aWMgaW50IHdhbnBpcGVfbGlzdGVuKHN0cnVjdCBzb2NrZXQgKnNvY2ssIGludCBiYWNrbG9nKQoreworCXN0cnVjdCBzb2NrICpzayA9IHNvY2stPnNrOworCisgCS8qIFRoaXMgaXMgeDI1IHNwZWNpZmljIGFyZWEgaWYgcHJvdG9jb2wgZG9lc24ndAorICAgICAgICAgKiBtYXRjaCwgcmV0dXJuIGVycm9yICovCisJaWYgKHdwX3NrKHNrKS0+bnVtICE9IGh0b25zKFgyNV9QUk9UKSkKKwkJcmV0dXJuIC1FSU5WQUw7CisKKwlpZiAoc2stPnNrX3N0YXRlID09IFdBTlNPQ0tfQklORF9MSVNURU4pIHsKKworCQlzay0+c2tfbWF4X2Fja19iYWNrbG9nID0gYmFja2xvZzsKKwkJc2stPnNrX3N0YXRlICAgICAgICAgICA9IFdBTlNPQ0tfTElTVEVOOworCQlyZXR1cm4gMDsKKwl9ZWxzZXsKKwkJcHJpbnRrKEtFUk5fSU5GTyAid2Fuc29jazogTGlzdGVuaW5nIHNvY2sgd2FzIG5vdCBiaW5kZWRcbiIpOworCX0KKworCXJldHVybiAtRUlOVkFMOworfQorCisvKj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIHdhbnBpcGVfbGlua19jYXJkCisgKgorICoJQ29ubmVjdHMgdGhlIGxpc3RlbmluZyBzb2NrZXQgdG8gdGhlIGRyaXZlcgorICo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0qLworCitzdGF0aWMgaW50IHdhbnBpcGVfbGlua19jYXJkIChzdHJ1Y3Qgc29jayAqc2spCit7CisJc2RsYV90ICpjYXJkID0gKHNkbGFfdCopd3Bfc2soc2spLT5jYXJkOworCisJaWYgKCFjYXJkKQorCQlyZXR1cm4gLUVOT01FTTsKKworCWlmICgoY2FyZC0+c2sgIT0gTlVMTCkgfHwgKGNhcmQtPmZ1bmMgIT0gTlVMTCkpeworCQlwcmludGsoS0VSTl9JTkZPICJ3YW5zb2NrOiBMaXN0ZW5pbmcgcXVldWUgaXMgYWxyZWFkeSBlc3RhYmxpc2hlZFxuIik7CisJCXJldHVybiAtRUlOVkFMOworCX0KKworCWNhcmQtPnNrPXNrOworCWNhcmQtPmZ1bmM9d2FucGlwZV9saXN0ZW5fcmN2OworCXNvY2tfc2V0X2ZsYWcoc2ssIFNPQ0tfWkFQUEVEKTsKKyAKKwlyZXR1cm4gMDsKK30KKworLyo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiB3YW5waXBlX2xpc3RlbgorICoKKyAqCVgyNUFQSSBTcGVjaWZpYyBmdW5jdGlvbi4gRGlzY29ubmVjdCBsaXN0ZW5pbmcgc29ja2V0IGZyb20KKyAqICAgICAgdGhlIGRyaXZlci4KKyAqPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ki8KKworc3RhdGljIHZvaWQgd2FucGlwZV91bmxpbmtfY2FyZCAoc3RydWN0IHNvY2sgKnNrKQoreworCXNkbGFfdCAqY2FyZCA9IChzZGxhX3QqKXdwX3NrKHNrKS0+Y2FyZDsgCisKKwlpZiAoY2FyZCl7CisJCWNhcmQtPnNrPU5VTEw7CisJCWNhcmQtPmZ1bmM9TlVMTDsKKwl9Cit9CisKKy8qPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogd2FucGlwZV9leGVjX2NtZAorICoKKyAqCUlvY3RsIGZ1bmN0aW9uIGNhbGxzIHRoaXMgZnVuY3Rpb24gdG8gZXhlY3V0ZSB1c2VyIGNvbW1hbmQuCisgKiAgICAgIENvbm5lY3QoKSBzeXRlbSBjYWxsIGFsc28gY2FsbHMgdGhpcyBmdW5jdGlvbiB0byBleGVjdXRlCisgKiAgICAgIHBsYWNlIGNhbGwuICBUaGlzIGZ1bmN0aW9uIGJsb2NrcyB1bnRpbCBjb21tYW5kIGlzIGV4ZWN1dGVkLgorICo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0qLworCitzdGF0aWMgaW50IHdhbnBpcGVfZXhlY19jbWQoc3RydWN0IHNvY2sgKnNrLCBpbnQgY21kLCB1bnNpZ25lZCBpbnQgZmxhZ3MpCit7CisJaW50IGVyciA9IC1FSU5WQUw7CisJd2FucGlwZV9vcHQgKndwID0gd3Bfc2soc2spOworCW1ib3hfY21kX3QgKm1ib3hfcHRyID0gKG1ib3hfY21kX3QqKXdwLT5tYm94OworCisJaWYgKCFtYm94X3B0cil7CisJCXByaW50ayhLRVJOX0lORk8gIk5PIE1CT1ggUFRSICEhISEhXG4iKTsKKwkJcmV0dXJuIC1FSU5WQUw7CisJfQorCQorCS8qIFRoaXMgaXMgeDI1IHNwZWNpZmljIGFyZWEgaWYgcHJvdG9jb2wgZG9lc24ndAorICAgICAgICAgKiBtYXRjaCwgcmV0dXJuIGVycm9yICovCisJaWYgKHdwLT5udW0gIT0gaHRvbnMoWDI1X1BST1QpKQorCQlyZXR1cm4gLUVJTlZBTDsKKworCisJc3dpdGNoIChjbWQpeworCisJCWNhc2UgU0lPQ19XQU5QSVBFX0FDQ0VQVF9DQUxMOgorCisJCQlpZiAoc2stPnNrX3N0YXRlICE9IFdBTlNPQ0tfQ09OTkVDVElORykgeworCQkJCWVyciA9IC1FSE9TVERPV047CisJCQkJYnJlYWs7CisJCQl9CisJCQkKKwkJCWVyciA9IGV4ZWN1dGVfY29tbWFuZChzayxYMjVfQUNDRVBUX0NBTEwsMCk7CisJCQlpZiAoZXJyIDwgMCkKKwkJCQlicmVhazsKKworCQkJLyogVXBkYXRlLiBNYXI2IDIwMDAuIAorICAgICAgICAgICAgICAgICAgICAgICAgICogRG8gbm90IHNldCB0aGUgc29jayBsY24gbnVtYmVyIGhlcmUsIHNpbmNlCisgICAgICAgICAgICAgICAgICAgICAgICAgKiBpdCBpcyBkb25lIGluIHdhbnBpcGVfbGlzdGVuX3JjdigpLiAKKyAgICAgICAgICAgICAgICAgICAgICAgICAqLyAKKwkJIAlpZiAoc2stPnNrX3N0YXRlID09IFdBTlNPQ0tfQ09OTkVDVEVEKSB7CisJCQkJd3AtPmxjbiA9ICgobWJveF9jbWRfdCopd3AtPm1ib3gpLT5jbWQubGNuOwkKKwkJCQlEQkdfUFJJTlRLKEtFUk5fSU5GTyAiXG53YW5zb2NrOiBBY2NlcHQgT0sgJWlcbiIsCisJCQkJCXdwLT5sY24pOworCQkJCWVyciA9IDA7CisKKwkJCX1lbHNleworCQkJCURCR19QUklOVEsgKEtFUk5fSU5GTyAiXG53YW5zb2NrOiBBY2NlcHQgRmFpbGVkICVpXG4iLAorCQkJCQl3cC0+bGNuKTsKKwkJCQl3cC0+bGNuID0gMDsKKwkJCQllcnIgPSAtRUNPTk5SRUZVU0VEOworCQkJfQorCQkJYnJlYWs7CisKKwkJY2FzZSBTSU9DX1dBTlBJUEVfQ0xFQVJfQ0FMTDoKKworCQkJaWYgKHNrLT5za19zdGF0ZSA9PSBXQU5TT0NLX0RJU0NPTk5FQ1RFRCkgeworCQkJCWVyciA9IC1FSU5WQUw7CisJCQkJYnJlYWs7CisJCQl9CisKKworCQkJLyogQ2hlY2sgaWYgZGF0YSBidWZmZXJzIGFyZSBwZW5kaW5nIGZvciB0cmFuc21pc3Npb24sCisgICAgICAgICAgICAgICAgICAgICAgICAgKiBpZiBzbywgY2hlY2sgd2hldGhlciB1c2VyIHdhbnRzIHRvIHdhaXQgdW50aWwgZGF0YQorICAgICAgICAgICAgICAgICAgICAgICAgICogaXMgdHJhbnNtaXR0ZWQsIG9yIGNsZWFyIGEgY2FsbCBhbmQgZHJvcCBwYWNrZXRzICovCisgICAgICAgICAgICAgICAgICAgICAgICAgIAorCQkJaWYgKGF0b21pY19yZWFkKCZzay0+c2tfd21lbV9hbGxvYykgfHwKKwkJCSAgICBjaGVja19kcml2ZXJfYnVzeShzaykpIHsKKwkJCSAgCW1ib3hfY21kX3QgKm1ib3ggPSB3cC0+bWJveDsKKwkJCQlpZiAobWJveC0+Y21kLnFkbSAmIDB4ODApeworCQkJCQltYm94LT5jbWQucmVzdWx0ID0gMHgzNTsKKwkJCQkJZXJyID0gLUVBR0FJTjsJCisJCQkJCWJyZWFrOworCQkJCX0KKwkJCX0KKworCQkJc2stPnNrX3N0YXRlID0gV0FOU09DS19ESVNDT05ORUNUSU5HOworCisJCQllcnIgPSBleGVjdXRlX2NvbW1hbmQoc2ssWDI1X0NMRUFSX0NBTEwsMCk7CisJCQlpZiAoZXJyIDwgMCkKKwkJCQlicmVhazsKKworCQkJZXJyID0gLUVDT05OUkVGVVNFRDsKKwkJCWlmIChzay0+c2tfc3RhdGUgPT0gV0FOU09DS19ESVNDT05ORUNURUQpIHsKKwkJCQlEQkdfUFJJTlRLKEtFUk5fSU5GTyAiXG53YW5zb2NrOiBDTEVBUiBPSyAlaVxuIiwKKwkJCQkJICAgd3AtPmxjbik7CisJCQkJd3AtPmxjbiA9IDA7CisJCQkJZXJyID0gMDsKKwkJCX0KKwkJCWJyZWFrOworCisJCWNhc2UgU0lPQ19XQU5QSVBFX1JFU0VUX0NBTEw6CisKKwkJCWlmIChzay0+c2tfc3RhdGUgIT0gV0FOU09DS19DT05ORUNURUQpIHsKKwkJCQllcnIgPSAtRUlOVkFMOworCQkJCWJyZWFrOworCQkJfQorCisKKwkJCS8qIENoZWNrIGlmIGRhdGEgYnVmZmVycyBhcmUgcGVuZGluZyBmb3IgdHJhbnNtaXNzaW9uLAorICAgICAgICAgICAgICAgICAgICAgICAgICogaWYgc28sIGNoZWNrIHdoZXRoZXIgdXNlciB3YW50cyB0byB3YWl0IHVudGlsIGRhdGEKKyAgICAgICAgICAgICAgICAgICAgICAgICAqIGlzIHRyYW5zbWl0dGVkLCBvciByZXNldCBhIGNhbGwgYW5kIGRyb3AgcGFja2V0cyAqLworICAgICAgICAgICAgICAgICAgICAgICAgICAKKwkJCWlmIChhdG9taWNfcmVhZCgmc2stPnNrX3dtZW1fYWxsb2MpIHx8CisJCQkgICAgY2hlY2tfZHJpdmVyX2J1c3koc2spKSB7CisJCQkgIAltYm94X2NtZF90ICptYm94ID0gd3AtPm1ib3g7CisJCQkJaWYgKG1ib3gtPmNtZC5xZG0gJiAweDgwKXsKKwkJCQkJbWJveC0+Y21kLnJlc3VsdCA9IDB4MzU7CisJCQkJCWVyciA9IC1FQUdBSU47CQorCQkJCQlicmVhazsKKwkJCQl9CisJCQl9CisKKworCQkJ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K3N0YXRpYyBpbnQgY2hlY2tfZHJpdmVyX2J1c3kgKHN0cnVjdCBzb2NrICpzaykKK3sKKwlzdHJ1Y3QgbmV0X2RldmljZSAqZGV2ID0gZGV2X2dldF9ieV9pbmRleChzay0+c2tfYm91bmRfZGV2X2lmKTsKKwl3YW5waXBlX2NvbW1vbl90ICpjaGFuOworCisJaWYgKCFkZXYpCisJCXJldHVybiAwOworCisJZGV2X3B1dChkZXYpOworCisJaWYgKChjaGFuPWRldi0+cHJpdikgPT0gTlVMTCkKKwkJcmV0dXJuIDA7CisKKwlyZXR1cm4gYXRvbWljX3JlYWQoJmNoYW4tPmRyaXZlcl9idXN5KTsKK30KKworCisvKj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqIHdhbnBpcGVfYWNjZXB0CisgKgorICoJQUNDRVBUKCkgU3lzdGVtIGNhbGwuCVgyNUFQSSBTcGVjaWZpYyBmdW5jdGlvbi4gCisgKglGb3IgZWFjaCBpbmNvbWluZyBjYWxsLCBjcmVhdGUgYSBuZXcgc29ja2V0IGFuZCAKKyAqICAgICAgcmV0dXJuIGl0IHRvIHRoZSB1c2VyLgkKKyAqPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ki8KKworc3RhdGljIGludCB3YW5waXBlX2FjY2VwdChzdHJ1Y3Qgc29ja2V0ICpzb2NrLCBzdHJ1Y3Qgc29ja2V0ICpuZXdzb2NrLCBpbnQgZmxhZ3MpCit7CisJc3RydWN0IHNvY2sgKnNrOworCXN0cnVjdCBzb2NrICpuZXdzazsKKwlzdHJ1Y3Qgc2tfYnVmZiAqc2tiOworCURFQ0xBUkVfV0FJVFFVRVVFKHdhaXQsIGN1cnJlbnQpOworCWludCBlcnI9MDsKKworCWlmIChuZXdzb2NrLT5zayAhPSBOVUxMKXsKKwkJd2FucGlwZV9raWxsX3Nv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QpOworCXdyaXRlX3VubG9jaygmd2FucGlwZV9za2xpc3RfbG9jayk7CisJY2xlYXJfYml0KDEsJndhbnBpcGVfdHhfY3JpdGljYWwpOworCisJbmV3c2stPnNrX3NvY2tldCA9IG5ld3NvY2s7CisJbmV3c2stPnNrX3NsZWVwID0gJm5ld3NvY2stPndhaXQ7CisKKwkvKiBOb3cgYXR0YWNoIHVwIHRoZSBuZXcgc29ja2V0ICovCisJc2stPnNrX2Fja19iYWNrbG9nLS07CisJbmV3c29jay0+c2sgPSBuZXdzazsKKwkKKwlrZnJlZV9za2Ioc2tiKTsKKworCURCR19QUklOVEsoS0VSTl9JTkZPICJcbndhbnNvY2s6IEFDQ0VQVCBHb3QgTENOICVpXG4iLAorCQkgICB3cF9zayhuZXdzayktPmxjbik7CisJcmV0dXJuIDA7Cit9CisKKy8qPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogIGdldF9uZXdza19mcm9tX3NrYgorICoKKyAqCUFjY2VwdCgpIHVzZXMgdGhpcyBmdW5jdGlvbiB0byBnZXQgdGhlIGFkZHJlc3Mgb2YgdGhlIG5ldworICogICAgICBzb2NrZXQgc3RydWN0dXJlLgorICo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0qLworCitzdHJ1Y3Qgc29jayAqIGdldF9uZXdza19mcm9tX3NrYiAoc3RydWN0IHNrX2J1ZmYgKnNrYikKK3sKKwlzdHJ1Y3QgbmV0X2RldmljZSAqZGV2ID0gc2tiLT5kZXY7CisJd2FucGlwZV9jb21tb25fdCAqY2hhbjsJCisKKwlpZiAoIWRldil7CisJCXJldHVybiBOVUxMOworCX0KKwkJCisJaWYgKChjaGFuID0gZGV2LT5wcml2KSA9PSBOVUxMKXsKKwkJcmV0dXJuIE5VTEw7CisJfQorCQkKKwlpZiAoIWNoYW4tPnNrKXsKKwkJcmV0dXJuIE5VTEw7CisJfQorCXJldHVybiAoc3RydWN0IHNvY2sgKiljaGFuLT5zazsKK30KKworLyo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiAgd2FucGlwZV9jb25uZWN0CisgKgorICogIAlDT05ORUNUKCkgU3lzdGVtIENhbGwuIFgyNUFQSSBzcGVjaWZpYyBmdW5jdGlvbgorICogCUNoZWNrIHRoZSBzdGF0ZSBvZiB0aGUgc29jaywgYW5kIGV4ZWN1dGUgUExBQ0VfQ0FMTCBjb21tYW5kLgorICogICAgICBDb25uZWN0IGNhbiBldGhlciBibG9jayBvciByZXR1cm4gd2l0aG91dCB3YWl0aW5nIGZvciBjb25uZWN0aW9uLCAKKyAqICAgICAgaWYgc3BlY2lmaWVkIGJ5IHVzZXIuCisgKj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PSovCisKK3N0YXRpYyBpbnQgd2FucGlwZV9jb25uZWN0KHN0cnVjdCBzb2NrZXQgKnNvY2ssIHN0cnVjdCBzb2NrYWRkciAqdWFkZHIsIGludCBhZGRyX2xlbiwgaW50IGZsYWdzKQoreworCXN0cnVjdCBzb2NrICpzayA9IHNvY2stPnNrOworCXN0cnVjdCB3YW5fc29ja2FkZHJfbGwgKmFkZHIgPSAoc3RydWN0IHdhbl9zb2NrYWRkcl9sbCopdWFkZHI7CisJc3RydWN0IG5ldF9kZXZpY2UgKmRldjsKKwlpbnQgZXJyOworCisJaWYgKHdwX3NrKHNrKS0+bnVtICE9IGh0b25zKFgyNV9QUk9UKSkKKwkJcmV0dXJuIC1FSU5WQUw7CisKKwlpZiAoc2stPnNrX3N0YXRlID09IFdBTlNPQ0tfQ09OTkVDVEVEKQorCQlyZXR1cm4gLUVJU0NPTk47CS8qIE5vIHJlY29ubmVjdCBvbiBhIHNlcXBhY2tldCBzb2NrZXQgKi8KKwor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5kZXIgdGhlIHRlcm1zIG9mIHRoZSBHTlUgR2VuZXJhbCBQdWJsaWMgTGljZW5zZQorKgkJYXMgcHVibGlzaGVkIGJ5IHRoZSBGcmVlIFNvZnR3YXJlIEZvdW5kYXRpb247IGVpdGhlciB2ZXJzaW9uCisqCQkyIG9mIHRoZSBMaWNlbnNlLCBvciAoYXQgeW91ciBvcHRpb24pIGFueSBsYXRlciB2ZXJzaW9uLgorKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisqIEp1biAwMiwgMTk5OSAgR2lkZW9uIEhhY2sJVXBkYXRlcyBmb3IgTGludXggMi4yLlgga2VybmVscy4KKyogSnVuIDI5LCAxOTk3CUFsYW4gQ294CU1lcmdlZCB3aXRoIDEuMC4zIHZlbmRvciBjb2RlCisqIEphbiAyOSwgMTk5NwlHZW5lIEtvemluCXYxLjAuMS4gSW1wbGVtZW50ZWQgL3Byb2MgcmVhZCByb3V0aW5lcworKiBKYW4gMzAsIDE5OTcJQWxhbiBDb3gJSGFja2VkIGFyb3VuZCBmb3IgMi4xCisqIERlYyAxMywgMTk5NglHZW5lIEtvemluCUluaXRpYWwgdmVyc2lvbiAoYmFzZWQgb24gU2FuZ29tYSdzIFdBTlBJUEUpCisqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKworI2luY2x1ZGUgPGxpbnV4L2NvbmZpZy5oPgorI2luY2x1ZGUgPGxpbnV4L2luaXQuaD4JCS8qIF9faW5pdGZ1bmMgZXQgYWwuICovCisjaW5jbHVkZSA8bGludXgvc3RkZGVmLmg+CS8qIG9mZnNldG9mKCksIGV0Yy4gKi8KKyNpbmNsdWRlIDxsaW51eC9lcnJuby5oPgkvKiByZXR1cm4gY29kZXMgKi8KKyNpbmNsdWRlIDxsaW51eC9rZXJuZWwuaD4KKyNpbmNsdWRlIDxsaW51eC9tb2R1bGUuaD4KKyNpbmNsdWRlIDxsaW51eC93YW5yb3V0ZXIuaD4JLyogV0FOIHJvdXRlciBBUEkgZGVmaW5pdGlvbnMgKi8KKyNpbmNsdWRlIDxsaW51eC9zZXFfZmlsZS5oPgorI2luY2x1ZGUgPGxpbnV4L3NtcF9sb2NrLmg+CisKKyNpbmNsdWRlIDxhc20vaW8uaD4KKworI2RlZmluZSBQUk9DX1NUQVRTX0ZPUk1BVCAiJTMwczogJTEybHVcbiIKKworLyoqKioqKiBEZWZpbmVzIGFuZCBNYWNyb3MgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisKKyNkZWZpbmUgUFJPVF9ERUNPREUocHJvdCkgKChwcm90ID09IFdBTkNPTkZJR19GUikgPyAiIEZSIiA6XAorCQkJICAgICAgKHByb3QgPT0gV0FOQ09ORklHX1gyNSkgPyAiIFgyNSIgOiBcCisJCQkgICAgICAgICAocHJvdCA9PSBXQU5DT05GSUdfUFBQKSA/ICIgUFBQIiA6IFwKKwkJCQkgICAgKHByb3QgPT0gV0FOQ09ORklHX0NIRExDKSA/ICIgQ0hETEMiOiBcCisJCQkJICAgICAgIChwcm90ID09IFdBTkNPTkZJR19NUFBQKSA/ICIgTVBQUCIgOiBcCisJCQkJICAgICAgICAgICAiIFVua25vd24iICkKKworLyoqKioqKiBGdW5jdGlvbiBQcm90b3R5cGVzICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisKKyNpZmRlZiBDT05GSUdfUFJPQ19GUworCisvKiBNaXNjZWxsYW5lb3VzICovCisKKy8qCisgKglTdHJ1Y3R1cmVzIGZvciBpbnRlcmZhY2luZyB3aXRoIHRoZSAvcHJvYyBmaWxlc3lzdGVtLgorICoJUm91dGVyIGNyZWF0ZXMgaXRzIG93biBkaXJlY3RvcnkgL3Byb2MvbmV0L3JvdXRlciB3aXRoIHRoZSBmb2xvd2luZworICoJZ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X2FkZHI7CisJfQorCisJbXNnLT5tc2dfbmFtZWxlbiA9IHNpemVvZihzdHJ1Y3Qgc29ja2FkZHJfeDI1KTsKKworCWxvY2tfc29jayhzayk7CisJeDI1X2NoZWNrX3JidWYoc2spOworCXJlbGVhc2Vfc29jayhzayk7CisJcmMgPSBjb3BpZWQ7CitvdXRfZnJlZV9kZ3JhbToKKwlza2JfZnJlZV9kYXRhZ3JhbShzaywgc2tiKTsKK291dDoKKwlyZXR1cm4gcmM7Cit9CisKKworc3RhdGljIGludCB4MjVfaW9jdGwoc3RydWN0IHNvY2tldCAqc29jaywgdW5zaWduZWQgaW50IGNtZCwgdW5zaWduZWQgbG9uZyBhcmcpCit7CisJc3RydWN0IHNvY2sgKnNrID0gc29jay0+c2s7CisJc3RydWN0IHgyNV9zb2NrICp4MjUgPSB4MjVfc2soc2spOworCXZvaWQgX191c2VyICphcmdwID0gKHZvaWQgX191c2VyICopYXJnOworCWludCByYzsKKworCXN3aXRjaCAoY21kKSB7CisJCWNhc2UgVElPQ09VVFE6IHsKKwkJCWludCBhbW91bnQgPSBzay0+c2tfc25kYnVmIC0KKwkJCQkgICAgIGF0b21pY19yZWFkKCZzay0+c2tfd21lbV9hbGxvYyk7CisJCQlpZiAoYW1vdW50IDwgMCkKKwkJCQlhbW91bnQgPSAwOworCQkJcmMgPSBwdXRfdXNlcihhbW91bnQsICh1bnNpZ25lZCBpbnQgX191c2VyICopYXJncCk7CisJCQlicmVhazsKKwkJfQorCisJCWNhc2UgVElPQ0lOUTogeworCQkJc3RydWN0IHNrX2J1ZmYgKnNrYjsKKwkJCWludCBhbW91bnQgPSAwOworCQkJLyoKKwkJCSAqIFRoZXNlIHR3byBhcmUgc2FmZSBvbiBhIHNpbmdsZSBDUFUgc3lzdGVtIGFzCisJCQkgKiBvbmx5IHVzZXIgdGFza3MgZmlkZGxlIGhlcmUKKwkJCSAqLworCQkJaWYgKChza2IgPSBza2JfcGVlaygmc2stPnNrX3JlY2VpdmVfcXVldWUp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3NpemVfaW4pIHsKKwkJCVNPQ0tfREVCVUcoc2ssICJYLjI1OiBwYWNrZXQgc2l6ZSBpbndhcmRzIG5lZ290aWF0ZWQgZG93biIpOworCQkJbmV3LT5wYWNzaXplX2luID0gdGhlaXJzLnBhY3NpemVfaW47CisJCX0KKwkJaWYgKHRoZWlycy5wYWNzaXplX291dCA8IG91cnMtPnBhY3NpemVfb3V0KSB7CisJCQlTT0NLX0RFQlVHKHNrLCAiWC4yNTogcGFja2V0IHNpemUgb3V0d2FyZHMgbmVnb3RpYXRlZCBkb3duIik7CisJCQluZXctPnBhY3NpemVfb3V0ID0gdGhlaXJzLnBhY3NpemVfb3V0OworCQl9CisJfQorCisJaWYgKHRoZWlycy53aW5zaXplX2luICYmIHRoZWlycy53aW5zaXplX291dCkgeworCQlpZiAodGhlaXJzLndpbnNpemVfaW4gPCBvdXJzLT53aW5zaXplX2luKSB7CisJCQlTT0NLX0RFQlVHKHNrLCAiWC4yNTogd2luZG93IHNpemUgaW53YXJkcyBuZWdvdGlhdGVkIGRvd24iKTsKKwkJCW5ldy0+d2luc2l6ZV9pbiA9IHRoZWlycy53aW5zaXplX2luOworCQl9CisJCWlmICh0aGVpcnMud2luc2l6ZV9vdXQgPCBvdXJzLT53aW5zaXplX291dCkgeworCQkJU09DS19ERUJVRyhzaywgIlguMjU6IHdpbmRvdyBzaXplIG91dHdhcmRzIG5lZ290aWF0ZWQgZG93biIpOworCQkJbmV3LT53aW5zaXplX291dCA9IHRoZWlycy53aW5zaXplX291dDsKKwkJfQorCX0KKworCXJldHVybiBsZW47Cit9CisKKy8qCisgKglMaW1pdCB2YWx1ZXMgb2YgY2VydGFpbiBmYWNpbGl0aWVzIGFjY29yZGluZyB0byB0aGUgY2FwYWJpbGl0eSBvZiB0aGUgCisgKiAgICAgIGN1cnJlbnRseSBhdHRhY2hlZCB4MjUgbGluay4KKyAqLwordm9pZCB4MjVfbGltaXRfZmFjaWxpdGllcyhzdHJ1Y3QgeDI1X2ZhY2ls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worCQkuc2FkYl9hbGdfaWQgPSBTQURCX1hfRUFMR19CTE9XRklTSENCQywKKwkJLnNhZGJfYWxnX2l2bGVuID0gOCwKKwkJLnNhZGJfYWxnX21pbmJpdHMgPSA0MCwKKwkJLnNhZGJfYWxnX21heGJpdHMgPSA0NDgKKwl9Cit9LAoreworCS5uYW1lID0gImFlcyIsCisKKwkudWluZm8gPSB7CisJCS5lbmNyID0geworCQkJLmJsb2NrYml0cyA9IDEyOCwKKwkJCS5kZWZrZXliaXRzID0gMTI4LAorCQl9CisJfSwKKworCS5kZXNjID0geworCQkuc2FkYl9hbGdfaWQgPSBTQURCX1hfRUFMR19BRVNDQkMsCisJCS5zYWRiX2FsZ19pdmxlbiA9IDgsCisJCS5zYWRiX2FsZ19taW5iaXRzID0gMTI4LAorCQkuc2FkYl9hbGdfbWF4Yml0cyA9IDI1NgorCX0KK30sCit7CisgICAgICAgIC5uYW1lID0gInNlcnBlbnQiLAorCisgICAgICAgIC51aW5mbyA9IHsKKyAgICAgICAgICAgICAgICAuZW5jciA9IHsKKyAgICAgICAgICAgICAgICAgICAgICAgIC5ibG9ja2JpdHMgPSAxMjgsCisgICAgICAgICAgICAgICAgICAgICAgICAuZGVma2V5Yml0cyA9IDEyOCwKKyAgICAgICAgICAgICAgICB9CisgICAgICAgIH0sCisKKyAgICAgICAgLmRlc2MgPSB7CisgICAgICAgICAgICAgICAgLnNhZGJfYWxnX2lkID0gU0FEQl9YX0VBTEdfU0VSUEVOVENCQywKKyAgICAgICAgICAgICAgICAuc2FkYl9hbGdfaXZsZW4gPSA4LAorICAgICAgICAgICAgICAgIC5zYWRiX2FsZ19taW5iaXRzID0gMTI4LAorICAgICAgICAgICAgICAgIC5zYWRiX2FsZ19tYXhiaXRzID0gMjU2LAorICAgICAgICB9Cit9LAoreworICAgICAgICAubmFtZSA9ICJ0d29maXNoIiwKKyAgICAgICAgICAgICAgICAgCisgICAgICAgIC51aW5mbyA9IHsKKyAgICAgICAgICAgICAgICAuZW5jciA9IHsKKyAgICAgICAgICAgICAgICAgICAgICAgIC5ibG9ja2JpdHMgPSAxMjgsCisgICAgICAgICAgICAgICAgICAgICAgICAuZGVma2V5Yml0cyA9IDEyOCwKKyAgICAgICAgICAgICAgICB9CisgICAgICAgIH0sCisKKyAgICAgICAgLmRlc2MgPSB7CisgICAgICAgICAgICAgICAgLnNhZGJfYWxnX2lkID0gU0FEQl9YX0VBTEdfVFdPRklTSENCQywKKyAgICAgICAgICAgICAgICAuc2FkYl9hbGdfaXZsZW4gPSA4LAorICAgICAgICAgICAgICAgIC5zYWRiX2FsZ19taW5iaXRzID0gMTI4LAorICAgICAgICAgICAgICAgIC5zYWRiX2FsZ19tYXhiaXRzID0gMjU2CisgICAgICAgIH0KK30sCit9OworCitzdGF0aWMgc3RydWN0IHhmcm1fYWxnb19kZXNjIGNhbGdfbGlzdFtdID0geworeworCS5uYW1lID0gImRlZmxhdGUiLAorCS51aW5mbyA9IHsKKwkJLmNvbXAgPSB7CisJCQkudGhyZXNob2xkID0gOTAsCisJCX0KKwl9LAorCS5kZXNjID0geyAuc2FkYl9hbGdfaWQgPSBTQURCX1hfQ0FMR19ERUZMQVRFIH0KK30sCit7CisJLm5hbWUgPSAibHpzIiwKKwkudWluZm8gPSB7CisJCS5jb21wID0geworCQkJLnRocmVzaG9sZCA9IDkwLAorCQl9CisJfSwKKwkuZGVzYyA9IHsgLnNhZGJfYWxnX2lkID0gU0FEQl9YX0NBTEdfTFpTIH0KK30sCit7CisJLm5hbWUgPSAibHpqaCIsCisJLnVpbmZvID0geworCQkuY29tcCA9IHsKKwkJCS50aHJlc2hvbGQgPSA1MCwKKwkJfQorCX0sCisJLmRlc2MgPSB7IC5zYWRiX2FsZ19pZCA9IFNBREJfWF9DQUxHX0xaSkggfQorfSwKK307CisKK3N0YXRpYyBpbmxpbmUgaW50IGFhbGdfZW50cmllcyh2b2lkKQoreworCXJldHVybiBBUlJBWV9TSVpFKGFhbGdfbGlzdCk7Cit9CisKK3N0YXRpY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