From patchwork Wed May 31 04:03:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 687251 Delivered-To: patch@linaro.org Received: by 2002:a5d:4d8a:0:0:0:0:0 with SMTP id b10csp1062395wru; Tue, 30 May 2023 21:08:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ62j/Lbcib+btr7pzyIjQtE2iBGS53O52DPEUn6h7c+fibPfJhDKtRYy7nPpnzWLAsAKWdA X-Received: by 2002:a05:6214:21a4:b0:626:ff6:f48a with SMTP id t4-20020a05621421a400b006260ff6f48amr4980142qvc.13.1685506122324; Tue, 30 May 2023 21:08:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685506122; cv=none; d=google.com; s=arc-20160816; b=JYd0V1Zh8IsYSTNP38hqjM+G9ERLOskmX72wSj7vMCvT94uBwv58vVx5h5ZF8r8UoA BC2UrFt4AQ9jn0ephFByOJj85jEP7j4RLnOGq5p4jvJ7MycCWPiD4NU1c81ne2JlkvT0 PC9K0y+aM73jK0k8xEnDVGVg3RGauliuUkGWhGsxl2Xgxl+LsYZWWfDLhEHf5N3dndld SdNRgWdGpG1fOc7sBAnHCpBXkqt40apRdVabIGHzjkgSkrj3yjfusifFzmGiWNQua8J/ QcAoLq3Tfoq5BHEy51ww2LDcSit9cS0pM1iLPa3j2qgdPZ3Y8qe4d1wcfGUysz8ahqEc jC9Q== 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=H24fyidw2Mts4UgybMsZXcSBtkvN1xbQ1AV6r3ckQ6Y=; b=I9o1YNKBEmfnDG5ljP7aFGq9+6JwAFkE90LYdnqlAXCAdrKeMJbCMPSQ+BDeJq1fuh jxrb/c8uigpDBxPBTV+O5Fg7tI0sa1vm0Q+q+JKuanxnJ4V51MrDBdoNCRjnz5eVKK5T STh4Zf0dOhGmXDkFvvkwcYGnpsyKJg4cbcwF6caNsC+P0WkPlUUjs8PgD2NtPaDG7Qky OlMSZiUY4X2rKOy8DYaIDiAaOl/sVyFJKqWM9/upLGVw6CexxZcHVm0SQKpYIagUUs40 FX29lGceOR38K541/UXAhtBtLCgjPRztGpPqwKCkH2IwyyGzJ6umsEXtd77Lidbbp7/D MYgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="G/pSZ3rH"; 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 if7-20020a0562141c4700b0061b6c6928besi1766233qvb.257.2023.05.30.21.08.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 30 May 2023 21:08:42 -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="G/pSZ3rH"; 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 1q4D7V-0004ce-F0; Wed, 31 May 2023 00:07:33 -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 1q4D7B-0003CH-3U for qemu-devel@nongnu.org; Wed, 31 May 2023 00:07:14 -0400 Received: from mail-oi1-x235.google.com ([2607:f8b0:4864:20::235]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q4D75-0006v6-O0 for qemu-devel@nongnu.org; Wed, 31 May 2023 00:07:12 -0400 Received: by mail-oi1-x235.google.com with SMTP id 5614622812f47-39a523e8209so23410b6e.0 for ; Tue, 30 May 2023 21:07:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685506025; x=1688098025; 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=H24fyidw2Mts4UgybMsZXcSBtkvN1xbQ1AV6r3ckQ6Y=; b=G/pSZ3rHfbBc9FT/9EhIqO1JQHpC6oBXoh6ZpcAdeEfW8zBL8i8VI3hiSQOsxwa2SD jwL7aNWqW4Or9oCWX/308ICQUrRTjo1T22IyS09DovSiML2dEfC4D3WrIdsFtuWlr6Gv B+4D0YYx3O52gEXNKmMkAnMrAvthRA1nXPBRDnUHufqq+Gz6ZEcOFq/1+XfCgdKZJdRF yiclVOTDC85ImGEQ9ytv1SrmZF38B64ftsd7VRfIKZ+vynsuvYT7hA0jKfPMKzkm2x2D t2cs4nugi9kA+WV3rGXTh261b8bjxMpBFCg8ZwfMx/uMcs/MGV2NbX512gzD0RRM/VvN nxNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685506025; x=1688098025; 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=H24fyidw2Mts4UgybMsZXcSBtkvN1xbQ1AV6r3ckQ6Y=; b=TE1qkfhuvC2fIIHdFDgDxONPscAeNNejfyLfaOyVYkUFk4CHDiwqqf4+NQMNdvedyD qqquoXPIUDsTkS25l64KiOFtj/CGBFBtx2epcesRjOZNxGoqmVBngCsCHRwG1mig17va 4ngO46vXHb+8KxBCATwwlkrnJUtvhklzfTuHH1BZc6V5LSmy6nOeeezh2fcQxzQl26bV QSwdK/ka7a8fzPuIuGImKE/a4yUSSnlenV6gWSj9YUnALTOFgsw2wHQ8R6deLyHC2Na8 p+HVj4S7gLRPpim0Gfq9O6LPrrGSoNZvbjsulAcfw2Nd2xX+HR5Z7d6851c1yCbWp+Vk xeJg== X-Gm-Message-State: AC+VfDxm9o/ztGZkeFPp+LpOR/jwFw6sqy2rgD0O/Rb1Ns0U3WBJK5uT xbQ+9Fb0oatU2/Twby88vdNMfF3ivL/GDR9LQlg= X-Received: by 2002:a05:6808:2a6d:b0:397:c038:54ef with SMTP id fu13-20020a0568082a6d00b00397c03854efmr2459995oib.0.1685506024829; Tue, 30 May 2023 21:07:04 -0700 (PDT) Received: from stoup.. ([2602:ae:1598:4c01:1cd:ec7a:a720:ce9a]) by smtp.gmail.com with ESMTPSA id h13-20020a170902f7cd00b001aadd0d7364sm151797plw.83.2023.05.30.21.07.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 May 2023 21:07:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 42/48] tcg: Fix PAGE/PROT confusion Date: Tue, 30 May 2023 21:03:24 -0700 Message-Id: <20230531040330.8950-43-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230531040330.8950-1-richard.henderson@linaro.org> References: <20230531040330.8950-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::235; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x235.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, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_TEMPERROR=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 The bug was hidden because they happen to have the same values. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- tcg/region.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/tcg/region.c b/tcg/region.c index bef4c4756f..f8410ba5db 100644 --- a/tcg/region.c +++ b/tcg/region.c @@ -505,6 +505,14 @@ static int alloc_code_gen_buffer(size_t tb_size, int splitwx, Error **errp) return PROT_READ | PROT_WRITE; } #elif defined(_WIN32) +/* + * Local source-level compatibility with Unix. + * Used by tcg_region_init below. + */ +#define PROT_READ 1 +#define PROT_WRITE 2 +#define PROT_EXEC 4 + static int alloc_code_gen_buffer(size_t size, int splitwx, Error **errp) { void *buf; @@ -525,7 +533,7 @@ static int alloc_code_gen_buffer(size_t size, int splitwx, Error **errp) region.start_aligned = buf; region.total_size = size; - return PAGE_READ | PAGE_WRITE | PAGE_EXEC; + return PROT_READ | PROT_WRITE | PROT_EXEC; } #else static int alloc_code_gen_buffer_anon(size_t size, int prot, @@ -794,10 +802,10 @@ void tcg_region_init(size_t tb_size, int splitwx, unsigned max_cpus) * buffer -- let that one use hugepages throughout. * Work with the page protections set up with the initial mapping. */ - need_prot = PAGE_READ | PAGE_WRITE; + need_prot = PROT_READ | PROT_WRITE; #ifndef CONFIG_TCG_INTERPRETER if (tcg_splitwx_diff == 0) { - need_prot |= PAGE_EXEC; + need_prot |= PROT_EXEC; } #endif for (size_t i = 0, n = region.n; i < n; i++) { @@ -807,9 +815,9 @@ void tcg_region_init(size_t tb_size, int splitwx, unsigned max_cpus) if (have_prot != need_prot) { int rc; - if (need_prot == (PAGE_READ | PAGE_WRITE | PAGE_EXEC)) { + if (need_prot == (PROT_READ | PROT_WRITE | PROT_EXEC)) { rc = qemu_mprotect_rwx(start, end - start); - } else if (need_prot == (PAGE_READ | PAGE_WRITE)) { + } else if (need_prot == (PROT_READ | PROT_WRITE)) { rc = qemu_mprotect_rw(start, end - start); } else { g_assert_not_reached();