Received: by 2002:ac8:5491:0:b0:40f:fb00:664b with SMTP id h17csp602425qtq; Thu, 10 Aug 2023 10:13:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFznLlDMbmFMZkUsrbrUnloaCzTY34QexgrcU/TRuHJcn6/nOlFlw26+EwdMNdAAUqKUBss X-Received: by 2002:a05:6402:28c:b0:523:37ff:1170 with SMTP id l12-20020a056402028c00b0052337ff1170mr2580368edv.16.1691687588215; Thu, 10 Aug 2023 10:13:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691687588; cv=none; d=google.com; s=arc-20160816; b=wE1sQDzwp3CLBv9Uk+PnrD1DjsrzG3flQoj94Q/07lJ8ZOhugwb8zFogdlgr+JM0/z 8gTxrvsN/4h9cx1VMWeR/uoYHalU4Twy8w4gHpIYKCnIu5x7T/SQiMucaYrwxQez+LfE d87RT2X1d+IB2id034jncFnX8xRc7MBqpLE8p8svypzxL203jdvrSFJRhLnrRl/CnVpy 7GhVlqPMMuJ3+CGttXkEFdO0+1kmlSKByJqtrRcXL6uIkBsAj48w4VvJUYFEQCbnIa0h 28WaCnICJniTYtEA2dZOzm4MRyEuF8prRYFDVOaSDhCBbTvOBLePt5+lIl6td6RYrzzl GdDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8t2VfLawA9ywP02e+pHf7PaApjxnp0yIluklbdk/jFA=; fh=TxLVtSsj0Yk+bstPG6ly04YaPbvjOFEmGNSQ8sZkNQc=; b=PK+9JxyAWCogjlnRayc8pJi9xfryno9Jmfv0+zfToEAw1hsCD2hTWJ1OrXavU/Sxkl wykjz0fvY+quipEhO6Ia9uxT/IBxv6x8wRhTEsUIPBWAoI1lFIwupNaOZfvMCu+WjCWj fXBl51rNAZPq3o2wFTaGRAwzL0HKdYcWlE/1jGrSvgSaIYRGkPEfCHM+rZ/E3i5dN7wH DuvuSi2zHGsVCZkTqR3NE7+xjxwiV1o/BjHU7PSaIriiWJZExN/lIJN/9/nMgLWn+lRK 7tumOQ8EHG69/ynJiDxUDmKHE+hYqeMS4yc1WlZ7HoRUK2Lfhq5aq9uqmHMTv/PPxM8H K20g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=Nh56mQoW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c17-20020aa7c751000000b005232e3160fesi1737385eds.445.2023.08.10.10.12.43; Thu, 10 Aug 2023 10:13:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=Nh56mQoW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236660AbjHJQGL (ORCPT + 99 others); Thu, 10 Aug 2023 12:06:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236389AbjHJQFU (ORCPT ); Thu, 10 Aug 2023 12:05:20 -0400 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7C263AB5; Thu, 10 Aug 2023 09:04:27 -0700 (PDT) Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1bc6535027aso9464095ad.2; Thu, 10 Aug 2023 09:04:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691683466; x=1692288266; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8t2VfLawA9ywP02e+pHf7PaApjxnp0yIluklbdk/jFA=; b=Nh56mQoWzqfv+j317jO12KM0T1Osl7MSV0J2qA5WZbPMZWmzNQOlzYGDzuNrR1v1wa S2stpUK/8rmn8BD/SKgSRhsbHa7KeAYxMWJnj1IOp75oF+bxYMOd8v10P3W0lCJzuMUs /W1ohHneOyTRIiM7hKpxZqpl7zYUVpMbnnqZRMqTFgrs0+y7ZQ1G67zIcR3vU8Z61FEe ZdNZlCLCyW+YyH+aP9Vzy8AOS7oz413uXGqmg8XlUb4jzzdQHWbLkpvkawxS3qf6xizi n/IlnDUYUt5zVYVtvGujbs4/DBZ2cjT2aG3cWT6KjiF8b4XYyX/fiJLEtHSR4J/q0fOX +/jA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691683466; x=1692288266; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8t2VfLawA9ywP02e+pHf7PaApjxnp0yIluklbdk/jFA=; b=RZZf1hs1aTFXkn7LAXo+alwd0RyjxJXUw6UCk89G2ZD5xbLg2Au4ZIExcUlpX1Wg6p +dOwaTjGK4emqfCz94OyZMJRZxO14Aali7EykJmN/pPZpBs8V4R0vnT8USHaW5MRbl77 LD6bhx1Ofe0xParr/Hhoe63nkd1S1rWISTqweeNRdOoYGAawF3MSUUJLtvaEWI5wnegU fGlznACdaQuCfJX0PiR4vaGbc1xbJonVavrYzOHBrcvvqL88TSrGWZ/1T8YhJgyBpZKA SR7IMrkeK/c1hgb7jR8Qh4d2BpWqFGbat5Q6GxITMmlQnoptyziLMXTQMmarNltgEkdj hNOg== X-Gm-Message-State: AOJu0YzuC1vRhpRV4+q5hgM+DDc3RHWCLqqvjVay/jSk0mrqkYwzrRJE Pn+4UXRJfqo8Vfbk1LQ7Me0= X-Received: by 2002:a17:903:1c5:b0:1b9:e81f:fb08 with SMTP id e5-20020a17090301c500b001b9e81ffb08mr3293438plh.55.1691683465813; Thu, 10 Aug 2023 09:04:25 -0700 (PDT) Received: from ubuntu-Virtual-Machine.corp.microsoft.com ([2001:4898:80e8:0:c620:2003:6c97:8057]) by smtp.gmail.com with ESMTPSA id r4-20020a1709028bc400b001b895a17429sm1948821plo.280.2023.08.10.09.04.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Aug 2023 09:04:24 -0700 (PDT) From: Tianyu Lan To: kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, daniel.lezcano@linaro.org, arnd@arndb.de, michael.h.kelley@microsoft.com Cc: Tianyu Lan , linux-arch@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, vkuznets@redhat.com, Michael Kelley Subject: [PATCH V5 3/8] x86/hyperv: Mark Hyper-V vp assist page unencrypted in SEV-SNP enlightened guest Date: Thu, 10 Aug 2023 12:04:06 -0400 Message-Id: <20230810160412.820246-4-ltykernel@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230810160412.820246-1-ltykernel@gmail.com> References: <20230810160412.820246-1-ltykernel@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tianyu Lan hv vp assist page needs to be shared between SEV-SNP guest and Hyper-V. So mark the page unencrypted in the SEV-SNP guest. Reviewed-by: Michael Kelley Signed-off-by: Tianyu Lan --- arch/x86/hyperv/hv_init.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c index 0fd0f82c4f07..547ebf6a03bc 100644 --- a/arch/x86/hyperv/hv_init.c +++ b/arch/x86/hyperv/hv_init.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -106,8 +107,21 @@ static int hv_cpu_init(unsigned int cpu) * in hv_cpu_die(), otherwise a CPU may not be stopped in the * case of CPU offlining and the VM will hang. */ - if (!*hvp) + if (!*hvp) { *hvp = __vmalloc(PAGE_SIZE, GFP_KERNEL | __GFP_ZERO); + + /* + * Hyper-V should never specify a VM that is a Confidential + * VM and also running in the root partition. Root partition + * is blocked to run in Confidential VM. So only decrypt assist + * page in non-root partition here. + */ + if (*hvp && hv_isolation_type_en_snp()) { + WARN_ON_ONCE(set_memory_decrypted((unsigned long)(*hvp), 1)); + memset(*hvp, 0, PAGE_SIZE); + } + } + if (*hvp) msr.pfn = vmalloc_to_pfn(*hvp); -- 2.25.1