From patchwork Fri Aug 19 03:25:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 598470 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:4388:0:0:0:0 with SMTP id w8csp1063192mae; Thu, 18 Aug 2022 20:27:28 -0700 (PDT) X-Google-Smtp-Source: AA6agR4SvRhA9Vehol0hygEznPKWPD2gbB9bpBVASdFDGr7jF4LEZwUFCuP0MrTFzAKSU06Xv7+I X-Received: by 2002:a05:6214:2606:b0:496:c5d7:dbd0 with SMTP id gu6-20020a056214260600b00496c5d7dbd0mr718229qvb.86.1660879648577; Thu, 18 Aug 2022 20:27:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660879648; cv=none; d=google.com; s=arc-20160816; b=UjtNVtpzDZNMZ3MXh67/ZHk/zV1beFubJpJ6iXu67bM8h6ZwsCaM5n13LIUT5bcanh z4Co+vvSreBbxkOHzICwbHM9C+xkIrfnjf0WtBuKegb8YrWrp34SwhtCXiG1vDzP8a5l z3Nbro/og+B3xGHuZ/cxPsC/ngDD/U6ULEH19oInDelTDq1IAo9CEHPFNzuBWzDF57ac URnieJrSKr/hkGwIxjU6KHttwmk7+YfINOxdVMe/35Zr/K1Htv09au5SVA7PIU1FF02P 7uauIbS6FffLgbEYmvENa0t9pQ2Za10ckRFtgMX5XJDfzRsQ1Ynkhk+3tFiiRww36gzU hyLg== 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=ztH2KdOZugDOiuPkZQawXgA4F56Gwh34Y3mDIuElS7Y=; b=hXjd0PnoZduSQvisFllJYB5JLKZCEwyUu5MF93r/AXnk3Pd997d0J6EA/ag8AUlEI3 2dFglREXvh/MrP4RtmM6wQw6CwG0pdjl/VaMZ3hwtV+2beMq+WiiWYqiJgOG2tDm24Qo 3/qBf0CfHOj2bFrvcxSzwNiEwXQY8/mGGyVCv4VUl+lTo5UQCQzl4ETU6nkEDo13CItQ 0+O7NBg/rG1sOT5rgeAOqGz9uQUL+KjSBNcVgImZDOsxc7qn+aCf/+mcmtzgnTgOf6Eu z+l+8V3M3iORaT8y3P0lT4Z0CV4Cc/0zfQnN0vSH+g5stwt654U4sujrOQtSFGWT9Tdr vdnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=x1MCq2nI; 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 bv10-20020a05622a0a0a00b0033c616d2192si1566044qtb.713.2022.08.18.20.27.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Aug 2022 20:27:28 -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=x1MCq2nI; 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]:49422 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oOsfQ-0001S5-5p for patch@linaro.org; Thu, 18 Aug 2022 23:27:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37342) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oOseL-0001RY-OB for qemu-devel@nongnu.org; Thu, 18 Aug 2022 23:26:21 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]:36788) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oOseK-0002iT-9A for qemu-devel@nongnu.org; Thu, 18 Aug 2022 23:26:21 -0400 Received: by mail-pl1-x631.google.com with SMTP id c2so3108230plo.3 for ; Thu, 18 Aug 2022 20:26:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=ztH2KdOZugDOiuPkZQawXgA4F56Gwh34Y3mDIuElS7Y=; b=x1MCq2nI2WuzpIlYXbl/jpbHcEo+NJaZbvN7kEPMwYzB8tJ1oDNLN/vqkvC5E0Z3z+ 2k3Sex1yChUeKGmPU2qXopnIoLjXUdlcxKARRoprpH/8Z6nACdsoMHzKfssVSndhuA7z lmSvqU4Lnx5k+mmtkpEM2WY4hAFYZh4jr/8tNbbtl1xtozjxi0Rf//X6YU8LUlNhWeE4 ux67HkKsFZ0nqrtg2D5KpGAVlROdv8x+R/gjhmtXtRONjNe6sZh0o83vJzlSLBoonpQu po4WbtG/1KZTsfehSBqKeo3hGEByUWaue9domADT6zYUN5dueaqb8EjRs9Z9dFlhxDQB PHug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=ztH2KdOZugDOiuPkZQawXgA4F56Gwh34Y3mDIuElS7Y=; b=bQQD6+QL5KkoV9cHuscDyPB+vc3+7OMQJK3dx3jG/1Ena3Y60MIFQwFRsbnhQiNhTh 00LxiXdPpGJkSwftKGH7pP2hZzWr8oFhqABltmK4GgvJ9H2RnL3v9NatVWOnwvR8JBNx joEuINO8S0eWaVY2VXuiFfgL2krhpBMvc3SNGpJ13IQNFmsk/HKNvanfPbvMY1vG59TI gtaESQL+vrst4At1/OFei417uAMEqPpamMg8Ba2SslhUD56YSB89QwDbW/8LP0t9YL78 AWZ71izn/vtopidBMOBv30OjQ5Igse2U3QIE98YCVzADvfb2epSt6vfAuowu2V+QOket nBAg== X-Gm-Message-State: ACgBeo0XvF3AAKqgxTvgn2FwgUkYVAlkO//QGYpgAeZI9oX33oMzGJYW AgnLsI+KCxtfuykW7oxymV6gaLAT0xD5Lg== X-Received: by 2002:a17:90b:33c4:b0:1f5:8428:beb9 with SMTP id lk4-20020a17090b33c400b001f58428beb9mr11821825pjb.95.1660879578520; Thu, 18 Aug 2022 20:26:18 -0700 (PDT) Received: from stoup.. ([2602:47:d49d:ec01:bbf3:9914:aa9c:3b4e]) by smtp.gmail.com with ESMTPSA id g184-20020a6252c1000000b00535d19c46d7sm2199904pfb.203.2022.08.18.20.26.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Aug 2022 20:26:18 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, iii@linux.ibm.com, dramforever@live.com, alistair.francis@wdc.com, alex.bennee@linaro.org Subject: [PATCH v6 01/21] linux-user/arm: Mark the commpage executable Date: Thu, 18 Aug 2022 20:25:55 -0700 Message-Id: <20220819032615.884847-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220819032615.884847-1-richard.henderson@linaro.org> References: <20220819032615.884847-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.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" We're about to start validating PAGE_EXEC, which means that we've got to mark the commpage executable. We had been placing the commpage outside of reserved_va, which was incorrect and lead to an abort. Signed-off-by: Richard Henderson --- linux-user/arm/target_cpu.h | 4 ++-- linux-user/elfload.c | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/linux-user/arm/target_cpu.h b/linux-user/arm/target_cpu.h index 709d19bc9e..89ba274cfc 100644 --- a/linux-user/arm/target_cpu.h +++ b/linux-user/arm/target_cpu.h @@ -34,9 +34,9 @@ static inline unsigned long arm_max_reserved_va(CPUState *cs) } else { /* * We need to be able to map the commpage. - * See validate_guest_space in linux-user/elfload.c. + * See init_guest_commpage in linux-user/elfload.c. */ - return 0xffff0000ul; + return 0xfffffffful; } } #define MAX_RESERVED_VA arm_max_reserved_va diff --git a/linux-user/elfload.c b/linux-user/elfload.c index ce902dbd56..3e3dc02499 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -398,7 +398,8 @@ enum { static bool init_guest_commpage(void) { - void *want = g2h_untagged(HI_COMMPAGE & -qemu_host_page_size); + abi_ptr commpage = HI_COMMPAGE & -qemu_host_page_size; + void *want = g2h_untagged(commpage); void *addr = mmap(want, qemu_host_page_size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0); @@ -417,6 +418,9 @@ static bool init_guest_commpage(void) perror("Protecting guest commpage"); exit(EXIT_FAILURE); } + + page_set_flags(commpage, commpage + qemu_host_page_size, + PAGE_READ | PAGE_EXEC | PAGE_VALID); return true; }