Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753064AbdHDOXm (ORCPT ); Fri, 4 Aug 2017 10:23:42 -0400 Received: from mail-sn1nam02on0080.outbound.protection.outlook.com ([104.47.36.80]:62848 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752467AbdHDOXj (ORCPT ); Fri, 4 Aug 2017 10:23:39 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; Cc: brijesh.singh@amd.com, kvm@vger.kernel.org, thomas lendacky , rkrcmar@redhat.com, joro@8bytes.org, x86@kernel.org, linux-kernel@vger.kernel.org, mingo@redhat.com, hpa@zytor.com, tglx@linutronix.de, bp@suse.de Subject: Re: [PATCH v2 1/3] kvm: svm: Add support for additional SVM NPF error codes To: Paolo Bonzini References: <147992048887.27638.17559991037474542240.stgit@brijesh-build-machine> <147992049856.27638.17076562184960611399.stgit@brijesh-build-machine> <21b9f4db-f929-80f6-6ad2-6fa3b77f82c0@redhat.com> <98086274.371452.1501531542630.JavaMail.zimbra@redhat.com> <661faa8a-87af-743f-d3ea-b95ada0d7677@amd.com> <6afdcd42-7abe-c814-1f67-407ff91a75d2@redhat.com> <85670631-0e42-7fd3-6d2c-29be2f91b38a@redhat.com> From: Brijesh Singh Message-ID: Date: Fri, 4 Aug 2017 09:23:29 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <85670631-0e42-7fd3-6d2c-29be2f91b38a@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: BN6PR03CA0015.namprd03.prod.outlook.com (10.168.230.153) To BY2PR12MB0145.namprd12.prod.outlook.com (10.162.82.18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 19c07a66-0e1b-4816-814d-08d4db4465a2 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(48565401081)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:BY2PR12MB0145; X-Microsoft-Exchange-Diagnostics: 1;BY2PR12MB0145;3:r9qQJa/PuEQg8eIHZB1aopx1As8jqAqsE1l4dF4vvj3d7NOroojveQ28LwfRMhzhOgnzKhoscSMc95g+f9YiUdbQo9XDQkgZjYzW64b9B1q4bTrc+1tF1xdxso7ztAzIg1tDSLg4wBAzNKk3vnsk7kZC0KEwaIhOP9VrN8Wry272XEIIuj1nwEfIowNcsovb2BtIomoV9WqpS3bdK376XS8o2GjFaBQzBeOwMpV34D/tyRavp5pwCT7xEA+iYKwL;25:ys3+BvntMJD6RTr2oPiw3Kio9f/s/mnVZM+uO3IepXDxQz/AcCguRvZ62cdzgOuFgSQx5w+T2XV+WXh0MKtmEj3JyX7+67XAL7lBkN3G6y/6bZ33aONLvZLyxcEjTA+leBKyvj75LD9SS+M1iKzbqnziuKsu+6M0GtRjAvTkUpm3DWVKfzLejcpoPGDx2Nc64j0sYeEKUdAf3tu65a0KX6jHaVDySzvPbvE9D+ohzitu9fY0KtP9n7l4nVnJTo6uEHwpnW/yI3UBA59UQIvpclYUpBO8qVad8t6lcJtmt4xqEf9KS6H0hS/mrcUOYYYrdN1atPFLDsQ6wvy+ORJ4pg==;31:4JuTv8Gy4ISl9MwikqveCG99gfRCGYWsAyMbUCKBvN5TPUudW3UsX8AN5QBexYZTbKOQ40ePDI/aKQSQ+c/+IeLztSJM/wx5lXUx61hsOnmRsG9qK7webfug6WExdcdS5eBEqkE7d0zMetEKrddw794nKsfpRemGHkWTeYC3Iqadqh+9dzvQp2krTEfpwEQqRYCILLQJWVxr+FCWWyGjzrhi+kxjxJLh3T+yraAmz7U= X-MS-TrafficTypeDiagnostic: BY2PR12MB0145: X-Microsoft-Exchange-Diagnostics: 1;BY2PR12MB0145;20:4QsGD5W1FDklUr7oNGIapSMza6ChCWCCUToQGUaqmokzgiOOUCA6w/zzUygQ2AcGY5twIoLk0J/FXhFi/bnpuX8bXfWeScWf/V60RCz4szHebkbWhrTXWqtfWj3y1Qo7tvcEa7Bz1mxmFjt4l56lnG2fe3waP38yG1jhHscLQphe5wI735lGbHNax4xo2kQFKOp1oEOx0BrDGjDEZsv2IGVhUw0kJV87h6pYN0ClWEDRDwSe+nBROLfAS0m5PcjlfYs9s8hMq6HGLcGE1ia2OQL4IlcCx3Hg2Wsx8EkRx4SoQv8D/T0XmPFyUfGt8a6lKdGaSJv6GWQb80xLaQ65b2WvUjeE21SYJn+e71xOVsJqgw0i4p+IdHcHI+ihqPmU3f18sGI7ubHub5t0m22VN54oZdTr9Gf2kra4mpVYt/xYFg8dq1Ppr3z1Nks4v20/OJMaZRn8Gh8YNOzTKskZYZW5RL0kg007fCHMSszaz9tc5BgI8d1E/osTQYhYl9qz;4:SgWEQ8T7HCAnvDH0NhsO86w+0m/H/rOUWdM4Rkh08SKlPatijY40f9jcPufZ9oNWyVDod6K5hQTc+aa7YJhXmvbabDjaJp//xmuZTEu6lNRTlosOEACEJQJYIAKeLfUC4zMrIR1QFrN5hhQ7evFN7T+CsytpYYbjfKD/LD/I4sYAhYU5soZZSld1bSk8uEO6d8B0pjqpb8fH4VB/SmcUa5nlhn0+NmVVQsun70wnDTh/UaRc06uPxaxkb9rZMhv2 X-Exchange-Antispam-Report-Test: UriScan:; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(93006095)(93001095)(100000703101)(100105400095)(3002001)(10201501046)(6055026)(6041248)(20161123555025)(20161123558100)(20161123562025)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:BY2PR12MB0145;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:BY2PR12MB0145; X-Forefront-PRVS: 0389EDA07F X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(7370300001)(6049001)(6009001)(39850400002)(39400400002)(39840400002)(39410400002)(39860400002)(39450400003)(377454003)(199003)(24454002)(189002)(38730400002)(36756003)(4001350100001)(110136004)(65826007)(229853002)(50986999)(97736004)(53546010)(189998001)(4326008)(81166006)(6246003)(53936002)(83506001)(5660300001)(2906002)(305945005)(7736002)(64126003)(8676002)(7416002)(81156014)(25786009)(50466002)(3846002)(7350300001)(33646002)(23676002)(6116002)(68736007)(478600001)(86362001)(42186005)(66066001)(47776003)(54356999)(6666003)(230700001)(65956001)(31686004)(76176999)(77096006)(65806001)(31696002)(6486002)(101416001)(90366009)(93886004)(6916009)(106356001)(2950100002)(105586002)(217873001);DIR:OUT;SFP:1101;SCL:1;SRVR:BY2PR12MB0145;H:[10.236.136.62];FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtCWTJQUjEyTUIwMTQ1OzIzOndvSVpKYXNxSlQrNmpaYjcxYjdiM0JoYVlI?= =?utf-8?B?VExnY0dndHgwVDIxdGUxa1VVQlRrVzVGRVBua0J5N202TDkvYXluN0JkVmtQ?= =?utf-8?B?MmxHSG1idUI5bE9kQTVmSHZlZG1uejRHbkc2S3VnVktsNS83UmJlbExjQ21Z?= =?utf-8?B?N005NlE0VnJMd1FSYzB4RUNIMHBpSExIc1p2dm1QWVdiUEFyWXl5UmxQcHR1?= =?utf-8?B?cDVTc2h2WE9yY29rS1ZvQi9KY3IyWS9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fo= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BY2PR12MB0145;20:5JgkytgCdoB9B7lYKhP3qtKqkr16LUvMYB3aFcjbBhAy2HI9z49ABe0n+ynXT6aBb6JwgM9aLLyMcad00LT+Ro8SobdDClK1RRAXUDsz4M6NjJ3Raz3JDqdevSJe7sorRtYYbFJhymIv07uhKpH16C7Pwah8bbutMR3FZ7BTuQbJcHeu0Ta2C7/nGO6WR4EwHb9P71nBsJrajaIvM3rKty85YsxXfjGv2oqAqbBAiu1odYs4c25EVXMFlnaj4Att X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Aug 2017 14:23:35.2989 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR12MB0145 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1970 Lines: 59 Hi Paolo, On 08/04/2017 09:05 AM, Paolo Bonzini wrote: > On 04/08/2017 02:30, Brijesh Singh wrote: >> >> >> On 8/2/17 5:42 AM, Paolo Bonzini wrote: >>> On 01/08/2017 15:36, Brijesh Singh wrote: >>>>> The flow is: >>>>> >>>>> hardware walks page table; L2 page table points to read only memory >>>>> -> pf_interception (code = >>>>> -> kvm_handle_page_fault (need_unprotect = false) >>>>> -> kvm_mmu_page_fault >>>>> -> paging64_page_fault (for example) >>>>> -> try_async_pf >>>>> map_writable set to false >>>>> -> paging64_fetch(write_fault = true, map_writable = false, >>>>> prefault = false) >>>>> -> mmu_set_spte(speculative = false, host_writable = false, >>>>> write_fault = true) >>>>> -> set_spte >>>>> mmu_need_write_protect returns true >>>>> return true >>>>> write_fault == true -> set emulate = true >>>>> return true >>>>> return true >>>>> return true >>>>> emulate >>>>> >>>>> Without this patch, emulation would have called >>>>> >>>>> ..._gva_to_gpa_nested >>>>> -> translate_nested_gpa >>>>> -> paging64_gva_to_gpa >>>>> -> paging64_walk_addr >>>>> -> paging64_walk_addr_generic >>>>> set fault (nested_page_fault=true) >>>>> >>>>> and then: >>>>> >>>>> kvm_propagate_fault >>>>> -> nested_svm_inject_npf_exit >>>>> >>>> maybe then safer thing would be to qualify the new error_code check with >>>> !mmu_is_nested(vcpu) or something like that. So that way it would run on >>>> L1 guest, and not the L2 guest. I believe that would restrict it avoid >>>> hitting this case. Are you okay with this change ? >>> Or check "vcpu->arch.mmu.direct_map"? That would be true when not using >>> shadow pages. >> >> Yes that can be used. > > Are you going to send a patch for this? > Yes. I should be posting it by Monday or Tuesday - need sometime to verify it. -Brijesh