From patchwork Fri Mar 1 23:06:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 777126 Delivered-To: patch@linaro.org Received: by 2002:adf:e94d:0:b0:33d:f458:43ce with SMTP id m13csp1604794wrn; Fri, 1 Mar 2024 15:20:14 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWw6OwxTDbDiyYlEoDgjYv1Rb3cvXhIHDHMPywWfPbSuGaPmGiPpKD0zWiBfoJOvLEryrFqvx1Ieg2/+ylfJNBv X-Google-Smtp-Source: AGHT+IGUknXGEGs5RN0V6VWYS2JlafX959C4GI/LTRR0Alnk+9txdzrEYfaX22FL9CO14POL29J6 X-Received: by 2002:a05:6214:4252:b0:68f:e80f:a285 with SMTP id ne18-20020a056214425200b0068fe80fa285mr3234120qvb.59.1709335214244; Fri, 01 Mar 2024 15:20:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709335214; cv=none; d=google.com; s=arc-20160816; b=WSqaiTTTt6UYWadfNgvIauSOwLmEbQ4apvXZFpB89tTa+vYZxzeD/UZgliT5JvyMcS VsMN7ZhHcmDyHJ6H/nHXt7zVLnSLWakrdG1ODzD15C5w8yR99+t0EzJ5J9aWw1sxs9uX xnffs0PohaegcSzpg+q9jAaYqEGJwBgRr3LkwxRizSDJXc0YGa8hQxYhIVt3snJVfz/f quPvZ7NNhqQR+E7lhERtyUuLgkfgI9G5EXnjVydnpW9sfH7Rnp7XGbsjs7JgGnl0K9/6 GUOPnBbPNBDJsQKeTM20tW8Yxa7up21ajnHwDjKUktJ2m7gOB2g4CM/FA7DIOm8BVcEo 6ySQ== 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:cc:to :from:dkim-signature; bh=b5H5GE1LAqBUPd7mQOHglWKh/GcV0V+kwE9pYm3ahFA=; fh=akUSvRccVt8SjEp97fUPeSLjFmLWLgFk16EYqCeIvf8=; b=IqQROYrSUbwBsUT6YjD1Pudg4LwvEqtE+xL5XxNKYKTAB9q3wQtZAKwqZEpXieAFWJ 2YtKKxasDDUUQUKQSHwa5qiSW2Pu32z5elzFdQt/ODBo/4vV0OV8hTcGZp79YNXuIOnu Lv9nwqM2yYpkkTQu3+ggerTf2bBc1Q4mbWCzeVUg+7w/1OIWPhNHziE600Ea5E2s+RV+ j8IvULIl2Fed5ptjZwGQ2UK/kEUo0wqXuvuVuRuwR1/XK3Zl+1mwMvXgbyi+G1LT51U1 Y7sYDm6zyNnoAJENrV1AdBMb2scvhNSMKHnSuM/jRYOUoIqUpbYVjUknYAz2yWZxUqL1 XFfg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lJYAe32X; 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 kc7-20020a056214410700b0068fe50183f4si4581578qvb.76.2024.03.01.15.20.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Mar 2024 15:20:14 -0800 (PST) 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=lJYAe32X; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rgC2Z-0004tn-8a; Fri, 01 Mar 2024 18:11:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rgC1X-0003rp-Gv for qemu-devel@nongnu.org; Fri, 01 Mar 2024 18:10:44 -0500 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rgC1V-0005ig-RL for qemu-devel@nongnu.org; Fri, 01 Mar 2024 18:10:39 -0500 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-6e5d7f1f15bso658681b3a.2 for ; Fri, 01 Mar 2024 15:10:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709334636; x=1709939436; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=b5H5GE1LAqBUPd7mQOHglWKh/GcV0V+kwE9pYm3ahFA=; b=lJYAe32X81XPDf+gXyZgIsourEj2xnRFoqlWjxG8mNoZbq2djjMCDm+JjZY6cJkNL4 NndUDSADBbMEILefks0Ezfa4Md2/hG4IA2ILhKWm3rvclj4OTu4Or56sH+mYANCGhn9v msGoRxLf462rbgJYpmaI8B+7b7xXPCSdHvGTi9qSrYoGxOL6kqMxBLQrjPkenRWtOdHq YBKj4xv1ec70ZWz7ZZLn5os0Zrr5v87bYZlWUf/KEGe2h9KjAXuWiGavP+0p5H1ghvsd TZlWD/hdSf1s2IvoYyYxFkvCTPgKIuuMyyqNXQp0ubIxg9jE5k+OLlhfGW/cvlDPPEbn cigQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709334636; x=1709939436; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=b5H5GE1LAqBUPd7mQOHglWKh/GcV0V+kwE9pYm3ahFA=; b=eaBRBLcnC/bGv73b6IpWqbNoWucdNCVhls7D+PfVCZtZMuKuiWnnfHag7U9xJBe28k pqXB1yj4GiwCu7JFpEUupwH/ZQhGxUKorpgKyJdYbjiUSh1P1dZ6IC04t/z7y7QPmGEF OpR1NUT3sFIAPOeMFJgtooOhlYPIDJG8Y7QTPFsMjIRbkD+trXdpYh7xU9e8nkryi85v j5EQdS4tCY+xf5jfwV8apG+4iXZ9VIZTpxPuMgJOPncv/rhAZyAAzXVosTu0XqAwVrju C4mcxLn3U4MXjvspnkneoEm9BOv2irWGqvtWaYAi8HtH0kR634ulW+QKGASvNm9YjK5D IFeA== X-Gm-Message-State: AOJu0YzWaJRKeHebYlt9NPZz8eHzQrcun2NoSKi+cf6367lqKnVhYH3r Gqrot1Rn7TGRI7HglOYjJtqxn6RI1osuz6WvoCSuruz3DZ0Hn3oizbx+9ptDmcKwwY1F7tOF/YE W X-Received: by 2002:a05:6a20:429f:b0:1a1:461a:3a04 with SMTP id o31-20020a056a20429f00b001a1461a3a04mr397633pzj.8.1709334636656; Fri, 01 Mar 2024 15:10:36 -0800 (PST) Received: from stoup.. (098-147-055-211.res.spectrum.com. [98.147.55.211]) by smtp.gmail.com with ESMTPSA id c2-20020a634e02000000b005e438fe702dsm3449407pgb.65.2024.03.01.15.10.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 15:10:36 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Helge Deller Subject: [PATCH 50/60] target/arm: Enable TARGET_PAGE_BITS_VARY for AArch64 user-only Date: Fri, 1 Mar 2024 13:06:09 -1000 Message-Id: <20240301230619.661008-51-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240301230619.661008-1-richard.henderson@linaro.org> References: <20240301230619.661008-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::429; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x429.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, T_SCC_BODY_TEXT_LINE=-0.01 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-bounces+patch=linaro.org@nongnu.org Since aarch64 binaries are generally built for multiple page sizes, it is trivial to allow the page size to vary. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier Acked-by: Helge Deller Message-Id: <20240102015808.132373-31-richard.henderson@linaro.org> --- target/arm/cpu-param.h | 6 ++++- target/arm/cpu.c | 51 ++++++++++++++++++++++++------------------ 2 files changed, 34 insertions(+), 23 deletions(-) diff --git a/target/arm/cpu-param.h b/target/arm/cpu-param.h index f9b462a98f..da3243ab21 100644 --- a/target/arm/cpu-param.h +++ b/target/arm/cpu-param.h @@ -19,9 +19,13 @@ #endif #ifdef CONFIG_USER_ONLY -#define TARGET_PAGE_BITS 12 # ifdef TARGET_AARCH64 # define TARGET_TAGGED_ADDRESSES +/* Allow user-only to vary page size from 4k */ +# define TARGET_PAGE_BITS_VARY +# define TARGET_PAGE_BITS_MIN 12 +# else +# define TARGET_PAGE_BITS 12 # endif #else /* diff --git a/target/arm/cpu.c b/target/arm/cpu.c index b2ea5d6513..f3ed79cef2 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1809,7 +1809,6 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) ARMCPU *cpu = ARM_CPU(dev); ARMCPUClass *acc = ARM_CPU_GET_CLASS(dev); CPUARMState *env = &cpu->env; - int pagebits; Error *local_err = NULL; #if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY) @@ -2100,28 +2099,36 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) !cpu_isar_feature(aa32_vfp_simd, cpu) || !arm_feature(env, ARM_FEATURE_XSCALE)); - if (arm_feature(env, ARM_FEATURE_V7) && - !arm_feature(env, ARM_FEATURE_M) && - !arm_feature(env, ARM_FEATURE_PMSA)) { - /* v7VMSA drops support for the old ARMv5 tiny pages, so we - * can use 4K pages. - */ - pagebits = 12; - } else { - /* For CPUs which might have tiny 1K pages, or which have an - * MPU and might have small region sizes, stick with 1K pages. - */ - pagebits = 10; - } - if (!set_preferred_target_page_bits(pagebits)) { - /* This can only ever happen for hotplugging a CPU, or if - * the board code incorrectly creates a CPU which it has - * promised via minimum_page_size that it will not. - */ - error_setg(errp, "This CPU requires a smaller page size than the " - "system is using"); - return; +#ifndef CONFIG_USER_ONLY + { + int pagebits; + if (arm_feature(env, ARM_FEATURE_V7) && + !arm_feature(env, ARM_FEATURE_M) && + !arm_feature(env, ARM_FEATURE_PMSA)) { + /* + * v7VMSA drops support for the old ARMv5 tiny pages, + * so we can use 4K pages. + */ + pagebits = 12; + } else { + /* + * For CPUs which might have tiny 1K pages, or which have an + * MPU and might have small region sizes, stick with 1K pages. + */ + pagebits = 10; + } + if (!set_preferred_target_page_bits(pagebits)) { + /* + * This can only ever happen for hotplugging a CPU, or if + * the board code incorrectly creates a CPU which it has + * promised via minimum_page_size that it will not. + */ + error_setg(errp, "This CPU requires a smaller page size " + "than the system is using"); + return; + } } +#endif /* This cpu-id-to-MPIDR affinity is used only for TCG; KVM will override it. * We don't support setting cluster ID ([16..23]) (known as Aff2