From patchwork Tue May 23 13:53:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 684976 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1740131wrt; Tue, 23 May 2023 07:09:01 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5PqBSJzBZIqRdpePnGMOyQWyiJ994RXC/b4dOIo6vYn5yGGVrr0wmVT2FLK8qnIjuS5X5L X-Received: by 2002:a37:f70b:0:b0:75b:23a1:8e64 with SMTP id q11-20020a37f70b000000b0075b23a18e64mr3976177qkj.53.1684850941030; Tue, 23 May 2023 07:09:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684850941; cv=none; d=google.com; s=arc-20160816; b=ir/3H1/yEvcYu74zF5TTCbUozaUdrYZiSSW1t3YDywiUogKD6alqpLsmDrc6bfZk/y 07RLgLjR9k8wcwkcy5ESc8A59Av6JVrha0zqUaTXc65FKCZPrirq/z4Y1TnhB0D1U0w1 +EYq/TzRRf1ebMetu9//aJsBaEBqHnIaW4ahsR61ilt3CdwnuZ1UIjsFUNwVGxT3ZbYp CcjaxxQq+WBKHim34x2tuSLlrOTsCQXyxfHMwl4+BqEjV6Z1NFjKpYqHiScgrEux/Yyi Y5sZRkqaNSMaqahjvruS/3P9+AXzcJuI+RJNxyPatKoxrvwMmb8kUhMgKFGF1J3YYlQA ETVQ== 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=OVmsUx5trCwxWekmTd1RE9Nb9Hhxj1t4Uos0U6OmJ/w=; b=sGiC1x3Qa1w9B1M1neLPd0Y+LGZIaqua7uCuQRyP8e7Ye5eJFIIhHb3YRrz8gFMwzk gsiG3jtYwIECRXuitakMs/txWT1nn2L7FN/7qH1h3PVLDN1eR4XBrF5qy5iUfl2vyqUy /tfbAiQ1phQ9FSIvc6X+1U0MqxhtdLmzTlqDk8t1AjzNSZKcILiAb99xg98epBeX6wlM CiWXAB52kn3gVTxMjzNBX7HnBdYYsp/+Wq5zVpDW/88aZHSNQVOrfeR5Ytu4BAu1yOLe l7M+8eAGF0A+MXzTJlGRlWHhMSZeplEdKdC03nbHN7QBdIiUHpY1XHIKoi8aBX/ESSQt oiyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rd5dBAFJ; 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 t5-20020a05620a004500b00757903685c1si4941930qkt.417.2023.05.23.07.09.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 23 May 2023 07:09:01 -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=rd5dBAFJ; 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 1q1SVj-0003QN-Ou; Tue, 23 May 2023 09:57:11 -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 1q1SVe-0003FB-20 for qemu-devel@nongnu.org; Tue, 23 May 2023 09:57:09 -0400 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q1SVb-0004Cs-6L for qemu-devel@nongnu.org; Tue, 23 May 2023 09:57:05 -0400 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-64d3bc502ddso5122350b3a.0 for ; Tue, 23 May 2023 06:57:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684850222; x=1687442222; 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=OVmsUx5trCwxWekmTd1RE9Nb9Hhxj1t4Uos0U6OmJ/w=; b=rd5dBAFJ+i2tym6Xr9t6sA6gQH6AkVzfIwKiViNeTK3GxHP+cuudVqCIJtFkPE5dk9 IH6sINRdT716LrbMqWDZLAFsuYVOBxzsfBNjQfW5j0qmU5ox3H8gX56goPYWxX8dvch8 IDC70dckXsrInY/tyEAQyT2OTRUnb3D8W41VDV62TrMZqgWUuJ5f/2FSEhsrU7+4xeEh EOtubzR+ZT+uSJcaZV+f69+wP2A5L+qJG3VHdYehpP8gd68VoMkKxFB0z3WW9DqPzNfL telci+jAWDkGD9KBzcxWN9gv2I4szKDKFWDGtmzKNPQ3VdRq/t1nkvdtJhgi6JKHas1f eWGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684850222; x=1687442222; 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=OVmsUx5trCwxWekmTd1RE9Nb9Hhxj1t4Uos0U6OmJ/w=; b=BCglddv7qEBJ/NlAtSHX1VBqHtIxpSADTi/xCyP5RsAXb03GmyKyzTDBBHYbxlAh3+ Jkq1GkZNqtc94cLLEIyl1wjTpblgVypgQ1rziQTuTWFqTFObM2OvdrW99kLS8/wb6X3/ V7vrF58WEHCNwByRY/3zxzsUHz1Y7BTRQ+fw7Jk26RnWgErgt1Lm4raCWgznerXD0Jfn TLbV6IBAVw+rv3y4jBb4mBubZTCOsVPDgGT9lSotjg2LSLHNgV69hiycHc6XvhTnoJqr vMVCANs/PyHlBfdLnPghHhbLlOkkjwpApFZP34s8HQoI3N0NEZkcGQzPruQMJoEF6kpW dn6g== X-Gm-Message-State: AC+VfDzjrWsbMFWcqsREwvHMqr7mQJGCKbTxzhE125yYYYbj8GoDN6SX OpSIQAg/E6A1bfG4IKFXPA87U56r7yUmI/bDy1I= X-Received: by 2002:a05:6a00:1307:b0:64b:256:204c with SMTP id j7-20020a056a00130700b0064b0256204cmr18298429pfu.20.1684850221464; Tue, 23 May 2023 06:57:01 -0700 (PDT) Received: from stoup.. ([2602:ae:1598:4c01:c13a:d73:4f88:3654]) by smtp.gmail.com with ESMTPSA id v11-20020a62a50b000000b0063799398eaesm5805790pfm.51.2023.05.23.06.57.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 May 2023 06:57:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 46/52] tcg: Fix PAGE/PROT confusion Date: Tue, 23 May 2023 06:53:16 -0700 Message-Id: <20230523135322.678948-47-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230523135322.678948-1-richard.henderson@linaro.org> References: <20230523135322.678948-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42d; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42d.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 The bug was hidden because they happen to have the same values. Signed-off-by: Richard Henderson --- tcg/region.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/tcg/region.c b/tcg/region.c index 34ac124081..184e684b04 100644 --- a/tcg/region.c +++ b/tcg/region.c @@ -507,6 +507,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; @@ -527,7 +535,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, @@ -796,10 +804,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++) { @@ -809,9 +817,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();