From patchwork Fri Apr 26 19:41:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 792379 Delivered-To: patch@linaro.org Received: by 2002:adf:cc13:0:b0:346:15ad:a2a with SMTP id x19csp627373wrh; Fri, 26 Apr 2024 12:50:58 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUmlwew8Uyhey1kHyggHDUjb/LdnwNQrahP0h7vdlHQmLD8eQ9OLy03gpkt7tIKHvSGQBsxAC8DkCKSgtVWha4S X-Google-Smtp-Source: AGHT+IFVqxc/FztW86Vgkn8tw/iT85ZkaP+zndHvuMYmzVumz8Vq1rOsRWyfQcnJ0K+ESRqD7kn2 X-Received: by 2002:a05:6359:5097:b0:18a:5676:2fd0 with SMTP id on23-20020a056359509700b0018a56762fd0mr3838485rwb.10.1714161058657; Fri, 26 Apr 2024 12:50:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714161058; cv=none; d=google.com; s=arc-20160816; b=AF4uYGb9DTlq7MPBHHZD+4miqfw2D40sr29RWJ1SrliTjEFipbU9bJmrWn424cnaJV uu5zEEOjxWH1ZgzTqkJnjEBZvQT25yujI8ese9gDAKg6hFPTLaFZbWuIKjxlcDcAXr0A r+xGo9Lb5KAMwnM9VrNqT+Ul21NYlnslUjPHIm/7QMcP/37YDJfeUgF7LJnb3Hbg5HRs d24pnZ+ef2nUsJui5QoiQKsH/1FUSV3cjz3rtvSiehN1Jpy9jiElFyL9edq9VtKvKC27 qu6Wep6O9VUD4G3n2ncgkXa7KmOq64NY+gvwP4by/32syeC1rdUtPvw4SoXtsoPliR0S AGxA== 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=Z+2jDyZubLtcgNSevFNEEciw6F0x1NCcSU5rQYS3oAw=; fh=Pw2rna1XKA6Q6oVrBm5QfqVdprGO4k4MCabOwh7/beA=; b=E+IrOlFTTbs9OlkMfNpM5jUcIojvX0QiHBXrKJXejwposKUHKQLXcK7UOQu8+2w4X8 YZcEyFZCWoJZ6rdItMJ+8tAoLxUgiADiRSn0a1IIoswXfgWjPCtUi0ktJGb+yvdhBN/a 3dd+E49NclKYtEnUG1/6iUDSLp5PXFs0V/nzBa7qu9fxJ3z+hmbAI0zzWh2KljJFyWKi 7QewFCMeUaazJKjtzpQvoyz6EB00GNjeOQ1taewZGdKApkc1U85ifqZQEEYX3QEzR98U CZqhli+IJ1T3vYxr/+EKuk1/Dxd7EiBu+xNhxNPGu+1+O2wj3CHAcn5okBRztaG++F64 LETQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UhjCGqBE; 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 ay4-20020a05622a228400b0043a20714cdesi6721853qtb.390.2024.04.26.12.50.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 26 Apr 2024 12:50:58 -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=UhjCGqBE; 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 1s0RVs-0002Rr-1P; Fri, 26 Apr 2024 15:45:40 -0400 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 1s0RVn-00025J-Jd for qemu-devel@nongnu.org; Fri, 26 Apr 2024 15:45:35 -0400 Received: from mail-lj1-x234.google.com ([2a00:1450:4864:20::234]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s0RVj-0004jI-Ug for qemu-devel@nongnu.org; Fri, 26 Apr 2024 15:45:35 -0400 Received: by mail-lj1-x234.google.com with SMTP id 38308e7fff4ca-2def8e5ae60so25090511fa.2 for ; Fri, 26 Apr 2024 12:45:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714160729; x=1714765529; 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=Z+2jDyZubLtcgNSevFNEEciw6F0x1NCcSU5rQYS3oAw=; b=UhjCGqBEM92b5zkUfUld/wygKKFVElvhoYrm3fHPiB9+D+2M24KTOejCjKZFFj2Rk6 ysyuK73y9GVucNQgxVcuGw9Uk540c/LN1QibEolh61fvVjCyKTnfMPN/OLO4MlBtpHgd UPN4YwIUgNDURpjygXpg74DcypK9iqOzkG4vili37cLue/9LEPVbU3v+SuWC3P1+l6DH cujOXQhWoNm6500QUIyc/IAIEhAuqt6ffSnOXCe6ibgzDyc2FqC45BC47FoOP2cfinJ9 QeJ8tjnX2cujeck0IB0JZ/QAt6HlzEy640a9TqDVjPmtQzlAZkI6YzVhRWeLyQ7kUbKO MyoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714160729; x=1714765529; 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=Z+2jDyZubLtcgNSevFNEEciw6F0x1NCcSU5rQYS3oAw=; b=S7YTDZ/QG4NnVlo0XoPrB4DWO3qMr8TLzv4jhGyjyhDL695B0KpvDFDfRq0cSoDbZG sSNFx3aD7ewOW0UF7hznh8H1yNPUEacb5cRDOzzGV4kPNpOG+yTwkHZ13iGzRUXDQvW7 Se1xvkD5plyI0849TDjshRLrnavPJ2nDcoV+WaIvql7CSZF+aA4cD+Ku8CTGo1MY47HK ++3S9PPRjOVmap0agFNwzQJdqCHsztmbM2JSzz+m5fV8Hvz9FD/3phVZodccjXeHxWXq WvP3HN8J6VCnf+qD/JaI14j1Rbag911Hv9nrCwRH61tNd1X0rMyNm7rZSOXiUeMSw+Dh PxEw== X-Gm-Message-State: AOJu0YyXQyev2WJ/oUCuDFHfXC1oIbhuq7SDTt4iNdFuudTI36ygD+Vi JOQVL5vPM2v9UAx2ECe5ZiPZE3szG8LFf16K1khjDD/ErwQWkUy2sb+u+ovfba0dd+nKhLQeH7u P4YI= X-Received: by 2002:a2e:a4a4:0:b0:2db:7b:1a7b with SMTP id g4-20020a2ea4a4000000b002db007b1a7bmr2028423ljm.46.1714160729546; Fri, 26 Apr 2024 12:45:29 -0700 (PDT) Received: from m1x-phil.lan (aul93-h02-176-184-11-147.dsl.sta.abo.bbox.fr. [176.184.11.147]) by smtp.gmail.com with ESMTPSA id l10-20020a056402124a00b00571bec923bcsm10012663edw.93.2024.04.26.12.45.27 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 26 Apr 2024 12:45:29 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, qemu-ppc@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson , Anton Johansson , Warner Losh , Kyle Evans , Paolo Bonzini , Riku Voipio , Laurent Vivier Subject: [PULL 35/38] exec: Restrict inclusion of 'user/guest-base.h' Date: Fri, 26 Apr 2024 21:41:55 +0200 Message-ID: <20240426194200.43723-36-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240426194200.43723-1-philmd@linaro.org> References: <20240426194200.43723-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::234; envelope-from=philmd@linaro.org; helo=mail-lj1-x234.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=unavailable 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 Declare 'have_guest_base' in "user/guest-base.h". Very few files require this header, so explicitly include it there instead of "exec/cpu-all.h" which is used in many source files. Assert this user-specific header is only included from user emulation. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Message-Id: <20231211212003.21686-23-philmd@linaro.org> Reviewed-by: Anton Johansson --- include/exec/cpu-all.h | 3 --- include/exec/cpu_ldst.h | 2 ++ include/user/guest-base.h | 6 ++++++ bsd-user/main.c | 1 + linux-user/elfload.c | 1 + linux-user/main.c | 1 + 6 files changed, 11 insertions(+), 3 deletions(-) diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index 027f19e052..e75ec13cd0 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -65,9 +65,6 @@ #if defined(CONFIG_USER_ONLY) #include "exec/user/abitypes.h" -#include "user/guest-base.h" - -extern bool have_guest_base; /* * If non-zero, the guest virtual address space is a contiguous subset diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h index f3c2a3ca74..7d0a0412ad 100644 --- a/include/exec/cpu_ldst.h +++ b/include/exec/cpu_ldst.h @@ -74,6 +74,8 @@ #if defined(CONFIG_USER_ONLY) +#include "user/guest-base.h" + #ifndef TARGET_TAGGED_ADDRESSES static inline abi_ptr cpu_untagged_addr(CPUState *cs, abi_ptr x) { diff --git a/include/user/guest-base.h b/include/user/guest-base.h index 1e42bca5db..055c1d14fe 100644 --- a/include/user/guest-base.h +++ b/include/user/guest-base.h @@ -7,6 +7,12 @@ #ifndef USER_GUEST_BASE_H #define USER_GUEST_BASE_H +#ifndef CONFIG_USER_ONLY +#error Cannot include this header from system emulation +#endif + extern uintptr_t guest_base; +extern bool have_guest_base; + #endif diff --git a/bsd-user/main.c b/bsd-user/main.c index 01b313756e..29a629d877 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -36,6 +36,7 @@ #include "qemu/help_option.h" #include "qemu/module.h" #include "exec/exec-all.h" +#include "user/guest-base.h" #include "tcg/startup.h" #include "qemu/timer.h" #include "qemu/envlist.h" diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 207455c1ba..f9461d2844 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -8,6 +8,7 @@ #include "qemu.h" #include "user/tswap-target.h" +#include "user/guest-base.h" #include "user-internals.h" #include "signal-common.h" #include "loader.h" diff --git a/linux-user/main.c b/linux-user/main.c index 149e35432e..94e4c47f05 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -38,6 +38,7 @@ #include "qemu/help_option.h" #include "qemu/module.h" #include "qemu/plugin.h" +#include "user/guest-base.h" #include "exec/exec-all.h" #include "exec/gdbstub.h" #include "gdbstub/user.h"