Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp445425pxb; Fri, 16 Apr 2021 09:19:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwRXebVswKL7+lM4QYNFWLMa3ks9i7XnhakEnmDY7MVL1tJ+ShDhDZCbF6xC9fwhhrXz5jU X-Received: by 2002:aa7:da18:: with SMTP id r24mr9691332eds.198.1618589942726; Fri, 16 Apr 2021 09:19:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618589942; cv=none; d=google.com; s=arc-20160816; b=QOGH7JpLht8avuKL3aw2/NYRjEdNrVby6b4+hk5PYTTG4dwPszX8d61Rs75FSG8wRB T8PWC49SVbS0Aw7sEjozae4/EQSRanGeXxXmbw23lw+xqVPn1Jlhb3ALup/M+Sa2txdB bqpVQUPvZbMHr0nQIOpkbS7YwOltjS6BwhcK88CC235ALm+I/YWVxLCFZvVqa2Ng29pK QxElt7pML/ujh9yhzvcyGJuwc9HzHvTItOQC1P14Jxp7gQngLHu+FhqyBjuRWIEQVy09 udAvDODssv2EqDnvRLrMZ/9dljHiHKv6jIVooiFWj0aJW4vd2UCHQjdRkKjlTz5QMt8H PqFw== 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 :ironport-sdr:ironport-sdr; bh=NRukntRqIH9oIHyEudEHW0ud1MS+kv1ItAvshsRDqdY=; b=Cs3rTA8yVrQJX9XMN6xF1slqhpEa6wdNsigzXehfIplaIWYvmFRKZBVDDGonS3iydU DwjSm/Fvn517iNpDpYQ6XAq0WQ1sK5+NnOVbh8Yfz7vmwefTZnjLMHu36uPWosxV9+nv o7tip2e709vpkQJK7xfQmW6qzXtH27IZ7lNyB/R29d8sVsVKc8aRNd8n/dd6Q9Z2cn88 xDLOD/YQglddQrbabNeduUbhIeDQ0Y5425NiZB9CwqG9UQly4lefYhVPvQ/bt7I86Hh6 kjZv6rgTJYyMQec15H2ZUP4JQfRikJi+mhqNOJTIBDk3BvHzmc8kZf3V3NQPKvHAXjp8 owTQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n17si5155895ejb.145.2021.04.16.09.18.39; Fri, 16 Apr 2021 09:19:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243801AbhDPPmX (ORCPT + 99 others); Fri, 16 Apr 2021 11:42:23 -0400 Received: from mga09.intel.com ([134.134.136.24]:4092 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343989AbhDPPmL (ORCPT ); Fri, 16 Apr 2021 11:42:11 -0400 IronPort-SDR: E9YfRotjPqIUZrKWWV/D64DLh8dwSCmaGzDza6oSmpdTNUauWpp8/Exd1T9XjguHtJEZIEQkFc tPMJ9eFMHzwQ== X-IronPort-AV: E=McAfee;i="6200,9189,9956"; a="195169145" X-IronPort-AV: E=Sophos;i="5.82,226,1613462400"; d="scan'208";a="195169145" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2021 08:41:42 -0700 IronPort-SDR: X85JOUNwgOD0cizzR5uDukCMiBRDxeHXnklH8hj1bphP48a0OlK0J470EynoTDSDOOq7s8sGWp THnhFtf3GCoQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,226,1613462400"; d="scan'208";a="384352246" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga006.jf.intel.com with ESMTP; 16 Apr 2021 08:41:37 -0700 Received: by black.fi.intel.com (Postfix, from userid 1000) id 0A0DB279; Fri, 16 Apr 2021 18:41:50 +0300 (EEST) From: "Kirill A. Shutemov" To: Dave Hansen , Andy Lutomirski , Peter Zijlstra , Sean Christopherson , Jim Mattson Cc: David Rientjes , "Edgecombe, Rick P" , "Kleen, Andi" , "Yamahata, Isaku" , Erdem Aktas , Steve Rutherford , Peter Gonda , David Hildenbrand , x86@kernel.org, kvm@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Kirill A. Shutemov" Subject: [RFCv2 06/13] x86/realmode: Share trampoline area if KVM memory protection enabled Date: Fri, 16 Apr 2021 18:40:59 +0300 Message-Id: <20210416154106.23721-7-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210416154106.23721-1-kirill.shutemov@linux.intel.com> References: <20210416154106.23721-1-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If KVM memory protection is active, the trampoline area will need to be in shared memory. Signed-off-by: Kirill A. Shutemov --- arch/x86/realmode/init.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c index 22fda7d99159..f3b54b5da693 100644 --- a/arch/x86/realmode/init.c +++ b/arch/x86/realmode/init.c @@ -10,6 +10,7 @@ #include #include #include +#include struct real_mode_header *real_mode_header; u32 *trampoline_cr4_features; @@ -75,11 +76,11 @@ static void __init setup_real_mode(void) base = (unsigned char *)real_mode_header; /* - * If SME is active, the trampoline area will need to be in - * decrypted memory in order to bring up other processors + * If SME or KVM memory protection is active, the trampoline area will + * need to be in decrypted memory in order to bring up other processors * successfully. This is not needed for SEV. */ - if (sme_active()) + if (sme_active() || kvm_mem_protected()) set_memory_decrypted((unsigned long)base, size >> PAGE_SHIFT); memcpy(base, real_mode_blob, size); -- 2.26.3