From patchwork Mon Oct 10 14:27:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 613757 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2030746pvb; Mon, 10 Oct 2022 08:03:04 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5BAQEDO2fooAtvT03FTnSRD8phjS/5dftMevNQErahHHeuvqw9g2e0PWONULymJCl0hkup X-Received: by 2002:a05:6000:50a:b0:225:210c:a7e4 with SMTP id a10-20020a056000050a00b00225210ca7e4mr11795278wrf.704.1665414183853; Mon, 10 Oct 2022 08:03:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665414183; cv=none; d=google.com; s=arc-20160816; b=AynX2vwinIDq0vkbW9gUyNUIUNGSXnHxjj/XjtrO6aRXgoQ1rLECAl59YW4sgfkYj7 Qh05DK2dChZwRBrw0c96ZFu/awalf8LqGD8orZ0bvf+Nzf0frETaNxkbAn+q3naCu3Wh bMnxz8+Sy+RhGCDZlVRPczxztAzR42OHd5hLngFkN5ym99lj22HN1zRN1qIx5PF08B1j +T1CYI2KZsLYycFo1Kfb5eiGwFLHyI/Blj5WZa/aX1p9Cy9hNEkHD+F3ZmWR42fjYBgz K7pmRhn3+2hE3lgfd4h8RZnMxDWIZpBBkJ9Fhd2/vfC11991w5ifYJykz0vgv9NC8xS6 OwtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=nSdHJeWqWDZOQeABzXBHYYSEmw+sgR02dIC9udOVmMk=; b=y2o3PXJM3HecKNAoyaR7/2+jHN3ta/y2sqehv0ZcZ8n9FJPTVNkhehKXWW4Rgqkilv 7bdUhnhbMlO774pCMMbFxvRkzk8uNMVK856q9CnVUYw/eG3daelJnzxxwMks2L6B9gtu RN90nBk7lI0wD+JU/DzbUdTMYY4NM53oba+JIoMrjXQmPBxv5aRNXk7WiFbMGIHpAvmR sxIa6OSdETJaZ8oW2MmF3QzPZShEEXEUVqn+jMHXueXAfkUboT4Be2p/WimqfhGjMpy2 YI4XqxwBQumYf380QPF1Igp/kfz8DA9a25FTQHEQCGfNWrTlWzFKiCKmmyr6CAgmIZOO eLjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=t+BErM9b; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id p12-20020a5d68cc000000b0022cbc622f8bsi6863581wrw.871.2022.10.10.08.03.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Oct 2022 08:03:03 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=t+BErM9b; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34232 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ohuJ4-0001rc-C5 for patch@linaro.org; Mon, 10 Oct 2022 11:03:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60094) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohtlB-0006WI-QI for qemu-devel@nongnu.org; Mon, 10 Oct 2022 10:28:01 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]:56110) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ohtl9-0005aG-At for qemu-devel@nongnu.org; Mon, 10 Oct 2022 10:28:00 -0400 Received: by mail-wm1-x329.google.com with SMTP id t4so6938510wmj.5 for ; Mon, 10 Oct 2022 07:27:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=nSdHJeWqWDZOQeABzXBHYYSEmw+sgR02dIC9udOVmMk=; b=t+BErM9br1YlQLslYwau5GkqlHmMJKbeFKdIE+dRMBkUsviOxvr7nqMVC4h4Rfd3P3 Z+l2Kg89EAYCfqD5t92+O9I8A2D4/dOI0yLoIWkjuDvIpww7WrXyNAiWn+/wRr92Y1m5 aO7KLE2CxnI9wYle+Pa8Nc80TV+G0VBZraux65W557GTAxKnZcfJJLpO9nRXdiBctSGS JZRtNG/v7WIK2pz3kNi2SQWUtjoi0H4Aqj4++zq3s1CrgHYJ/w3XoZQgbhGtWKa4Zmsj uSBCZ6MlpTlghwRw5KqM9IWrpVLyeo1hqsRjeQ0RXyA9sVvD7DPVcbUDwYKFU5qPkJ73 KT7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nSdHJeWqWDZOQeABzXBHYYSEmw+sgR02dIC9udOVmMk=; b=x7eouCXmtSF0ZPIDkXg3b+674SJkWgJvnHcSSKJEVwuj7BuSxfYWoo1Nsaz3/go4OE +wDWW1yg/OZqqcY2Bw7gTm8mnsNcu1b2vqa5dW1dml4dkPYclRHgKf+WfDr5uTCg0THD ByDHG/SqM768B8QFJGB5OFu2fI1r9+Q3afLOwYm31g2XcLib0InDtLV/OzXnbfKy6KQu efnLugRlm7MEXbAEAotTNWjFAkjSbG9m++/vmxtt/anLUJ/aFXw3XdYYIR+NanZDl6+k kwUgarxRcYvHSv8/sQbGPK0z3QAidmopG0ajOSoJTPd5ch/6klVEdy1GN9HmOgV3Lp88 8SKA== X-Gm-Message-State: ACrzQf3+BfJKkHyJGaVQ9CwNLMjxgadveOd6c8mmDub/fPrEZgB9IiOQ 4ZIdBkKoUIsKHUSoyAJThQ5U3bq9N45z9g== X-Received: by 2002:a1c:730e:0:b0:3b4:b0c0:d616 with SMTP id d14-20020a1c730e000000b003b4b0c0d616mr13128048wmb.72.1665412078642; Mon, 10 Oct 2022 07:27:58 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id u6-20020adfed46000000b0022e04bfa661sm9037054wro.59.2022.10.10.07.27.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Oct 2022 07:27:58 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 25/28] hw/arm/boot: set CPTR_EL3.ESM and SCR_EL3.EnTP2 when booting Linux with EL3 Date: Mon, 10 Oct 2022 15:27:27 +0100 Message-Id: <20221010142730.502083-26-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221010142730.502083-1-peter.maydell@linaro.org> References: <20221010142730.502083-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x329.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Jerome Forissier According to the Linux kernel booting.rst [1], CPTR_EL3.ESM and SCR_EL3.EnTP2 must be initialized to 1 when EL3 is present and FEAT_SME is advertised. This has to be taken care of when QEMU boots directly into the kernel (i.e., "-M virt,secure=on -cpu max -kernel Image"). Cc: qemu-stable@nongnu.org Fixes: 78cb9776662a ("target/arm: Enable SME for -cpu max") Link: [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/arm64/booting.rst?h=v6.0#n321 Signed-off-by: Jerome Forissier Message-id: 20221003145641.1921467-1-jerome.forissier@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/arm/boot.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/arm/boot.c b/hw/arm/boot.c index ada2717f760..ee3858b673a 100644 --- a/hw/arm/boot.c +++ b/hw/arm/boot.c @@ -763,6 +763,10 @@ static void do_cpu_reset(void *opaque) if (cpu_isar_feature(aa64_sve, cpu)) { env->cp15.cptr_el[3] |= R_CPTR_EL3_EZ_MASK; } + if (cpu_isar_feature(aa64_sme, cpu)) { + env->cp15.cptr_el[3] |= R_CPTR_EL3_ESM_MASK; + env->cp15.scr_el3 |= SCR_ENTP2; + } /* AArch64 kernels never boot in secure mode */ assert(!info->secure_boot); /* This hook is only supported for AArch32 currently: