From patchwork Tue Aug 23 22:05:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 599483 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:4388:0:0:0:0 with SMTP id w8csp2738353mae; Tue, 23 Aug 2022 15:09:30 -0700 (PDT) X-Google-Smtp-Source: AA6agR7v8GQTXiZkt5pAs+Apj3opdA0j43oFhwZrP2tKUroWiE99ooin8NxNgEjNKD/bwssueFga X-Received: by 2002:a05:6214:21ee:b0:496:f3d2:fa81 with SMTP id p14-20020a05621421ee00b00496f3d2fa81mr7325228qvj.1.1661292570244; Tue, 23 Aug 2022 15:09:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661292570; cv=none; d=google.com; s=arc-20160816; b=W8/n8pDXYn0kPg3SSqeZuD3GrES9R7tpZLojrgw+gbtMpeoAu2yo9N8TG+6caOvqIv lYMPBhwruLRL2UJ3BkS6cS1XZUCsmcMNmYA5TT94LwQQExtZpVM/S/4/iIqFUULjSnij 5QD4L8PLWRn+ZeFaVo946rSOeMJQviXDFke3wCJx0J1TOUA4caWPIIz1dC7zCoZWjYDA hHRtUMmIi5Sn3hvjvcIik8Qp/vonR11Q31teo7uNH5o+3WNDiXFg4SP7JaTzo/4dKY8b dmtfLRDpq2pwRCb+JSmRn0zKilShFzX3BMBisz1wurofP7YQ6VintpqpLSCbyCWCl8KT t7mA== 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=nZZ45pMxOHvR/MX8ViZjTrfSqbkn36lcVu6HChiZ8OQ=; b=qMrl+VgwGnEMKCNfvPH/RsBSGZ8c+xItVDO/5F5fKZeobvxv8E/6iWSbAHbWI2lXfT jePq82t6pZutpx7wxciXbUELWNDaW6LfgmGpPPw9erJiJzrQJ3DjihuuOHdGNoXjnVUQ rhKNj8POYJJJOXBiqpgUM6MdGcTi4YO3Y5S6hG/Qipk9k1QC7fkQ+4guTHvoD4FOzuvO z+cWln1iffvgnU+Ll82kQonA4WaIv4In4KCaiB0TR/+Q10axAqklDUpTKN5h4HCEoiPo iFeYbd0cHKhw3Psv/Bh3Vut60zQuHZWZ/Mbt3g8dVaor6y7mPAJaSrdOEHsfDtPKsNhJ J2og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cChtaknj; 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 x26-20020a05620a0b5a00b006b589557deesi6046120qkg.278.2022.08.23.15.09.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 23 Aug 2022 15:09:30 -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=cChtaknj; 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]:54034 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oQc5R-0005h9-On for patch@linaro.org; Tue, 23 Aug 2022 18:09:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42488) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQc1v-0008Gr-LU for qemu-devel@nongnu.org; Tue, 23 Aug 2022 18:05:51 -0400 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]:55939) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oQc1u-0001Pu-3n for qemu-devel@nongnu.org; Tue, 23 Aug 2022 18:05:51 -0400 Received: by mail-pj1-x102a.google.com with SMTP id pm13so6323479pjb.5 for ; Tue, 23 Aug 2022 15:05:49 -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=nZZ45pMxOHvR/MX8ViZjTrfSqbkn36lcVu6HChiZ8OQ=; b=cChtaknjKhnoPvTgrP8fOhPUSokcE98dVPDkCCRWU9exQL0UcbmsGMeJxX5v832Inx +NqyMQ+7rVLEHDsZcBxjlJ2UNkMvlH1L3/21Fj9IBe/LFQIu3c3IxIIHuGNkxLi46aFn 1FDhcJo+Ge+ixOLjKpXOJoOdrDofOpOK8BLyq7owUnTRYHw4klTGjjB1d3IHVRljxZzI Z3TrfM6I7bCjuUQBj4KWDAmfFutAj8SnUiyNuNp15gpkQFonildRLi3L6Ykn7ZbCqmpp CJN6nLm5snm7MxcH4KZNub4smasXkHPX4bYVn5lb2bSkwzssM4d1/lIUtiD+XDGT028z aBrw== 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=nZZ45pMxOHvR/MX8ViZjTrfSqbkn36lcVu6HChiZ8OQ=; b=G+GEM//Xqdx0GeOR7z5otxBREP3/kaRvKX/14NRCH52KxvNpcTEfTMx6066WA/c5wr UInDdWQX6FSAcyBHhGtLhRXmv9y1vpC1l+KPrufSey7E/3ZeSCdocOwtW4bPjFx8YyiL 1GRp89sRdf9vDHrSG9M6QNi+EJ7twZuyh4dm1T5flFkdncTzVhCLoq8Tm7prQRnYOPjc Il9D4dS+0dp44ANmr+is/4LepSSfX9gUYDR/rpsk55yG5A89K6T1UNXWxAz4bIXwyvP/ xKTarimir1+nWyOHXRZSkgogYcS+qc97dHET6YoDYDQ2Q7+VgAGXvtaTlE39AYXl4JJ8 hG7A== X-Gm-Message-State: ACgBeo0ZCvM1wQI623u6Ofdav+zZUluDIpI7XbKmnbHo31HdVPRrm1il Qt5ZTvnV4y9tjfS15ETtYFEi8HPwXYMHaQ== X-Received: by 2002:a17:90a:6707:b0:1fb:6461:695d with SMTP id n7-20020a17090a670700b001fb6461695dmr4786824pjj.158.1661292348583; Tue, 23 Aug 2022 15:05:48 -0700 (PDT) Received: from stoup.. ([2602:47:d49d:ec01:46f9:77b4:ec0a:c2d9]) by smtp.gmail.com with ESMTPSA id n12-20020a170902f60c00b0017292073839sm11020974plg.178.2022.08.23.15.05.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Aug 2022 15:05:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: iii@linux.ibm.com, laurent@vivier.eu, alex.bennee@linaro.org Subject: [PATCH v7 03/20] linux-user/x86_64: Allocate vsyscall page as a commpage Date: Tue, 23 Aug 2022 15:05:25 -0700 Message-Id: <20220823220542.1993395-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220823220542.1993395-1-richard.henderson@linaro.org> References: <20220823220542.1993395-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102a; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102a.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 the vsyscall page executable. We had been special casing this entirely within translate. Acked-by: Ilya Leoshkevich Tested-by: Ilya Leoshkevich Signed-off-by: Richard Henderson --- linux-user/elfload.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 29d910c4cc..b20d513929 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -195,6 +195,27 @@ 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 INIT_GUEST_COMMPAGE +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 @@ -2360,8 +2381,10 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc, #else #define HI_COMMPAGE 0 #define LO_COMMPAGE -1 +#ifndef INIT_GUEST_COMMPAGE #define init_guest_commpage() true #endif +#endif static void pgb_fail_in_use(const char *image_name) {