From patchwork Tue Aug 16 20:33:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 597504 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b345:0:0:0:0 with SMTP id w5csp2694470maz; Tue, 16 Aug 2022 13:36:42 -0700 (PDT) X-Google-Smtp-Source: AA6agR4a2qla/i4rgonclMTp04XB9HfbhckH3pBc2v2eNninc9NjCRqmtLzyW3fnUxjzp25I/CNB X-Received: by 2002:a05:6214:f05:b0:476:99a4:26b6 with SMTP id gw5-20020a0562140f0500b0047699a426b6mr20287810qvb.121.1660682201975; Tue, 16 Aug 2022 13:36:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660682201; cv=none; d=google.com; s=arc-20160816; b=YYVl95fASWaiLP+LMrFoYUA0o6k8s/kAvgiWU1lZU+LVYOOkLteivsNA3mltEVvq1o rlJEI82nc1tuoreY7P4hl3w/na50GaixQVgySOvcSorcEsFT9UgUAKMH2vfJKYsnYQ7q +pdzY9FnwTjO77AjEej/9dvzFfyiTe7Bc420c67afVqQIDtgukT2EQ5zmK/XPGxYTK+z NR3i8lz/xwdqsUISLV+uOrophgyow7KuTqKbGI8ZOFA72TDe25iojR8KFltHWUpBVGGA R1cONoLoYTMxpedbyo3R+VD7kQeNEn2uE+ucNfYXh9kAYhTuu61pLV7xRop/vqHVsNPa hiYg== 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=X+2CEfgvZFxpq8e6EY+n5lvWBzz+vc8fFcrenQ8ZGDI=; b=ODOabxDZN7IhCmKomeh1s0aY+0RMHpptOPXlqu54RR8NhGR6hhzgNSeVZx5xWvOrzf tePPNXkz2NsNhBmMMi3WpSmIO5j0/GBRmQSW4t17587E1EvHqi65bseN9arqSazKqZdA 3nHoyYbpmbOKXmnS9y4STt9pBNXGngmawP97rXL049dDsCKCcKjZharEU8G8BOJ6sfKL /tZuxfa6ZTwhfQlymyLt58r5jzPZ34Ndn2khmZJTOwK3WYF6vj7KrtKtYMXFXLm38qnr Izt3B7gYxvCzqYKxUYBLPCyQ5ZWu+Hq46v2kidls4gxHpjxbzcn+pxEzDMnC/sKU/Gae aghQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wxp36Q2m; 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 t201-20020a37aad2000000b006b5d8ddfdb7si7559418qke.403.2022.08.16.13.36.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Aug 2022 13:36:41 -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=wxp36Q2m; 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]:60840 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oO3In-0004j3-GY for patch@linaro.org; Tue, 16 Aug 2022 16:36:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39362) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oO3GR-0004h1-DE for qemu-devel@nongnu.org; Tue, 16 Aug 2022 16:34:16 -0400 Received: from mail-oa1-x33.google.com ([2001:4860:4864:20::33]:35430) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oO3GP-0004U2-OL for qemu-devel@nongnu.org; Tue, 16 Aug 2022 16:34:15 -0400 Received: by mail-oa1-x33.google.com with SMTP id 586e51a60fabf-10cf9f5b500so12939958fac.2 for ; Tue, 16 Aug 2022 13:34:13 -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=X+2CEfgvZFxpq8e6EY+n5lvWBzz+vc8fFcrenQ8ZGDI=; b=wxp36Q2md0qnMRWC7iJRWrPljfk3YY4ss/v5NNmDqz9qd8HChkrMXEGw0Loj4dkLge Wt+QpOsbZhnimu1x3djtflOdpVih/xCGv9eTfUjj2tjuWiwMJ5Ldl+iDOlevU0ZLaER0 GLVx3J+sWamaF93Oaekmt1B/ku/w8KBZ/EdabhHGvyewIGKKVzMKXUbWaCwW3JEXyRBS PfNEKlL2fUst1eK4mkqlJMk3Y+2Mth0a+w8GRQAcB27FBiOsUqBOyd2ziSAzBsQRllAu 6Vkd4Z26TZ6Ev+NKzA5Vl11jrVX70XrkqWltEQGdCLey7vTXNc9IxaJV4ut3KRveN8KV zc0g== 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=X+2CEfgvZFxpq8e6EY+n5lvWBzz+vc8fFcrenQ8ZGDI=; b=Md7gHTwk77qY+vclC9oVmSzcZkFrN33p9KMlHiCBtd4c/sGgsGPz1eFUMB5mjLTfwh 8Cnk/1032rcE1SSZbkzRiQWMiQV/Pp7E9kKwFR7MAjrNQa4eA8usv5mz8jzCJeKARkg7 xZYm3NpWOpLCMG6sYx14OFPEM5+T4KlmSb7Lx5M+4LcRm22pKwceKLMocAXFTkZjtHbc iwlMsoFT7W0ajZNaV2NKya6kOGEdUVb2blN+DdZzHNoDOXmzr+31lcPdhiVM0r71av4s IVR+NCTzS8q3s1N1eV13MkmeMqXlPPuoHODxcGbb+o7FB+mBoMqKryhegHFZ0T85uaFw l0WA== X-Gm-Message-State: ACgBeo1Bb4LVuQy6RQgJSIlMChGld7QkSbWuyJyFn4/txdMxATvGBByv fT/jR0U2adu1dFsPKv6KH7BuycWOy0kc0g== X-Received: by 2002:a05:6870:4251:b0:10e:6ca2:5a29 with SMTP id v17-20020a056870425100b0010e6ca25a29mr161727oac.100.1660682052144; Tue, 16 Aug 2022 13:34:12 -0700 (PDT) Received: from stoup.. ([2605:ef80:80f6:61fa:9bc2:5095:d612:5e22]) by smtp.gmail.com with ESMTPSA id y23-20020a056870b01700b0010ef8ccde67sm2285220oae.13.2022.08.16.13.34.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Aug 2022 13:34:11 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, alex.bennee@linaro.org, iii@linux.ibm.com Subject: [PATCH v2 03/33] linux-user/x86_64: Allocate vsyscall page as a commpage Date: Tue, 16 Aug 2022 15:33:30 -0500 Message-Id: <20220816203400.161187-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220816203400.161187-1-richard.henderson@linaro.org> References: <20220816203400.161187-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2001:4860:4864:20::33; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x33.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=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" We're about to start validating PAGE_EXEC, which means that we've got to the vsyscall page executable. We had been special casing this entirely within translate. Signed-off-by: Richard Henderson --- linux-user/elfload.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 29d910c4cc..d783240a36 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -195,6 +195,28 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUX86State *en (*regs)[26] = tswapreg(env->segs[R_GS].selector & 0xffff); } +#if ULONG_MAX >= TARGET_VSYSCALL_PAGE +#define HI_COMMPAGE TARGET_VSYSCALL_PAGE + +static bool init_guest_commpage(void) +{ + /* + * The vsyscall page is at a high negative address aka kernel space, + * which means that we cannot actually allocate it with target_mmap. + * We still should be able to use page_set_flags, unless the user + * has specified -R reserved_va, which would trigger an assert(). + */ + if (reserved_va != 0 && + TARGET_VSYSCALL_PAGE + TARGET_PAGE_SIZE >= reserved_va) { + error_report("Cannot allocate vsyscall page"); + exit(EXIT_FAILURE); + } + page_set_flags(TARGET_VSYSCALL_PAGE, + TARGET_VSYSCALL_PAGE + TARGET_PAGE_SIZE, + PAGE_EXEC | PAGE_VALID); + return true; +} +#endif #else #define ELF_START_MMAP 0x80000000