From patchwork Wed Feb 1 10:37:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Perret X-Patchwork-Id: 13124133 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 56960C05027 for ; Wed, 1 Feb 2023 10:39:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID: References:Mime-Version:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=G+fM7pFZNd382BfXKB4T3nahI+52ayFlO4jU55iXlSY=; b=i6kv7XF+6AAVJJ4OICknICO1C4 Xny29Cc8jbG8cSPkIBmT17Zqs3gneVpjLqjdp+Tv48JuD8Z4XrY3OrvYvOYHo4jAwwg1ZVr43wCrG Hql5IM7g9Fv7+AG6OCiJ7twZJ7OoXixrQiyRVZD+BY9pMSk94g0x4A+N23HB2sO/5eGop1GsnDLWq SJWTJyjP19gHd+sOJeDT0MMmfC09bGE0UQN3LHqRx81n8fp+JyWVL4jJaFfHjk5pKMYk5uxUtzmRu l70ovDUmXg2k89k3hcSn18hA4pH/N8k8XR1sko5ZTtaZLkD1B+WyVhM9vxPpCUeg9Zg57aZ7PuKey wSbaY93Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNAVh-00BHMH-Ih; Wed, 01 Feb 2023 10:38:37 +0000 Received: from mail-ej1-x649.google.com ([2a00:1450:4864:20::649]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNAVI-00BHFg-9i for linux-arm-kernel@lists.infradead.org; Wed, 01 Feb 2023 10:38:13 +0000 Received: by mail-ej1-x649.google.com with SMTP id m21-20020a1709060d9500b0088ca6c7af4cso3089322eji.21 for ; Wed, 01 Feb 2023 02:38:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Nd0FeyMlG74m/nm4XHJil0DTW7Kcn6gyhw0b15r3ih4=; b=VtqJzQK9sDGnSBOg9QMtSeyNfUP3G5EGSiBFDu5xjYOD0Uh5vmcmxL62Smu27C/dLn tGW60izEIgX7nRCyqz+Vu2uRkJm5JXvaOw8QvBN9CudqLuhuLdMXChD9+PquNW/OXjhj iGpXQZLw5mdFNVyqZ66l5DfQ8DO40a5W1cSAyy28AyyckjjBb6Uf8gxjVKDIZhdRUgJt D5TNbzz3Y96Mafu24UqZCFrSDCud7a/BoBgKrDMUHFxbU6MySQJXiJ4MnwxKMo5X4STE RG+EHkAzMugg355mzM+h7RrBHvoQbI0GCpqL8eZupXxeT0q5SM/utc3i1JwRxfjGBoS6 1fww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Nd0FeyMlG74m/nm4XHJil0DTW7Kcn6gyhw0b15r3ih4=; b=nq5MCrsBcDYDYp28+IT0bhX+GoGQplqmQkZGxzPJge1XDrEI/wG6NNtICKSfv1bDj/ A5ud6PeB3pDAbWMxWQIa9T1OAy3yNV/Eux3kXz2PxOQ/nTpZ84A8NgfixXCjsqBftcEQ Durw2+oXjme1IGg7Yz9P4bn+fosOY+Nz0tkKVkiEL+TcwOgmrB5Afr/qXyFLm3d+3o8L 7u+3kkKJRgkbDSH5V8JM523Bs0eTBfGGO8+9Kcsx6hxG8Kf5BY/Yfme8+STQKjXsfOA9 iO+Kg/9QCp8r3hqcJXz1iIO17JXbU9BAi5EddijZicC9mNE0k00qIJGSoNp6gbfvwDf9 CIrw== X-Gm-Message-State: AO0yUKVqnIjBgpYkJago7EGERU2AJnIrhSLop8+ahXPGy5cEaWu4YFsy LMuVLwZsvc3ZlNBMoWtOSV4MT8wxBbIt X-Google-Smtp-Source: AK7set8pUWH/EIRKqNBELwGkOXfTUro9UW9voB6iL5jldWiapgA0tzxfry3rHjCWX353kPSCNlq0/jQ1X/U8 X-Received: from big-boi.c.googlers.com ([fda3:e722:ac3:cc00:31:98fb:c0a8:129]) (user=qperret job=sendgmr) by 2002:a17:906:1781:b0:878:7d2c:6ba4 with SMTP id t1-20020a170906178100b008787d2c6ba4mr572762eje.42.1675247888973; Wed, 01 Feb 2023 02:38:08 -0800 (PST) Date: Wed, 1 Feb 2023 10:37:53 +0000 In-Reply-To: <20230201103755.1398086-1-qperret@google.com> Mime-Version: 1.0 References: <20230201103755.1398086-1-qperret@google.com> X-Mailer: git-send-email 2.39.1.456.gfc5497dd1b-goog Message-ID: <20230201103755.1398086-4-qperret@google.com> Subject: [PATCH 3/4] KVM: arm64: Use sanitized values in __check_override in nVHE From: Quentin Perret To: Catalin Marinas , Will Deacon , Marc Zyngier , James Morse , Suzuki K Poulose , Oliver Upton , Zenghui Yu , Mark Brown Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev, kvmarm@lists.cs.columbia.edu, kernel-team@android.com, Quentin Perret X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230201_023812_359222_667C1111 X-CRM114-Status: UNSURE ( 9.82 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The nVHE EL2 code has access to sanitized values of certain idregs, so use them directly from __check_override instead of the *_override variants. Signed-off-by: Quentin Perret --- arch/arm64/include/asm/el2_setup.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/arch/arm64/include/asm/el2_setup.h b/arch/arm64/include/asm/el2_setup.h index fb7d04b81033..1cc29960fcdb 100644 --- a/arch/arm64/include/asm/el2_setup.h +++ b/arch/arm64/include/asm/el2_setup.h @@ -196,6 +196,7 @@ __init_el2_nvhe_prepare_eret .endm +#ifndef __KVM_NVHE_HYPERVISOR__ // This will clobber tmp1 and tmp2, and expect tmp1 to contain // the id register value as read from the HW .macro __check_override idreg, fld, width, pass, fail, tmp1, tmp2 @@ -219,6 +220,19 @@ mrs \tmp1, \idreg\()_el1 __check_override \idreg \fld 4 \pass \fail \tmp1 \tmp2 .endm +#else +// This will clobber tmp +.macro __check_override idreg, fld, width, pass, fail, tmp, ignore + ldr_l \tmp, \idreg\()_el1_sys_val + ubfx \tmp, \tmp, #\fld, #\width + cbnz \tmp, \pass + b \fail +.endm + +.macro check_override idreg, fld, pass, fail, tmp, ignore + __check_override \idreg \fld 4 \pass \fail \tmp \ignore +.endm +#endif .macro finalise_el2_state check_override id_aa64pfr0, ID_AA64PFR0_EL1_SVE_SHIFT, .Linit_sve_\@, .Lskip_sve_\@, x1, x2