From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D89FC433E7 for ; Fri, 28 Aug 2020 12:34:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4E2BB2086A for ; Fri, 28 Aug 2020 12:34:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729376AbgH1MeY (ORCPT ); Fri, 28 Aug 2020 08:34:24 -0400 Received: from 8bytes.org ([81.169.241.247]:39864 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729298AbgH1MdI (ORCPT ); Fri, 28 Aug 2020 08:33:08 -0400 Received: by theia.8bytes.org (Postfix, from userid 1000) id 1F45E2E1; Fri, 28 Aug 2020 14:33:07 +0200 (CEST) Date: Fri, 28 Aug 2020 14:33:04 +0200 From: Joerg Roedel To: Arvind Sankar Cc: x86@kernel.org, Joerg Roedel , Tom Lendacky , hpa@zytor.com, Andy Lutomirski , Dave Hansen , Peter Zijlstra , Jiri Slaby , Dan Williams , Juergen Gross , Kees Cook , David Rientjes , Cfir Cohen , Erdem Aktas , Masami Hiramatsu , Mike Stunes , Sean Christopherson , Martin Radev , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org Subject: Re: [PATCH v6 27/76] x86/sev-es: Add CPUID handling to #VC handler Message-ID: <20200828123304.GD13881@8bytes.org> References: <20200824085511.7553-1-joro@8bytes.org> <20200824085511.7553-28-joro@8bytes.org> <20200827224810.GA986963@rani.riverdale.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200827224810.GA986963@rani.riverdale.lan> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 27, 2020 at 06:48:10PM -0400, Arvind Sankar wrote: > On Mon, Aug 24, 2020 at 10:54:22AM +0200, Joerg Roedel wrote: > > From: Tom Lendacky > > > > Handle #VC exceptions caused by CPUID instructions. These happen in > > early boot code when the KASLR code checks for RDTSC. > > > > Signed-off-by: Tom Lendacky > > [ jroedel@suse.de: Adapt to #VC handling framework ] > > Co-developed-by: Joerg Roedel > > Signed-off-by: Joerg Roedel > > Link: https://lore.kernel.org/r/20200724160336.5435-27-joro@8bytes.org > > --- > > + > > +static enum es_result vc_handle_cpuid(struct ghcb *ghcb, > > + struct es_em_ctxt *ctxt) > > +{ > > + struct pt_regs *regs = ctxt->regs; > > + u32 cr4 = native_read_cr4(); > > + enum es_result ret; > > + > > + ghcb_set_rax(ghcb, regs->ax); > > + ghcb_set_rcx(ghcb, regs->cx); > > + > > + if (cr4 & X86_CR4_OSXSAVE) > > Will this ever happen? trampoline_32bit_src will clear CR4 except for > PAE and possibly LA57, no? This same code is later re-used in the runtime handler and there the check is needed :) Regards, Joerg