Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1592907pxb; Fri, 20 Aug 2021 09:06:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwyzMSbR+3aGgkfAHI4XHyBcaJsaVtF8A07pRixbIReX2gHx/BeZtC/H3hjEBNiRZJpUTQ/ X-Received: by 2002:a05:6e02:10c2:: with SMTP id s2mr14250865ilj.148.1629475595060; Fri, 20 Aug 2021 09:06:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1629475595; cv=pass; d=google.com; s=arc-20160816; b=C3F5su7HtBKriDhxgh15uZ0BfQiaXdRXyXZywYn4lNY+L7UXGXpxLggdbXWCc7nWNY FVKfXoWVwednrwAKCK5GvKr9iiRz/93GvKkvKuM0f+u+LetiDfI19SeezmKCOZL69TTJ MqC6JD02kR5Qg/OlIdWW40r8XT2QTCMbW5FfFdqspdQfvJAHxGl9mTM0tg9gtPM7pI98 2yQZI1MDkcWew17f6ifwNNknRET01kWGOH4NBMWXaxlUcQQax94idskB8sy1BWjOw6HZ 9XUFXJXtiO28SR83wPirjVX0JqUW2pc0lHv0kh5ezI9fZ/582JKTjidMpuZ//lRv7hDm x5Mg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=jgGy54dnJkrivIr9eJV5SEJ/kD8j1HP7vpZl/8sU0RA=; b=ttGm0Sgg786jKn0E9AtLQ0DhGG31KpsxSkDKqbNEMIR+x9QJhmAq8V8eHMyX/Mn5JZ CQA3O5bBlDujI9HJl7/juRfmZsbQ/nk0P+PRedJxgl/Xa9E0b4VDQTjXNEbiykjWhSBo OvN3kIqaaNMzYsBWdcuqTI1NFgOfA8f89ysbCNvCWXT8Zb5zRIDD/JIU+4LPqFtBoBT0 1QiEfxdAsyHGZaX1HoE5UDGOxrgAHuOkecqxqYD/d0Z4xxZytI2F6u+0dsqiq42Xm/nF aeYS1KRmuY9f9/2cISU5N8MX4OE7GxaGK6aiGXTai5MrD8B9hwTK60J6vYjb7DZNfp4+ 8l9A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b="EVRX/8qC"; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k10si7015034ilc.6.2021.08.20.09.06.16; Fri, 20 Aug 2021 09:06:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b="EVRX/8qC"; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238521AbhHTQGY (ORCPT + 99 others); Fri, 20 Aug 2021 12:06:24 -0400 Received: from mail-bn8nam12on2072.outbound.protection.outlook.com ([40.107.237.72]:45024 "EHLO NAM12-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229772AbhHTQEX (ORCPT ); Fri, 20 Aug 2021 12:04:23 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P4e4I4WQlD056UUR+LDDow/+cjcoO9crrtoA7KQxA/RT/uu1vpDQqPcs+fw6DmBvtXHuEEZe/Bjg4a+mOl7V3AD0ZPsTopaBA2U5eCbnkMFTKs3dUWWFzoAM1Pjo3sk5jb0N2SKPbFBiUWuyBT9OEiECMt7IN4b1rFUmy/M6MGlZOJAUumTbWckak7kcp/S4HL2pqzcOof/75E/dGp/ZBXA0Z09fUCaOW4GByCP7VuAFx1PYTzSN7z1/TPyfqB4sE2/e4jCWF6jCZ2GaKl3VCXrJSgdJhgto2bhUWizpl+i33yZthQWGUTZ6a3OwRu8Ocsn9QTz2IHdzU+fpSJUE8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jgGy54dnJkrivIr9eJV5SEJ/kD8j1HP7vpZl/8sU0RA=; b=ZA6fmE8B0z+pSqvVB/UC2GdVhG0NO9dLgDblIHycuMZddqSb98amAeJBf3pKgONUWVFlu/pNtnYHTN2YX2jIPE0gNejn3R7SdDdNcBvdWb3oSl0JuqcL4onndbXRMOkORu/47JNIjqGiUpAy8IDtZNuGDTtJylNwmboyMCJM6boK97vme0hYBgYOQM29Gw8s8DAXqBCif244tx89As12/ZWcuGzVMDey3n57CQlgDjhqq6y6+rI4tx68yhTczdbhhqsH7qraLPfqXWgBZn67OYgMTzaz6+P3+hWd0vEF3wRLYH0BaYvPRE6Vu2hxGlUYVrETgXotfle5dKP7tp0Kbw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jgGy54dnJkrivIr9eJV5SEJ/kD8j1HP7vpZl/8sU0RA=; b=EVRX/8qCGaI14kUNdhV4IKIUAM+WBHbRSbEfdULq42NicloGRfmB70CJVzaj0A99XIVyh5d+OnZf1v9XBHwaYRgEFXvjpeO1gID3PZt3SzKOE7Wgnb3vTyZ+YDTaIBb/IbowFc9NPpXV6noztkWfgQKEP7Ft/91UPU3YH+zNvkA= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=amd.com; Received: from SN6PR12MB2718.namprd12.prod.outlook.com (2603:10b6:805:6f::22) by SA0PR12MB4509.namprd12.prod.outlook.com (2603:10b6:806:9e::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19; Fri, 20 Aug 2021 16:01:10 +0000 Received: from SN6PR12MB2718.namprd12.prod.outlook.com ([fe80::78b7:7336:d363:9be3]) by SN6PR12MB2718.namprd12.prod.outlook.com ([fe80::78b7:7336:d363:9be3%6]) with mapi id 15.20.4436.019; Fri, 20 Aug 2021 16:01:10 +0000 From: Brijesh Singh To: x86@kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-coco@lists.linux.dev, linux-mm@kvack.org, linux-crypto@vger.kernel.org Cc: Thomas Gleixner , Ingo Molnar , Joerg Roedel , Tom Lendacky , "H. Peter Anvin" , Ard Biesheuvel , Paolo Bonzini , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Andy Lutomirski , Dave Hansen , Sergio Lopez , Peter Gonda , Peter Zijlstra , Srinivas Pandruvada , David Rientjes , Dov Murik , Tobin Feldman-Fitzthum , Borislav Petkov , Michael Roth , Vlastimil Babka , "Kirill A . Shutemov" , Andi Kleen , tony.luck@intel.com, marcorr@google.com, sathyanarayanan.kuppuswamy@linux.intel.com Subject: [PATCH Part2 v5 43/45] KVM: SVM: Use a VMSA physical address variable for populating VMCB Date: Fri, 20 Aug 2021 10:59:16 -0500 Message-Id: <20210820155918.7518-44-brijesh.singh@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210820155918.7518-1-brijesh.singh@amd.com> References: <20210820155918.7518-1-brijesh.singh@amd.com> Content-Type: text/plain X-ClientProxiedBy: SN7P222CA0013.NAMP222.PROD.OUTLOOK.COM (2603:10b6:806:124::11) To SN6PR12MB2718.namprd12.prod.outlook.com (2603:10b6:805:6f::22) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sbrijesh-desktop.amd.com (165.204.77.1) by SN7P222CA0013.NAMP222.PROD.OUTLOOK.COM (2603:10b6:806:124::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.18 via Frontend Transport; Fri, 20 Aug 2021 16:00:47 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1bde20be-330a-48cb-7b6b-08d963f3ad3c X-MS-TrafficTypeDiagnostic: SA0PR12MB4509: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jGx/slJKI788K8bBwDS3vhaYyv+Y9cv0cE13gSgkNjfh6lUbuvlOmFWV0Ja235VnQ2tbqYFykDY8hlWa+MEQmih3bocDKPiHBe+LLcIP9lGm17YTPW64NRe/Aj/SiM1Uy6Yc+CYl1XkSqHau3Oai1wTKt2AHneJtUd0b2pZ3GOkvx2yJNsuHHiR7Dhb+Gyhdrg3oWgjFBgYa6GkX8FrrEXCWUPTgXiPdlY8ZoADzlzZsuHGuUKMMx49g2kHCGlGBF4i8xdecf08oXHyCXA3q3tdaIvUTMWHB7bHfB7e7OGfiGZJtJJEdtf0nMm4+H//OL2xct1XFFU8sn8Db+0Pe09CxD0PNiW75pO07j3YySLGhZ414qsb7xRSF9cdetZDL+0HPU99RYdOAtmTfYqL46Kh0aGQns7xLwLIS/LGNIRrgL2D9bdYiXJ65HkNHWr12EHg6qDP/2BmVHDK0hhbAniFu60v5vAhYUQCm4f08E0w3Z1bPP1cgd+5XHrKHoO9gwXrLJhrraBYH1gVj8qdyewvKGMlM65RlbPiSatFnR9z9GG0KyXF3x+F+veocIa4qKofOnLOAfD7Jq6txzSgqxVR95TmTdNqPzXarcXBlWyUAfhwnSXbGjDpIN/H02JUIYbcT2neuJlQLckCShsCLeUilHmZ0YVOU7KoxL/kiT+PkruwlLG7WCTcJrEmyXUp9wXSmxauOgMFqvzs9Jgt3EQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR12MB2718.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(508600001)(4326008)(36756003)(7416002)(44832011)(54906003)(316002)(66946007)(66556008)(66476007)(86362001)(7406005)(956004)(6486002)(2616005)(2906002)(83380400001)(38350700002)(38100700002)(186003)(5660300002)(8936002)(52116002)(1076003)(7696005)(8676002)(26005)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?4JtmKJWKk6l0BlUGxidwA87nFdQ++XUtG8DhXe/J4vSVP0OkR7T3LuhtibVU?= =?us-ascii?Q?jUCqW9/TGzTP/d8ckJQtrWMLPdVShQxCXCBqi9EQ+qGUcQBSXkCXTbC+rpt8?= =?us-ascii?Q?OOby9q7+n7VNQZDpu64w+nJNz8XvzY1nWWKXldVrHoK+fUGsuzEF+oZSmkd1?= =?us-ascii?Q?OXR7xOsjRpqLZJ+QfqFHG5RqHhn8cjhuE51C71S7jcCfzVs2b/DZXzXgaB5V?= =?us-ascii?Q?8+j4TdshecaA94duvjWDM3943uLAHBnIGY+X4xNBZ308yboQr5wCOVHD27ya?= =?us-ascii?Q?QFJtiKZq+JuixI+R4nIAAM6HXZQQzRF/C5ve1mHoHfwk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TAuJP8fgRjB78D98SjSU7T/u9pgpkyYkAxnSkCov5iZ4o?= =?us-ascii?Q?AWmj8HSbon5KHqPFzBbLoGqhO8nUFDgUtDPIcWVzBHJpJMvSVCBUeBWRvxPh?= =?us-ascii?Q?3X9WnR8lGNYh4Uk0Mb2kxteB?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1bde20be-330a-48cb-7b6b-08d963f3ad3c X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB2718.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Aug 2021 16:00:48.5969 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: uxkdFAa+z3sW9ePyL7RVdF00vj7kXWpz66ufjoJb2UviR56CXNznBXbO6Q5TeafIivNANRNf71K5sMiT7LwxUg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4509 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Tom Lendacky In preparation to support SEV-SNP AP Creation, use a variable that holds the VMSA physical address rather than converting the virtual address. This will allow SEV-SNP AP Creation to set the new physical address that will be used should the vCPU reset path be taken. Signed-off-by: Tom Lendacky --- arch/x86/kvm/svm/sev.c | 5 ++--- arch/x86/kvm/svm/svm.c | 9 ++++++++- arch/x86/kvm/svm/svm.h | 1 + 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c index 81ccad412e55..05f795c30816 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -3619,10 +3619,9 @@ void sev_es_init_vmcb(struct vcpu_svm *svm) /* * An SEV-ES guest requires a VMSA area that is a separate from the - * VMCB page. Do not include the encryption mask on the VMSA physical - * address since hardware will access it using the guest key. + * VMCB page. */ - svm->vmcb->control.vmsa_pa = __pa(svm->vmsa); + svm->vmcb->control.vmsa_pa = svm->vmsa_pa; /* Can't intercept CR register access, HV can't modify CR registers */ svm_clr_intercept(svm, INTERCEPT_CR0_READ); diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index 3ba62f21b113..be820eb999fb 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -1409,9 +1409,16 @@ static int svm_create_vcpu(struct kvm_vcpu *vcpu) svm->vmcb01.ptr = page_address(vmcb01_page); svm->vmcb01.pa = __sme_set(page_to_pfn(vmcb01_page) << PAGE_SHIFT); - if (vmsa_page) + if (vmsa_page) { svm->vmsa = page_address(vmsa_page); + /* + * Do not include the encryption mask on the VMSA physical + * address since hardware will access it using the guest key. + */ + svm->vmsa_pa = __pa(svm->vmsa); + } + svm->guest_state_loaded = false; svm_switch_vmcb(svm, &svm->vmcb01); diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h index 71fe46a778f3..9bf6404142dd 100644 --- a/arch/x86/kvm/svm/svm.h +++ b/arch/x86/kvm/svm/svm.h @@ -199,6 +199,7 @@ struct vcpu_svm { /* SEV-ES support */ struct sev_es_save_area *vmsa; + hpa_t vmsa_pa; bool ghcb_in_use; bool received_first_sipi; unsigned int ap_reset_hold_type; -- 2.17.1