From: Brijesh Singh Subject: Re: [Part2 PATCH v5 31/31] KVM: X86: Restart the guest when insn_len is zero and SEV is enabled Date: Wed, 18 Oct 2017 07:19:59 -0500 Message-ID: <639d43f6-c403-4fff-7152-9814d9c5b9e6@amd.com> References: <20171004131704.13266-1-brijesh.singh@amd.com> <20171004131704.13266-2-brijesh.singh@amd.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Cc: brijesh.singh@amd.com, Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Joerg Roedel , Borislav Petkov , Tom Lendacky To: Paolo Bonzini , x86@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Return-path: In-Reply-To: Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org Hi Paolo, On 10/18/17 4:26 AM, Paolo Bonzini wrote: > 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? We can use X86_FEATURE_DECODEASSIST but since mmu.c is common file hence I was not sure if its safe for the VMX.  Is it okay to use decode assist feature bit in mm.c ? > > Thanks, > > Paolo