From patchwork Thu Apr 18 19:25:14 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: 789852 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp736799wrm; Thu, 18 Apr 2024 12:33:17 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUnh9E+0hc6gctoVF4NCQCAlHw0Q9WcEH43MuYg1ojFvI4xCbQew3s/O95QdLB/4SYiO0T96PCnF862xdyHcTl7 X-Google-Smtp-Source: AGHT+IFkjCdetr5rgxWBKCPtMcKmmufzCcHX6QzJOSH+8lde+NTtPeKYB1hSJZOWq5+TemAVNfRa X-Received: by 2002:a05:622a:1347:b0:437:b866:980e with SMTP id w7-20020a05622a134700b00437b866980emr29585qtk.5.1713468797631; Thu, 18 Apr 2024 12:33:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713468797; cv=none; d=google.com; s=arc-20160816; b=TvUG+hcxnKIVa8u1tDB0agMH4rnDpjrcNgVOeqrj0Fn13QAlvkssnBcLphKNLE7AxX C9eT35Yn9y0rOaVw4DUZwseEg83DkMkgql/jVuNXfc/stUGBlYR+sHKp9Q7uFpTZwJIN Sgb/QqBdLwN8Fld+8ZKIvEYffanFAYwCwj6WAt58Eyh+PCIi9Efcc+6aeJVJ7gpXzeq+ 6MIGb/dvoxIWXDKpa0SmbxtzXon3JitkPF6DSb2YdSoapq4TDH37dxy3LJ0QKEw60c3e 7Yh/Ta5GjW1OlO50lx5hVXPa4ddY+urWl/xoHpqGPqMWFYhBLPB5Z1ByvgVMk07EHQSb 3/LA== 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=Dml4vJCRKxCVY1uFtRIPG5lLzhQacgo/ZMSZt5sIQXk=; fh=b5TQUgX01t0/Q2g3IT/oGdKd0Qft+P2m2DT1KZ3fpmM=; b=N2QyTdWa2ZjyMX12Uf0hwPx70CG4PDzXH8GyzXbdKIaGG2tvfHCfgh4b3Mn0qBHCJq wgXXaFvEGqdpBeP2B6mdh6LP30fH/iF1mF9ufIG6ChhfLantpR2FE0rGG+Y0/CUyffQz cJB2A5R/dvd8WLRjwNFcwPdzccaVra4scjipvZ/5xvDNNUdB5k+lnHg5t54fM3qRPCoi /dCGIb1XQrq5tq75L1PFTQtvYhwMARiOkTYmAMyyo97+rAdzkLwdm/SDVFzdIxV1LIqC 7wWfEvgIvqXiaqCl2VAHRO1S99+PykoiArKP69qL1X+JQBmwHt2XC6eLIg3sqHWZTMVU azAQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=s0GWNpWb; 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 f9-20020ac87f09000000b00436d9cdd2b7si2230341qtk.245.2024.04.18.12.33.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Apr 2024 12:33:17 -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=s0GWNpWb; 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 1rxXRQ-0004cW-PT; Thu, 18 Apr 2024 15:29:04 -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 1rxXPh-0000Fm-Rh for qemu-devel@nongnu.org; Thu, 18 Apr 2024 15:27:19 -0400 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rxXPf-0007bM-5r for qemu-devel@nongnu.org; Thu, 18 Apr 2024 15:27:17 -0400 Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-a5200202c1bso150501666b.0 for ; Thu, 18 Apr 2024 12:27:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713468433; x=1714073233; 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=Dml4vJCRKxCVY1uFtRIPG5lLzhQacgo/ZMSZt5sIQXk=; b=s0GWNpWbxlSuPx0vJ7p9ynQSeHaNOyYRX7Amfsgw8O4d/p11qNn2v5a4XpEuS1JXGo rQWrWIlD16vjIGqjWJzeUbh3WObU3OVpVG6L9bUAIz29fbNXfsb7MBnClZveoINehthx xook377/S9V4/YkCOrRrp73n4JJfenHHvrFyA+UYrCJ+uSXE1JKF7pKSJctNw1oPMznt EsMdeygEerSsbqmjmXfuZj5LmdF+A13jUx8gYLHLQ+ULwKAdGpuIXbvDUyKAzjZpB1PT yNsMmi2MhmmN1NFmITn8rHiSXZgUh3ViMW4tzD5j70brvYrIftV89SE+dgrAkkoWczax suuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713468433; x=1714073233; 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=Dml4vJCRKxCVY1uFtRIPG5lLzhQacgo/ZMSZt5sIQXk=; b=hu0bSmXfOnxGLCHCmgJ5MLBvXDndbZFodRaF1ULyE3DxVAOTCTjDJVjCAaYPhTFD4W tyeiPPvFBsBRNrRdI9NlKy6H98u2JcUFKR5U6UM0EFlB6+ILtTd4eixXpZVQwJaw6Anj Fx6PW1hBEPNdYIRr+ZGBfG+8xM0KQfUDpSmu8z4XmfOsYyae/Pib1So0L6T9rjNxaQL5 cy6A/RYi7owsswtWKI3jqLqnfGMAFTfpbWZxUdiLvbxpYQ4cy0IzUgl51JgzyKYpwQvH hRM9ChqqM6FZjrq+sNAPHFkaJk/1GevkmGn+aJtaWNk1f1hab4jM0zA6GkFg2yeimkAd 94hA== X-Gm-Message-State: AOJu0YyHHCDYuAKLz7LKUH1DgKKt0Z39tVR08C2iby464vcoMbt+Q//T kiXRve/gb1sEhlZQj6xIWzKmrMuAMgAsZIkvefXs740KJ6O6whrdLTJCLRZRqli0MqQKBxvGd9N D X-Received: by 2002:a17:906:6bc7:b0:a52:13ee:8124 with SMTP id t7-20020a1709066bc700b00a5213ee8124mr59241ejs.35.1713468433364; Thu, 18 Apr 2024 12:27:13 -0700 (PDT) Received: from m1x-phil.lan ([176.176.151.213]) by smtp.gmail.com with ESMTPSA id x16-20020a1709060a5000b00a5575c9d5b4sm967734ejf.63.2024.04.18.12.27.11 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 18 Apr 2024 12:27:12 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Richard Henderson , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, David Hildenbrand , =?utf-8?q?Alex_Benn=C3=A9e?= , Anton Johansson , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Warner Losh , Kyle Evans , Riku Voipio , Laurent Vivier Subject: [PATCH 15/24] exec: Restrict inclusion of 'user/guest-base.h' Date: Thu, 18 Apr 2024 21:25:14 +0200 Message-ID: <20240418192525.97451-16-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240418192525.97451-1-philmd@linaro.org> References: <20240418192525.97451-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::633; envelope-from=philmd@linaro.org; helo=mail-ej1-x633.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 2c5a0a5c81..6d47d3114a 100644 --- a/include/exec/cpu_ldst.h +++ b/include/exec/cpu_ldst.h @@ -73,6 +73,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 fc60c01d57..9ed4baa2ac 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"