Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1572986pxb; Wed, 4 Nov 2020 12:36:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJwMeDDVMbGdL0Mntv4AGxYUkZ65kiEeDGchmlNIgsVc4ALkhk40UFbYiWe1A4E4JB5B4yg+ X-Received: by 2002:aa7:d514:: with SMTP id y20mr24179137edq.384.1604522192988; Wed, 04 Nov 2020 12:36:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604522192; cv=none; d=google.com; s=arc-20160816; b=BcrCFmhh3EDjcehjX6BLut6cUCD+pNaWugG6lPnLl7zvjtKecqR6ThHM+064k2BwJL ekNUiQNaGlIgC3IU+7LEuFvtDSnEksb+f0SQSceXguozaBK8FQnQ1J4zCHvD0B+v0kkj gm8r6OUgKmdRk0TLq6TbrEmGIidrNiTSyQm/3nendBNETQstc+zqccP/CNeNjA64h0Es qDTlu7LJIDa7OZwlJIrYjQr0vjqaoqesTYPOaSG46WQ5a2ErDrDk89D58YFVe+Vq09M1 PUgyoxMiSROszTt3saI7d8bza+s8dd4SrDaDb/w9IcQeFFY2iVsgzuenKq6BDaNd6p+6 079w== 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=iZCBnLMJdYcxZwBzQ3Sarf0ddb9E9I/tpQ6NvhqLTsI=; b=CcPrnIWU4hEzttsZ8vatLMbPQDE7zw0DIUrLTG/GOXBIJdRxu+1aidVM+Jkl026R4z ToIq/s5dlkH+Keqry9yVYeqaatswFwCC3qX13+JtClYgWZALyIHXrB0YeZ7t4fx+ryCn TBOtuo6UMesraI4/AXmsMMhfa6kRJ6NMmqylql93NWkFMoYD3yu0z9eKYuMNTBIXAN4j QZZZq6Ggh8Ddv7pDHiBWkJmmfqkpdVR7HG5SS8GS23NU4BOsM7/pfZO5fL6NH6n745lE GTY+Lrp2m1IGbzMLsbOYC9xEn6DfZGCDaVb9mG9JDnt8JSixEbzjs+FS0f5RmKDUPTfw bWSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=B4IhEM6i; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h1si2064374ejx.541.2020.11.04.12.36.10; Wed, 04 Nov 2020 12:36:32 -0800 (PST) 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; dkim=pass header.i=@google.com header.s=20161025 header.b=B4IhEM6i; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731063AbgKDShg (ORCPT + 99 others); Wed, 4 Nov 2020 13:37:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732605AbgKDShe (ORCPT ); Wed, 4 Nov 2020 13:37:34 -0500 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C81ACC0613D3 for ; Wed, 4 Nov 2020 10:37:33 -0800 (PST) Received: by mail-wr1-x443.google.com with SMTP id e6so5906070wro.1 for ; Wed, 04 Nov 2020 10:37:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=iZCBnLMJdYcxZwBzQ3Sarf0ddb9E9I/tpQ6NvhqLTsI=; b=B4IhEM6i7eYAD2ymU3gP34oS4vn1E/wZkt1PdaiPM5/5CtTpRosOvwsKQKo0X96cCK 0+g8w1fiydBxSAvZustLDS0jWbYdNwVoVeSGiVp01VErE+3NmXu2Zguj4zhDd3RQwoNG en6FWwAw0dLaqo1BuTfum7Ta4FxBg0BjZWLF6bqxR53vkiKPlHv0os4fdHkCfVcSOUha CL9qYevzyEmHuWS9pBv5RwzPROVRKDWww8V+k967+KldgQKur4GRkaO8J8q5SOBxRSpK YvVewWO1VZib5H/HpCQ7HbmNXpRdZWPNttE3mKM8sUogeVrex2BX1GvjsLxVqnF1JotD ALOQ== 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=iZCBnLMJdYcxZwBzQ3Sarf0ddb9E9I/tpQ6NvhqLTsI=; b=aQA3WNywWJ8TxToqt1q6uumCuh5CxX00ZpZDXqC3jNXeFnEvOLCfCEputPDpkx1DZT mfrjdT6fFCdxkFNFrfSTCbt1/DL+cYSf1hVpRP6kz4cZF1ZzhK1nc75vx4Ld1iJnbLT/ D/bA3lNIMW00fISVEhMoy6lwuuzUGW9hiiWGtVlpG1MpD8n5umeEnc4tK22y4BIbV/6o ppYNdDRBFdwSPHBeMIt99zPMoe6GCsIt4cnLFH78wLce3zWvZJkLSXnGZkrKxFWR4eNs Tw1AX2W3g5XuVoudf+on4MWJT5NVMf26ycmAIfbrxCF5tK89GSG8X0qVWiSN1CVnvsqC v/Dw== X-Gm-Message-State: AOAM533e7/qbjH3HM58B9jc4wS8/txCYWM6R2yTl0trZNGBFdvHgGN/F YE2AQLFNdpXUUen/8OkFbVWKMQ== X-Received: by 2002:adf:fe48:: with SMTP id m8mr33208177wrs.127.1604515052352; Wed, 04 Nov 2020 10:37:32 -0800 (PST) Received: from localhost ([2a01:4b00:8523:2d03:c8d2:30f2:53c6:bc2]) by smtp.gmail.com with ESMTPSA id r10sm3396829wmg.16.2020.11.04.10.37.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 04 Nov 2020 10:37:31 -0800 (PST) From: David Brazdil To: kvmarm@lists.cs.columbia.edu Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Marc Zyngier , James Morse , Julien Thierry , Suzuki K Poulose , Catalin Marinas , Will Deacon , Dennis Zhou , Tejun Heo , Christoph Lameter , Mark Rutland , Lorenzo Pieralisi , Quentin Perret , Andrew Scull , kernel-team@android.com, David Brazdil Subject: [RFC PATCH 25/26] kvm: arm64: Trap host SMCs Date: Wed, 4 Nov 2020 18:36:29 +0000 Message-Id: <20201104183630.27513-26-dbrazdil@google.com> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201104183630.27513-1-dbrazdil@google.com> References: <20201104183630.27513-1-dbrazdil@google.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org While nVHE KVM is installed, start trapping all host SMCs. By default, these are simply forwarded to EL3, but PSCI SMCs are validated first. Create new constant HCR_HOST_NVHE_STUB_FLAGS with the old set of HCR flags to use before the nVHE vector is installed or when switching back to stub vector. Extend HCR_HOST_NVHE_FLAGS to contain HCR_TSC. Set HCR_EL2 to it before installing nVHE vector. Signed-off-by: David Brazdil --- arch/arm64/include/asm/kvm_arm.h | 3 ++- arch/arm64/kernel/head.S | 2 +- arch/arm64/kvm/hyp/nvhe/hyp-init.S | 6 ++++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/kvm_arm.h b/arch/arm64/include/asm/kvm_arm.h index 64ce29378467..04b862955f32 100644 --- a/arch/arm64/include/asm/kvm_arm.h +++ b/arch/arm64/include/asm/kvm_arm.h @@ -79,7 +79,8 @@ HCR_AMO | HCR_SWIO | HCR_TIDCP | HCR_RW | HCR_TLOR | \ HCR_FMO | HCR_IMO | HCR_PTW ) #define HCR_VIRT_EXCP_MASK (HCR_VSE | HCR_VI | HCR_VF) -#define HCR_HOST_NVHE_FLAGS (HCR_RW | HCR_API | HCR_APK | HCR_ATA) +#define HCR_HOST_NVHE_STUB_FLAGS (HCR_RW | HCR_API | HCR_APK | HCR_ATA) +#define HCR_HOST_NVHE_FLAGS (HCR_HOST_NVHE_STUB_FLAGS | HCR_TSC) #define HCR_HOST_VHE_FLAGS (HCR_RW | HCR_TGE | HCR_E2H) /* TCR_EL2 Registers bits */ diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S index e7270b63abed..ea17413a04e0 100644 --- a/arch/arm64/kernel/head.S +++ b/arch/arm64/kernel/head.S @@ -522,7 +522,7 @@ SYM_FUNC_START(el2_setup) #endif SYM_INNER_LABEL(el2_setup_nvhe, SYM_L_LOCAL) - mov_q x0, HCR_HOST_NVHE_FLAGS + mov_q x0, HCR_HOST_NVHE_STUB_FLAGS msr hcr_el2, x0 isb diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-init.S b/arch/arm64/kvm/hyp/nvhe/hyp-init.S index dd297a1a8f82..97684deba6c1 100644 --- a/arch/arm64/kvm/hyp/nvhe/hyp-init.S +++ b/arch/arm64/kvm/hyp/nvhe/hyp-init.S @@ -88,6 +88,10 @@ SYM_CODE_END(__kvm_hyp_init) * x0: struct kvm_nvhe_init_params PA */ SYM_CODE_START(___kvm_hyp_init) + mov_q x1, HCR_HOST_NVHE_FLAGS + msr hcr_el2, x1 + isb + ldr x1, [x0, #NVHE_INIT_TPIDR_EL2] msr tpidr_el2, x1 @@ -220,6 +224,8 @@ reset: bic x5, x5, x6 // Clear SCTL_M and etc pre_disable_mmu_workaround msr sctlr_el2, x5 + mov_q x5, HCR_HOST_NVHE_STUB_FLAGS + msr hcr_el2, x5 isb /* Install stub vectors */ -- 2.29.1.341.ge80a0c044ae-goog