From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967138AbdJRJ0J (ORCPT ); Wed, 18 Oct 2017 05:26:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54810 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965409AbdJRJ0G (ORCPT ); Wed, 18 Oct 2017 05:26:06 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CF2FC81E10 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=pbonzini@redhat.com Subject: Re: [Part2 PATCH v5 31/31] KVM: X86: Restart the guest when insn_len is zero and SEV is enabled To: Brijesh Singh , x86@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Joerg Roedel , Borislav Petkov , Tom Lendacky References: <20171004131704.13266-1-brijesh.singh@amd.com> <20171004131704.13266-2-brijesh.singh@amd.com> From: Paolo Bonzini Message-ID: Date: Wed, 18 Oct 2017 11:26:01 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <20171004131704.13266-2-brijesh.singh@amd.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 18 Oct 2017 09:26:06 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/10/2017 15:17, Brijesh Singh wrote: > + /* > + * On AMD platforms, under certain conditions insn_len may be zero on #NPF. > + * This can happen if a guest gets a page-fault on data access but the HW > + * table walker is not able to read the instruction page (e.g instruction > + * page is not present in memory). > + * > + * Typically, when insn_len is zero, x86_emulate_instruction() walks the > + * guest page table and fetches the instruction bytes from guest memory. > + * When SEV is enabled, the guest memory is encrypted with guest-specific > + * key hence hypervisor will not able to fetch the instruction bytes. > + * In those cases we simply restart the guest. > + */ > + if (unlikely(!insn_len) && > + kvm_x86_ops->mem_enc_enabled && > + kvm_x86_ops->mem_enc_enabled(vcpu)) > + return 1; > + Is it needed to test mem_enc_enabled? Could it instead test for the availability of decode assists? Thanks, Paolo