Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3887747ybb; Mon, 6 Apr 2020 18:25:22 -0700 (PDT) X-Google-Smtp-Source: APiQypLK5KaA1pza0i9slJ9Q8d8T8u+XhFxg2xC+g31be7FBkhQ869OI65fmJtz/qUCcRBBvAkCc X-Received: by 2002:aca:5208:: with SMTP id g8mr1569993oib.169.1586222722002; Mon, 06 Apr 2020 18:25:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586222721; cv=none; d=google.com; s=arc-20160816; b=L3wFfNxLwy1nD6toz8gvEJnQBin2EiRGaitiGOo4/nfSz1HdsHjrCI93KQC/3gvaew 4swtOMOnnodm3yIVcwVlC/yhC8+cKBTFyZ5q7LDoOU8KKgOUuOU/IRDyK0jlYqlgVTJX hMMYy3Hp3QkAex95a+XNC3g2Juvc1xGRcRCmWpmdvpy207oZoTBcqLS5EpCSNMbsdbQk sUXWXkCeDf9Qvi3lB5swxKNcV4L3v/ooV2sE/z6FhRkf5d2oyPWlIhtV2EcL0gZj4rVF 0lXy9klwPrJi+V2wHDtHHfg28o3AeCTRNPIPGK5z4wDHlSP5jjFnHwHgOD1ZtFQQb281 SIcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=8xLjgb+qGG1qiDMfAEEmGgrAB+VQUtcxURJEWn+sb/E=; b=FTm7JDVEpfRHmsIbkIrTbMSmaQ5zNxAbkh8ev1blHpilte0STKmEwM1ivwAT/bVtG8 mWRhA8Zf2SUA2i06fhFcKbczkXGBgohT2n8TiiC/QRxjDBPXKC34MHoVIxyPr8y8pC6y BFnvjoHrG7RiE5sJf5ZzpaFKxdcGzNIxC4bol4C1Rr/x5VV3nxDKhEQIo9pi12zTxze9 FRdYTICKjzyTPKZ2c7frK1CPoi/BwpwXFdN4/jOXjEgPG5BHt2Ouhj2Zxvs9W1kqrSmg Eeop4lKXQLs172HFF3v4ULqjI0gOXweTUDEE5hmQECpcWIvLwljovz6bOvHDDT6Iv6CZ t3yA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=LXXGsD2r; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k7si598731otp.258.2020.04.06.18.25.09; Mon, 06 Apr 2020 18:25:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=LXXGsD2r; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726437AbgDGBXY (ORCPT + 99 others); Mon, 6 Apr 2020 21:23:24 -0400 Received: from mail-lf1-f68.google.com ([209.85.167.68]:45104 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726277AbgDGBXY (ORCPT ); Mon, 6 Apr 2020 21:23:24 -0400 Received: by mail-lf1-f68.google.com with SMTP id f8so1010549lfe.12 for ; Mon, 06 Apr 2020 18:23:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=8xLjgb+qGG1qiDMfAEEmGgrAB+VQUtcxURJEWn+sb/E=; b=LXXGsD2rAjvNbJ25G+PeWz1PdGgiEBdPoOmIDPFW1l76hp18A8PCL0Qt+lECooczdV 0PkgRztrvi5F61Pbl95AdPnsDwC0iH/Xvr33BJ+zKqIucp040ByHEeGsZZu+VTX0VOjT O2kilg4Fy/BcQp6OKQPU2Z6zj6zjUPOEuOASXbrphTpNKCVkd22Q8gQCh1mtuvfpAQse V0YMUAPR2foHEsWS4N4AagOTiQw1rNDE/tPBE5jTO3hbeHTtOeeWQH++9RWZm2ido8gd hHdMIlmZIdT0OF7mjJhPoMiRKbcoj0RT85iAIaGyN5ouV8TPpHNJsX1DgfEFSx4Uad32 rrTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=8xLjgb+qGG1qiDMfAEEmGgrAB+VQUtcxURJEWn+sb/E=; b=Gu0qIR66xjzuprwiH2LgkXTbiqC89iMfXlmoXoFWdrlj7FpFy9mbKMy+nhh3kF0Ylt my5nACzA+xfVgiXDMYwRKfXLF75MZrJos621Leox/qaZZ54JxGBErMPd2MJUOXjOCsU/ HuyX9MWBAQgrOQy/nQDL8k7yC0XRQFXZqHYFp8x3ADIhOJNKqetKO9neJBQdqxnTSDCv mlno75gzjTbfqSUXMVgB2IRhCel9wJ5jIlKRlrZ3TwU/rSSYdPdwKtKDl//1volDaTuq qdbjILkCDgWp/6e0LpnmBfKxvVa5Xgy2xYpoVPTCbZ/7GRBsf6TgUpKIdpr102gALRx0 AWbw== X-Gm-Message-State: AGi0PubCufSg1j0xKLTfmAPZwI8rK029dUM0Bw00hZS82Lw0wTaijmaT msoWErmOCuIm3nIvLGS9t7VHFUMaHpAnZ27t9VTAtg== X-Received: by 2002:a19:f20c:: with SMTP id q12mr14873243lfh.34.1586222600886; Mon, 06 Apr 2020 18:23:20 -0700 (PDT) MIME-Version: 1.0 References: <6dda7016ab64490ac3d8e74f461f9f3d0ee3fc88.1585548051.git.ashish.kalra@amd.com> <9d1f29da-2d63-dfed-228f-b82b3cc2b777@oracle.com> In-Reply-To: <9d1f29da-2d63-dfed-228f-b82b3cc2b777@oracle.com> From: Steve Rutherford Date: Mon, 6 Apr 2020 18:22:44 -0700 Message-ID: Subject: Re: [PATCH v6 07/14] KVM: x86: Add AMD SEV specific Hypercall3 To: Krish Sadhukhan Cc: Ashish Kalra , Paolo Bonzini , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Joerg Roedel , Borislav Petkov , Tom Lendacky , X86 ML , KVM list , LKML , David Rientjes , Andy Lutomirski , Brijesh Singh Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 2, 2020 at 4:56 PM Krish Sadhukhan wrote: > > > On 3/29/20 11:21 PM, Ashish Kalra wrote: > > From: Brijesh Singh > > > > KVM hypercall framework relies on alternative framework to patch the > > VMCALL -> VMMCALL on AMD platform. If a hypercall is made before > > apply_alternative() > > s/apply_alternative/apply_alternatives/ > > is called then it defaults to VMCALL. The approach > > works fine on non SEV guest. A VMCALL would causes #UD, and hypervisor > > will be able to decode the instruction and do the right things. But > > when SEV is active, guest memory is encrypted with guest key and > > hypervisor will not be able to decode the instruction bytes. > > > > Add SEV specific hypercall3, it unconditionally uses VMMCALL. The hyper= call > > will be used by the SEV guest to notify encrypted pages to the hypervis= or. > > > > Cc: Thomas Gleixner > > Cc: Ingo Molnar > > Cc: "H. Peter Anvin" > > Cc: Paolo Bonzini > > Cc: "Radim Kr=C4=8Dm=C3=A1=C5=99" > > Cc: Joerg Roedel > > Cc: Borislav Petkov > > Cc: Tom Lendacky > > Cc: x86@kernel.org > > Cc: kvm@vger.kernel.org > > Cc: linux-kernel@vger.kernel.org > > Signed-off-by: Brijesh Singh > > Signed-off-by: Ashish Kalra > > --- > > arch/x86/include/asm/kvm_para.h | 12 ++++++++++++ > > 1 file changed, 12 insertions(+) > > > > diff --git a/arch/x86/include/asm/kvm_para.h b/arch/x86/include/asm/kvm= _para.h > > index 9b4df6eaa11a..6c09255633a4 100644 > > --- a/arch/x86/include/asm/kvm_para.h > > +++ b/arch/x86/include/asm/kvm_para.h > > @@ -84,6 +84,18 @@ static inline long kvm_hypercall4(unsigned int nr, u= nsigned long p1, > > return ret; > > } > > > > +static inline long kvm_sev_hypercall3(unsigned int nr, unsigned long p= 1, > > + unsigned long p2, unsigned long p3) > > +{ > > + long ret; > > + > > + asm volatile("vmmcall" > > + : "=3Da"(ret) > > + : "a"(nr), "b"(p1), "c"(p2), "d"(p3) > > + : "memory"); > > + return ret; > > +} > > + > > #ifdef CONFIG_KVM_GUEST > > bool kvm_para_available(void); > > unsigned int kvm_arch_para_features(void); > Reviewed-by: Krish Sadhukhan Nit: I'd personally have named this kvm_vmmcall3, since it's about invoking a particular instruction. The usage happens to be for SEV. Reviewed-by: Steve Rutherford