From patchwork Wed Apr 14 14:49:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tianyu Lan X-Patchwork-Id: 12203027 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=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 81963C433ED for ; Wed, 14 Apr 2021 14:50:30 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0F0AD611EE for ; Wed, 14 Apr 2021 14:50:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0F0AD611EE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 51F986B0070; Wed, 14 Apr 2021 10:50:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3E5466B0071; Wed, 14 Apr 2021 10:50:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0AE3F6B0072; Wed, 14 Apr 2021 10:50:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0253.hostedemail.com [216.40.44.253]) by kanga.kvack.org (Postfix) with ESMTP id E31916B0070 for ; Wed, 14 Apr 2021 10:50:27 -0400 (EDT) Received: from smtpin33.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 92C4F18024CE7 for ; Wed, 14 Apr 2021 14:50:27 +0000 (UTC) X-FDA: 78031258494.33.B9CDB6E Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) by imf18.hostedemail.com (Postfix) with ESMTP id 191652000249 for ; Wed, 14 Apr 2021 14:50:27 +0000 (UTC) Received: by mail-pl1-f170.google.com with SMTP id e2so5932398plh.8 for ; Wed, 14 Apr 2021 07:50:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Iz6kQKmaAStJz2j939/tUEj2NIuTRDYIEtDill+C7IA=; b=D2taYVTe0z905CX87qYISBKtJJpcQncx/+jlzFtm+dqJ1FQrZXjYZ180oWEO28Y5y7 hlj6+yRPwjy4zDBc0qTSTOI4n3R9lkebe1U3i+D2ckp00qt3mqEM+7XERpL1KMDNXJn4 7wjSfLucr+uk3vZczBhcDhkKTijEPUzFZEFYwB9fuw000bOFSdkhpR5X452OAoNmDZSB 6R6DV6d3gKGUbhWxGXR8WhVAEQ7hP4x7wYAWlA87Le8gNxzh+cepaPjZjUSKkvMtMjhr s43ZTcJK8Kv06ThNFTuC2wlW97YulfZnT+41LKU+KQPRORDoo8Bg8JSixilt/nL1ihKW mQ+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Iz6kQKmaAStJz2j939/tUEj2NIuTRDYIEtDill+C7IA=; b=bVNX5k+f9F4oYRimyAlBdLEGZp6ZeCNlyn5IPv+HbIVNjieg1FuaoemyOt2QQsK3OZ VCNr8ik7osl8B5luFpm+0r5THkGTdpUXsNxKyYaO9vwLqnG+ps84eiZhOIv1zLgPyRM2 dCMZPx/xch1vzxx+wcukPCP0lsOxH2JBhfqP6y6YgfRcVXRHcQ9gtseWyXYDYPenCCd3 3V8V3B0ihj0bp4HWsH+T7PxLnM/Wqs/n34C98ba3Hc7J27uW15jHP3HRAyry5IBCRVIC p5keRfMOnltg9tvI/j8WqqgZQMAxwRPjejMMqlB3DarCBLwmsI82dCNy23434TRbhhvA /76w== X-Gm-Message-State: AOAM53255gXO/+6wpT5Jp0cbY6awA1iSsmZuXimubSmASX0CiiU3Hy1d WnXm78OOZJWV2qJzr1wL+Og= X-Google-Smtp-Source: ABdhPJwoWQUtM+Kmo2QdePpZgHK8I2K8arUG2KPZ/TVvHugCh22W4iDEwoDeLZUiglDRWNvFY5wZBA== X-Received: by 2002:a17:90a:bf17:: with SMTP id c23mr4103212pjs.12.1618411826429; Wed, 14 Apr 2021 07:50:26 -0700 (PDT) Received: from ubuntu-Virtual-Machine.corp.microsoft.com ([2001:4898:80e8:35:ebad:12c1:f579:e332]) by smtp.gmail.com with ESMTPSA id w67sm17732522pgb.87.2021.04.14.07.50.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Apr 2021 07:50:26 -0700 (PDT) From: Tianyu Lan To: kys@microsoft.com, haiyangz@microsoft.com, sthemmin@microsoft.com, wei.liu@kernel.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, x86@kernel.org, hpa@zytor.com, arnd@arndb.de, akpm@linux-foundation.org, gregkh@linuxfoundation.org, konrad.wilk@oracle.com, hch@lst.de, m.szyprowski@samsung.com, robin.murphy@arm.com, joro@8bytes.org, will@kernel.org, davem@davemloft.net, kuba@kernel.org, jejb@linux.ibm.com, martin.petersen@oracle.com Cc: Tianyu Lan , iommu@lists.linux-foundation.org, linux-arch@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-scsi@vger.kernel.org, netdev@vger.kernel.org, vkuznets@redhat.com, thomas.lendacky@amd.com, brijesh.singh@amd.com, sunilmut@microsoft.com Subject: [Resend RFC PATCH V2 02/12] x86/HV: Initialize shared memory boundary in Isolation VM Date: Wed, 14 Apr 2021 10:49:35 -0400 Message-Id: <20210414144945.3460554-3-ltykernel@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210414144945.3460554-1-ltykernel@gmail.com> References: <20210414144945.3460554-1-ltykernel@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 191652000249 X-Stat-Signature: inpqm779juijnh9448sk3wfagjqy53wn Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf18; identity=mailfrom; envelope-from=""; helo=mail-pl1-f170.google.com; client-ip=209.85.214.170 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1618411827-449766 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Tianyu Lan Hyper-V exposes shared memory boundary via cpuid HYPERV_ CPUID_ISOLATION_CONFIG and store it in the shared_gpa_ boundary of ms_hyperv struct. This prepares to share memory with host for AMD SEV SNP guest. Signed-off-by: Tianyu Lan --- arch/x86/kernel/cpu/mshyperv.c | 2 ++ include/asm-generic/mshyperv.h | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c index e88bc296afca..aeafd4017c89 100644 --- a/arch/x86/kernel/cpu/mshyperv.c +++ b/arch/x86/kernel/cpu/mshyperv.c @@ -328,6 +328,8 @@ static void __init ms_hyperv_init_platform(void) if (ms_hyperv.features_b & HV_ISOLATION) { ms_hyperv.isolation_config_a = cpuid_eax(HYPERV_CPUID_ISOLATION_CONFIG); ms_hyperv.isolation_config_b = cpuid_ebx(HYPERV_CPUID_ISOLATION_CONFIG); + ms_hyperv.shared_gpa_boundary = + (u64)1 << ms_hyperv.shared_gpa_boundary_bits; pr_info("Hyper-V: Isolation Config: Group A 0x%x, Group B 0x%x\n", ms_hyperv.isolation_config_a, ms_hyperv.isolation_config_b); diff --git a/include/asm-generic/mshyperv.h b/include/asm-generic/mshyperv.h index c6f4c5c20fb8..b73e201abc70 100644 --- a/include/asm-generic/mshyperv.h +++ b/include/asm-generic/mshyperv.h @@ -34,8 +34,19 @@ struct ms_hyperv_info { u32 max_vp_index; u32 max_lp_index; u32 isolation_config_a; - u32 isolation_config_b; + union + { + u32 isolation_config_b; + struct { + u32 cvm_type : 4; + u32 Reserved11 : 1; + u32 shared_gpa_boundary_active : 1; + u32 shared_gpa_boundary_bits : 6; + u32 Reserved12 : 20; + }; + }; void __percpu **ghcb_base; + u64 shared_gpa_boundary; }; extern struct ms_hyperv_info ms_hyperv;