From patchwork Thu Sep 1 06:51:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 1672682 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=ic3hhYqn; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MJBnw1kn0z1yhR for ; Thu, 1 Sep 2022 17:02:58 +1000 (AEST) Received: from localhost ([::1]:49808 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oTeE3-0003Uj-Cw for incoming@patchwork.ozlabs.org; Thu, 01 Sep 2022 03:02:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59116) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oTe41-0005uu-Pa for qemu-devel@nongnu.org; Thu, 01 Sep 2022 02:52:41 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]:39717) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oTe40-0003Gu-3C for qemu-devel@nongnu.org; Thu, 01 Sep 2022 02:52:33 -0400 Received: by mail-wr1-x435.google.com with SMTP id az27so21014549wrb.6 for ; Wed, 31 Aug 2022 23:52:31 -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=yfnHu4EbbnRvw3l+CBQz1H5c9gnGaVUZEDhcbvAt58s=; b=ic3hhYqnPJ5I0nsVaP+B4tQS1ELAfQC4B0QPJnYOXLTSg0mXdETrZd0ileEs7LqMj3 Fmz3zHNH6ml/ad4SA9lGzAzh3gjbGGdW4g+xKTzW0rlKEQfHyCK5eUlVUBGrOCiPj4h8 PFDthGaht+LJ3jPsIccb1pArT92miBNu+9meLynSqO3MsA6h+huSRHaN+TQkswGYOASe TRwhWvDTth/uAN66ilVBY2EoyLpiJVZjQj2J6v88Bq7t3DD6zZoFPBaGW/eSm0768Xk8 KDx46A+smCE7YiLNqVE4AcASbnC1Uqs5gPPY99PTorAlH/9bSb08LIZ0oxnld2Mfxyhi y/fg== 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=yfnHu4EbbnRvw3l+CBQz1H5c9gnGaVUZEDhcbvAt58s=; b=QgT70uxDrdXtteR24ouiV7WqDV/NIx+DIlFgUm4r59L5j3A3cndu2H2XFMyS447WNx VWt8jrZ5w0jKxRNkVj8S2U19QRkGYxyJ/QuFMQ+g7AKSGzOkOldEsTbLFtqv3S3ytXys B+lLb/eWP5Ifkcd+Lhe+JjF1VXp4SvoJE5a6aHQ4zWoweF6Xo+cqMmJDkcySHYFfrvEG wnDSijRSG3nnFw/UmdY9eYHvB1dddJnlIcPGBulC/dUapo0VHP0fNBu7mxGust3DSfPk WsJqMBfADfy3yYS6PFkMzYZ/eveoqCtJNvwxObdCD4GPiq3LPhdj2IQh/cocnaV8AgFG pX9g== X-Gm-Message-State: ACgBeo3k+pOHSGvcFQbj/0Al6nwFosSi1OO77sjLhS9EGKXuS9j3mxYD Pl03agEW9UzjZAVdzzYi37WdOICyghaCADB2 X-Google-Smtp-Source: AA6agR6twWaBoAEkebxSL9onk6TeWqSCgEKxJOtFX/RyKJhqp4mmNpzIYVyS/RR+gYt3Av37hfsiqA== X-Received: by 2002:a05:6000:81b:b0:226:bada:a5 with SMTP id bt27-20020a056000081b00b00226bada00a5mr13698448wrb.539.1662015149937; Wed, 31 Aug 2022 23:52:29 -0700 (PDT) Received: from stoup.. ([87.192.221.83]) by smtp.gmail.com with ESMTPSA id a6-20020a5d4d46000000b00226dedf1ab7sm8308153wru.76.2022.08.31.23.52.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Aug 2022 23:52:27 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich Subject: [PULL 03/20] linux-user/x86_64: Allocate vsyscall page as a commpage Date: Thu, 1 Sep 2022 07:51:51 +0100 Message-Id: <20220901065210.117081-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220901065210.117081-1-richard.henderson@linaro.org> References: <20220901065210.117081-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x435.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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" We're about to start validating PAGE_EXEC, which means that we've got to mark 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) {