From patchwork Tue Sep 6 08:37:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 602953 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:4388:0:0:0:0 with SMTP id w8csp4332263mae; Tue, 6 Sep 2022 01:45:00 -0700 (PDT) X-Google-Smtp-Source: AA6agR4dcFChaMW6vs2AjX85DFSmhRPjs+IbhVguvZJpay4tlmCP2C8K8Enj0Nu0Vf4OTe2d4Yb+ X-Received: by 2002:a05:622a:105:b0:344:f85d:f19a with SMTP id u5-20020a05622a010500b00344f85df19amr42259745qtw.49.1662453899903; Tue, 06 Sep 2022 01:44:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662453899; cv=none; d=google.com; s=arc-20160816; b=driwRfNr2i5rO9JjKdw4b+757X8okvfSN0BRhMKEuA493mFxCDZ99OQmb3PsK7QhTq rJJYpY6tKX2ckMqFIb3nIZFvJ3aF5zWOchqZvK2/YjvjwIZ7Ry4sCSIm7SfPva+XcgQD WHnnHiN4FNL+G5Su4Jk9MZ+LwjLly5cheam50dcQr9HSydnyLPlVvsTSt6AQahqdnZSQ q/8RzcH2h5u8Ua2PRBCul1RzPUeCKVOT3F8H8griEK1Jaa2rIABMHYf260Q6s6oMTrG/ rksU3/ruXHuuSCMYelZk4BNRdYEZbZGt6nF931jBptd0I1VpDQVizzNKsdv8LILAhilJ 8tkw== 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=cnDX4PL0OXe9dOqXgYaSV2oqzwR9gOMv9I1pf97HvaI=; b=oaymMU6JnTynN8r7uyM5+KCeypFujUts2nkXmXRSDUXqiF++AtJHCucfh8X0nmlTT7 RF0amaUVK7ZJErhOquphJt66q7+9xZhtuwcq2P33aoN/71lVTq8gXWVHlTLRU0VS7Xtn 4TMQp+DLz1ABg1Bo5nT5p7pvd9QbiPMbISrEOK8RKW9IAqvpwVr1MGG22yTD+LLXt8hZ f0AG6DbHEDFL4idBOZbvQU23EBJVe6esUFxSkPcptTYo+LEPUIQaR5vOr5z2eZBA/F1T QxIviUYQRc2hC1HcsHdujKeRxj1Ou0SkfgzgiXUkibowDky4FQDhnGrVdpP4RrOxxBni oUTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NgeEloTq; 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 8-20020ac856e8000000b0034464ae76f5si7053918qtu.511.2022.09.06.01.44.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Sep 2022 01:44:59 -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=NgeEloTq; 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]:33312 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oVUCZ-0008V8-Bg for patch@linaro.org; Tue, 06 Sep 2022 04:44:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57608) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oVU6E-0002WL-Na for qemu-devel@nongnu.org; Tue, 06 Sep 2022 04:38:26 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]:35577) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oVU6B-0005SS-Cg for qemu-devel@nongnu.org; Tue, 06 Sep 2022 04:38:26 -0400 Received: by mail-wr1-x433.google.com with SMTP id bz13so10891525wrb.2 for ; Tue, 06 Sep 2022 01:38:21 -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:subject:date; bh=cnDX4PL0OXe9dOqXgYaSV2oqzwR9gOMv9I1pf97HvaI=; b=NgeEloTqPwZf/t80BWHoQOMnEcmH//X/4Nwx9ugY39wAiJoakPz5alQTk3xwBmsb46 DrzCKt1/o1RrIuuvgdBt21z4d2WyPasswSrPL87LP2iycNV1vqBT6j+M3SbVaaDkEwN6 BgXB4mDiROEc9Hk0xvQajrP11zBV69bbNpTIf+f+sDZ8E5p7GdGujn6HykHWEBycsZjG dtd4OyFGJBWaqsKs561Id6peOeg/vo6P4iXDnWBhYiNhdhVWAkI1baHaG1LIWZjAG29v kAaFfbh35b1JizmEJ+9ZxXz9GDcGDc0GfrxADEksf6sPsCTHbeVSVsgyQlG7ECYHXfC6 ssSw== 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 :subject:date; bh=cnDX4PL0OXe9dOqXgYaSV2oqzwR9gOMv9I1pf97HvaI=; b=F5uTmdxGvWdDAFhWQ2qtU5H7oqKHYX9Zlb1lh9ddDjIHKQBd3FXEfZrJa98nTe12Uj y3n9NQaGd99b18webHBzoX4w7Y6l1ZeAjeI4zkZzfdEh2BSsOWCBvtpKKoJc7NkjyHNV GpDrfWzgBBT3jca/rcIwo6v4/mRVMnta9+Pd76mnA4bOjfLGH66KnXJmT3fo8CHcH4ZY FFZBMmf/u1y7UBB+Nlwpuy8XitqJx/n+GLH68aCZ9utTQcAZ5RdwusYDJL37ySofTYwx TFTGX/S/DlfIwb5Hu0u7k4o+Ck3sBm83uJe+jP9kpBTGf+02lTq8qPPfXgZXelt4f1O4 yLxQ== X-Gm-Message-State: ACgBeo0rqk0OLVrybknWMH2bap5rXCLzwxybzx9v74DnovUCz4eoJLPx vsusNOZDwiCiHA+k5EwgIQzd7Rp79NJ/o3Ki X-Received: by 2002:adf:eb02:0:b0:227:1c:e760 with SMTP id s2-20020adfeb02000000b00227001ce760mr11614874wrn.635.1662453499252; Tue, 06 Sep 2022 01:38:19 -0700 (PDT) Received: from localhost.localdomain ([2a02:8084:a5c0:5a80:ba98:3a71:8524:e0b1]) by smtp.gmail.com with ESMTPSA id g26-20020a7bc4da000000b003a54f49c1c8sm13421859wmk.12.2022.09.06.01.38.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 01:38:18 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, Ilya Leoshkevich Subject: [PULL v3 01/20] linux-user/arm: Mark the commpage executable Date: Tue, 6 Sep 2022 09:37:56 +0100 Message-Id: <20220906083815.252478-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220906083815.252478-1-richard.henderson@linaro.org> References: <20220906083815.252478-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x433.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. Acked-by: Ilya Leoshkevich Tested-by: Ilya Leoshkevich 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; }