Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1880148pxb; Mon, 18 Jan 2021 02:20:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJxUaC9yAO+0A3CRHnszjLqrQ4IBaU6J7hXOyqMcFs4FGGHoND/RyybSgXc6qRPcpiuZg1BE X-Received: by 2002:a17:906:950e:: with SMTP id u14mr2706564ejx.342.1610965206050; Mon, 18 Jan 2021 02:20:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610965206; cv=none; d=google.com; s=arc-20160816; b=vUDtkJPJkcD1QdawANckjHmUtz8miLI96RkKDyRrv0ZY1/ZzoFJupRqSrY4cpMBA0U k+YeWorZlIbZpLZkK/UpGtKLPiwaXuDJTGKY9IRjjJKGZKzX1SH+vXBOvUf3lKTjVJyH FlduG/eJVJq+t/TnLzp2OuXunJJID3INg1SuIoG/qQPcnz82+/wtnb+UZwW2on2qgcfd WXpntxT79eXARNO3skXyivLjZcz9/tMznei2NI/nNrHsgu3Hk4MtC91Ip5xVm9noRiWr LZz6+klHXm5C8tqyP9nUrlkRU77iE9DILvmtx/pj8fRSfImu972Vf/EAE1qRaZJezgn/ vk2A== 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; bh=VXCvYaWbxyn5VRip3FzYDNmgCypfcIgRWzfXf3p7fY0=; b=O5KY3BMw3zLc9gLxl3u5HZRO1dZzYUxysMj98YXI6Vm+rNHR0eMI28USBMoC1u1OxL MqUAlQJSUDnW4TYppKNbbO23Xml8ndUG2dliojQvSSb4TQZvxRL56bF0zaIGfyhMRHfy pGn5RH69H5Yzn/3H41RNO0H+yBprkQh88OeVtXxuOpeBizOaVGfhUdr0sXlaKwNTVHd1 PxGamao32wn+HUYGhT4whA7Iqcvn2l6N1mBZ42H0CfXZ5I1rta9vxbKd/zpN0enmPqpI zJYh5Bm044W77MW81kB1r6XjecKynpUaYWEROvN7GNAn3rqckSOSDABKKxHKzI/Kgz7b T3BA== 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l22si621328edr.554.2021.01.18.02.19.43; Mon, 18 Jan 2021 02:20:06 -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; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389508AbhARKFD (ORCPT + 99 others); Mon, 18 Jan 2021 05:05:03 -0500 Received: from mail.kernel.org ([198.145.29.99]:36998 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388289AbhARJsb (ORCPT ); Mon, 18 Jan 2021 04:48:31 -0500 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B680F2253A; Mon, 18 Jan 2021 09:46:05 +0000 (UTC) Received: from 78.163-31-62.static.virginmediabusiness.co.uk ([62.31.163.78] helo=why.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94) (envelope-from ) id 1l1R6q-008RhD-02; Mon, 18 Jan 2021 09:46:04 +0000 From: Marc Zyngier To: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org Cc: Catalin Marinas , Will Deacon , Mark Rutland , David Brazdil , Alexandru Elisei , Ard Biesheuvel , Jing Zhang , Ajay Patil , Prasad Sodagudi , Srinivas Ramana , James Morse , Julien Thierry , Suzuki K Poulose , kernel-team@android.com Subject: [PATCH v4 06/21] arm64: Move VHE-specific SPE setup to mutate_to_vhe() Date: Mon, 18 Jan 2021 09:45:18 +0000 Message-Id: <20210118094533.2874082-7-maz@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210118094533.2874082-1-maz@kernel.org> References: <20210118094533.2874082-1-maz@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 62.31.163.78 X-SA-Exim-Rcpt-To: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com, dbrazdil@google.com, alexandru.elisei@arm.com, ardb@kernel.org, jingzhangos@google.com, pajay@qti.qualcomm.com, psodagud@codeaurora.org, sramana@codeaurora.org, james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com, kernel-team@android.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There isn't much that a VHE kernel needs on top of whatever has been done for nVHE, so let's move the little we need to the VHE stub (the SPE setup), and drop the init_el2_state macro. No expected functional change. Signed-off-by: Marc Zyngier --- arch/arm64/kernel/hyp-stub.S | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/arch/arm64/kernel/hyp-stub.S b/arch/arm64/kernel/hyp-stub.S index 52b29c54a9f7..59820f9b8522 100644 --- a/arch/arm64/kernel/hyp-stub.S +++ b/arch/arm64/kernel/hyp-stub.S @@ -89,9 +89,6 @@ SYM_CODE_START_LOCAL(mutate_to_vhe) msr hcr_el2, x0 isb - // Doesn't do much on VHE, but still, worth a shot - init_el2_state vhe - // Use the EL1 allocated stack, per-cpu offset mrs x0, sp_el1 mov sp, x0 @@ -104,6 +101,31 @@ SYM_CODE_START_LOCAL(mutate_to_vhe) mrs_s x0, SYS_VBAR_EL12 msr vbar_el1, x0 + // Fixup SPE configuration, if supported... + mrs x1, id_aa64dfr0_el1 + ubfx x1, x1, #ID_AA64DFR0_PMSVER_SHIFT, #4 + mov x2, xzr + cbz x1, skip_spe + + // ... and not owned by EL3 + mrs_s x0, SYS_PMBIDR_EL1 + and x0, x0, #(1 << SYS_PMBIDR_EL1_P_SHIFT) + cbnz x0, skip_spe + + // Let the SPE driver in control of the sampling + mrs_s x0, SYS_PMSCR_EL1 + bic x0, x0, #(1 << SYS_PMSCR_EL2_PCT_SHIFT) + bic x0, x0, #(1 << SYS_PMSCR_EL2_PA_SHIFT) + msr_s SYS_PMSCR_EL1, x0 + mov x2, #MDCR_EL2_TPMS + +skip_spe: + // For VHE, use EL2 translation and disable access from EL1 + mrs x0, mdcr_el2 + bic x0, x0, #(MDCR_EL2_E2PB_MASK << MDCR_EL2_E2PB_SHIFT) + orr x0, x0, x2 + msr mdcr_el2, x0 + // Transfer the MM state from EL1 to EL2 mrs_s x0, SYS_TCR_EL12 msr tcr_el1, x0 -- 2.29.2