From patchwork Fri Mar 1 23:06:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 777112 Delivered-To: patch@linaro.org Received: by 2002:adf:e94d:0:b0:33d:f458:43ce with SMTP id m13csp1603781wrn; Fri, 1 Mar 2024 15:16:40 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUbpEOVl9TMgx2Affllj2Td1jz1AupSN1xbMwEFAsHrmxoHynffuLvSh+5AvPYR7kxlvaGmCBxUum5eyXZ6UQD0 X-Google-Smtp-Source: AGHT+IFjSEJmuXiel+Lox9biwcaXO8x9oqhlWr5Q/mPBaaX9DEIR4SsToKsqLEek+z5nvrX6Ao4G X-Received: by 2002:a05:620a:40d0:b0:787:f83e:3194 with SMTP id g16-20020a05620a40d000b00787f83e3194mr5635366qko.16.1709335000113; Fri, 01 Mar 2024 15:16:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709335000; cv=none; d=google.com; s=arc-20160816; b=o3MLG39Dfr90o6pbCLiVqRkdkCYgNLLJamDHOdH0HW9NiQl+Qab/GJ3BTA7rKhVuFe NaqWLwHOKtlRMFRiShSU0cfLq0HcdkmqdldgzJNuG52IfW4GJicAGRNJF7nCnipPZ2Dk Uk92dJ2ufJa8J3WCJivmZOb6OhzxeUieijiyV6wF9YHP8zsLMxPt+4KhgXmdIwqgtDeZ qy3vKFnPYXhkuKiXpMtnfQ0J90NfZ0pzSfRKxoLw/dUfgaWWtSFXt1hkI03gms2cADPi fHE53lrywuxUm3GgsfFP624vxUI2Uu7al31uhyQGFm68hOnzt3dQKOZWT6F9Roh+PWKw ZJgw== 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=vaUyQsnvahk8PvCDA8gukGjHfbLFzwV+mi5B0BNbUsQ=; fh=/b6muhdHFTPGDEv1d8xYfSbM3v1A3Ow/UiHlQW4DIq0=; b=W6sNlhHvIhXYlU3bwYdEL+cZEAmUvlLUAqDHC3fy78KUlvvyqbfsyX172bwCkfOVhj Oa2Fds7pTo/Nt4JiRwiE2E0PJHjJ7lxhcZzAJsarfxCggRvaBODxx1lCXzWpO4DTR619 KDEOrzYMdjLjr6fmT89/rcdWbBkl1Tf1rHp7CJraluFVAN4DQUBNHmEBKEcTGzSiRwbr qMYhhs6TmH8aGIeZKSvExi1yw/kbyMFbAxIwPfYqu9krzviCbFl2Oow+t5YTeGrcBk0p A9RpEFCxENVcZKw/95I8ba1sKDQGd4/egsEXMXYHyKXm3Lqv1rMD53YLjzo7TWFn7eMR Bvzw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="pYE8/6ZN"; 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 vu18-20020a05620a561200b00787c0e79d2dsi4473584qkn.572.2024.03.01.15.16.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Mar 2024 15:16:40 -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="pYE8/6ZN"; 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 1rgC2a-0005BU-G4; Fri, 01 Mar 2024 18:11:44 -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 1rgC1U-0003rJ-39 for qemu-devel@nongnu.org; Fri, 01 Mar 2024 18:10:43 -0500 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rgC1R-0005gb-Dm for qemu-devel@nongnu.org; Fri, 01 Mar 2024 18:10:35 -0500 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-6e5e4b1d1f1so206791b3a.1 for ; Fri, 01 Mar 2024 15:10:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709334632; x=1709939432; 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=vaUyQsnvahk8PvCDA8gukGjHfbLFzwV+mi5B0BNbUsQ=; b=pYE8/6ZNEihwLPHTBDrDs8dAqsHYmYUS59UB1CcMkgjoaFwV1Hsp7uVlsebhiKVK98 H91s0QfB5SylMhSzrjCE/yOsiVX6Ml6OTRoxBVRoTrtm2u1atEOzjnfDM9hkjI9LHm8M /qUkwCTDe5EpjrzgD7kHoQNxqIhlpMxYh4Rd5oQRRzzr8kSk7rxB/urPeWwXkeB7zSBL 8zc0mFLkaJ34BRDW4Sh6NL9lVwqtIhLXFQZSRQ6//nNjKSjdtoYEwF0Cqwi5qxkZArHh tTF2+UfG4+9pNB5+uflEEZjTNUuDEm5tW8tOovPSNBmPmqSquC1UHZkyy2NrMrmkJjgC PJSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709334632; x=1709939432; 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=vaUyQsnvahk8PvCDA8gukGjHfbLFzwV+mi5B0BNbUsQ=; b=Rx6YyDpT8U/oLhQScTZ2/9EzBr5C92oXk6DMlT8+xr3X0h5lYpzwhRZp0sBBhSpth+ it+voT0N03dg8E+DHMJSzZTihNJkD0Qg5q8Lj3FoEZCR90VB/lqYwnBoqIGBT4rIR6Ez T61XgX29zglx8WL8SpVYF+1Tftd2dV+X4SntXS+OqbTD+ODhOLR5cPSm5dsn/4DeWUuM WkoCWEHNAo/EELeH5mhINBbfzhRhkPOaFB+yYkX+DBz2GLpisVLMB2Uh07RX978ep+MN MDTforgbPi26RAx9g2nA2TpDOFYbiOMn7bCuLJKLjFzC/iBDZAQZJdvQjphOij6w8NQQ 1wag== X-Gm-Message-State: AOJu0YxL0iWrBbW1TGYppPSN/BqZgHG7iWupsaGMzzlT2zhb39Oq9xzQ iMFz6C/EhRCL38H/ACh42uiL6gwxa8Ej5LxZQXXvUCLgFrgGJguq5XeTuuriVCvjz0/MAYO/Y8B m X-Received: by 2002:a05:6a20:3d22:b0:19e:ba42:4ed9 with SMTP id y34-20020a056a203d2200b0019eba424ed9mr4598452pzi.1.1709334632155; Fri, 01 Mar 2024 15:10:32 -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.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 15:10:31 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Warner Losh , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Ilya Leoshkevich , Helge Deller Subject: [PATCH 47/60] cpu: Remove page_size_init Date: Fri, 1 Mar 2024 13:06:06 -1000 Message-Id: <20240301230619.661008-48-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::42f; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42f.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 Move qemu_host_page_{size,mask} and HOST_PAGE_ALIGN into bsd-user. It should be removed from bsd-user as well, but defer that cleanup. Reviewed-by: Warner Losh Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Tested-by: Ilya Leoshkevich Acked-by: Helge Deller Message-Id: <20240102015808.132373-28-richard.henderson@linaro.org> --- bsd-user/qemu.h | 7 +++++++ include/exec/cpu-common.h | 7 ------- include/hw/core/cpu.h | 2 -- accel/tcg/translate-all.c | 1 - bsd-user/main.c | 12 ++++++++++++ cpu-target.c | 16 ---------------- system/vl.c | 1 - 7 files changed, 19 insertions(+), 27 deletions(-) diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index dc842fffa7..c05c512767 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -39,6 +39,13 @@ extern char **environ; #include "qemu/clang-tsa.h" #include "qemu-os.h" +/* + * TODO: Remove these and rely only on qemu_real_host_page_size(). + */ +extern uintptr_t qemu_host_page_size; +extern intptr_t qemu_host_page_mask; +#define HOST_PAGE_ALIGN(addr) ROUND_UP((addr), qemu_host_page_size) + /* * This struct is used to hold certain information about the image. Basically, * it replicates in user space what would be certain task_struct fields in the diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h index 9ead1be100..6346df17ce 100644 --- a/include/exec/cpu-common.h +++ b/include/exec/cpu-common.h @@ -20,13 +20,6 @@ void cpu_exec_init_all(void); void cpu_exec_step_atomic(CPUState *cpu); -/* Using intptr_t ensures that qemu_*_page_mask is sign-extended even - * when intptr_t is 32-bit and we are aligning a long long. - */ -extern uintptr_t qemu_host_page_size; -extern intptr_t qemu_host_page_mask; - -#define HOST_PAGE_ALIGN(addr) ROUND_UP((addr), qemu_host_page_size) #define REAL_HOST_PAGE_ALIGN(addr) ROUND_UP((addr), qemu_real_host_page_size()) /* The CPU list lock nests outside page_(un)lock or mmap_(un)lock */ diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index af1a29526d..d0e345419f 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -1179,8 +1179,6 @@ bool target_words_bigendian(void); const char *target_name(void); -void page_size_init(void); - #ifdef NEED_CPU_H #ifndef CONFIG_USER_ONLY diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 1c695efe02..c1f57e894a 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -256,7 +256,6 @@ bool cpu_unwind_state_data(CPUState *cpu, uintptr_t host_pc, uint64_t *data) void page_init(void) { - page_size_init(); page_table_config_init(); } diff --git a/bsd-user/main.c b/bsd-user/main.c index 6ab3efd6c0..512d4ab69f 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -49,6 +49,13 @@ #include "host-os.h" #include "target_arch_cpu.h" + +/* + * TODO: Remove these and rely only on qemu_real_host_page_size(). + */ +uintptr_t qemu_host_page_size; +intptr_t qemu_host_page_mask; + static bool opt_one_insn_per_tb; uintptr_t guest_base; bool have_guest_base; @@ -307,6 +314,9 @@ int main(int argc, char **argv) (void) envlist_setenv(envlist, *wrk); } + qemu_host_page_size = getpagesize(); + qemu_host_page_size = MAX(qemu_host_page_size, TARGET_PAGE_SIZE); + cpu_model = NULL; qemu_add_opts(&qemu_trace_opts); @@ -404,6 +414,8 @@ int main(int argc, char **argv) } } + qemu_host_page_mask = -qemu_host_page_size; + /* init debug */ { int mask = 0; diff --git a/cpu-target.c b/cpu-target.c index 86444cc2c6..4c0621bf33 100644 --- a/cpu-target.c +++ b/cpu-target.c @@ -45,9 +45,6 @@ #include "trace/trace-root.h" #include "qemu/accel.h" -uintptr_t qemu_host_page_size; -intptr_t qemu_host_page_mask; - #ifndef CONFIG_USER_ONLY static int cpu_common_post_load(void *opaque, int version_id) { @@ -474,16 +471,3 @@ const char *target_name(void) { return TARGET_NAME; } - -void page_size_init(void) -{ - /* NOTE: we can always suppose that qemu_host_page_size >= - TARGET_PAGE_SIZE */ - if (qemu_host_page_size == 0) { - qemu_host_page_size = qemu_real_host_page_size(); - } - if (qemu_host_page_size < TARGET_PAGE_SIZE) { - qemu_host_page_size = TARGET_PAGE_SIZE; - } - qemu_host_page_mask = -(intptr_t)qemu_host_page_size; -} diff --git a/system/vl.c b/system/vl.c index e480afd7a0..48aae6e053 100644 --- a/system/vl.c +++ b/system/vl.c @@ -2118,7 +2118,6 @@ static void qemu_create_machine(QDict *qdict) } cpu_exec_init_all(); - page_size_init(); if (machine_class->hw_version) { qemu_set_hw_version(machine_class->hw_version);