From patchwork Tue Aug 29 22:02:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 718263 Delivered-To: patch@linaro.org Received: by 2002:adf:d20a:0:b0:31d:da82:a3b4 with SMTP id j10csp244281wrh; Tue, 29 Aug 2023 16:27:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHVsTdYAZMIWHXal+v0ofCFbYZbr5xFnMGQhw/ks7oem0hcR1mKuNCCHgcz9aBtGgTZFtId X-Received: by 2002:ad4:4204:0:b0:64f:42eb:92f3 with SMTP id k4-20020ad44204000000b0064f42eb92f3mr465790qvp.45.1693351676623; Tue, 29 Aug 2023 16:27:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693351676; cv=none; d=google.com; s=arc-20160816; b=OzB8/gfVX7NQzjHYh/9ejAkSA1APeXiIX9A0YcAgYkzLJ9sQw7U0KEbyLoJ1vx274N /VHo5Ct67KCdEny8tFPxIZTsocg+flXV94jONfOo+l+ijItmQ9cYtzPYUORSDqg1GaKr tEO0l6MxC2fSV/vcX6tgUoYF65v5ywt93x5oS6W5ttfvVPL4T/JNKGKsfHZmWQoizISO rexZdhrS1muN/rkYwVFmnZn/UYuQ/kdzensjRVO6LawrNCLpfNp0AIE2StW9NSi5cbSh 3p5EH20EkFyric++TLrrvS+KEyFjfK2TBKQyxEUDkeu68jZAovzAl8FLLajQ+AICVQaP X8mQ== 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=RtG96b3jmli1q7lVtewuvoGgDoJMS7AqHQZel0hsDHw=; fh=CQVgvEA797/6AHlvAuip4Dfdeigp3YyNGto1GCMbIo4=; b=dtSXj8HMdNRzpLKpbqY4VIm0/Ou+QbEgHhl9gHZ2PBi7buYqOeE3joRqv41Nl2rW9P 4p2gOByzsPpnn4CswUM8NVbI+3WBeeXfWz4rIurg9fV6ce2LZI4ugCCf8lfpnROghCTc 3rPNvY+vG0W8FC43eLgXs87aI0ybj0YCiZU4rBYH0oedkim73cN2BCUSVhxLoJ9xBOOj jTl7PyOB1fDcTWemXpcWnjcxJFv/7jITPExwq+HaTrkgiMsqy4iKvBXhmp3g7AtPTMWa KpFOG0S2oRbketsXxuy+b5jiRdsdTuAIrT0AJweOOqxOqkahoTh++T4kyDUc0vhhrP8K /x+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zuISEipD; 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 bs39-20020a05620a472700b0076efe86cb67si5025026qkb.446.2023.08.29.16.27.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 Aug 2023 16:27:56 -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=zuISEipD; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qb7ov-0003GG-LZ; Tue, 29 Aug 2023 19:08:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qb6nJ-0002Ns-If for qemu-devel@nongnu.org; Tue, 29 Aug 2023 18:02:42 -0400 Received: from mail-oa1-x36.google.com ([2001:4860:4864:20::36]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qb6nG-00048t-RL for qemu-devel@nongnu.org; Tue, 29 Aug 2023 18:02:40 -0400 Received: by mail-oa1-x36.google.com with SMTP id 586e51a60fabf-1cccbd43250so3481872fac.1 for ; Tue, 29 Aug 2023 15:02:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693346557; x=1693951357; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=RtG96b3jmli1q7lVtewuvoGgDoJMS7AqHQZel0hsDHw=; b=zuISEipDTVKCziWcRRcRCa/WR24i2orPvxaPumvEN2L7yH17vV/NRNhkqnHSAqxvQt vAluQA5u5db/553lY5BVJNl9BsAHxf3S5ZeNixfQ24FBBDlVBRjHmHGJuc5Lu+mJRQse imy4Sv8Z/eFOIt9siJ6xlkEtX71moX0TI6I5GnuHPK5yZuAW1lZ/9BL/R/OFgxswiDU7 MnCBS9zPlbZ9Ondf6WDg71ttpbGWpRF/43dHzIKaNPp+A6weEjJQCTbmm4SXBTx3sZyq hb7l/3zcMOkMPJipZqpBTCkUAa0EONhlaScw5hZZBl1dIo3Ya6Cz1ENvvClLUtjZYfEd L/tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693346557; x=1693951357; 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:message-id:reply-to; bh=RtG96b3jmli1q7lVtewuvoGgDoJMS7AqHQZel0hsDHw=; b=eZyvbFuJX7nnyCLvqr6XJ9/af8teVwSD13Z0oZxfvEjvVgx4KK7Dyk7D9jSMoq5l7x UUDGkHGqKhWMGhR3v731VpLqPC+pj8Ooe46+7eTYMIOSeD1nD0z2hKoqbTEBg8YkBYd/ HS1N00IAzxA9ZoMt/EFLZ+EiOSGAXxWeHWnZv1TTFGMce6wJotpciuZH0w/s4+jFkmIa xmXIVO3+G7gwwRdiDj/6+Yi954kqZg0zn5GnWTKWMtNtksY0GyPowjWEFzhGuRny/xd0 k3Yt/cOE/b3RkBDvrHSE0aws+VCgJuSF+6OJHNz6Jml3tsUO0Mn5cqFAPHxRgnv0AxCi 64vw== X-Gm-Message-State: AOJu0YxYrooHJLtA2B79UlDsxBITSzS79b9XMoRR7hjYdDUcAS2ry5Cp tkQ5ytplcHwFQSsHy1FceZtsVa9EJkg88McRqX4= X-Received: by 2002:a05:6871:205:b0:1c8:b715:6c81 with SMTP id t5-20020a056871020500b001c8b7156c81mr548472oad.55.1693346556873; Tue, 29 Aug 2023 15:02:36 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id b28-20020a63715c000000b0056606274e54sm9538196pgn.31.2023.08.29.15.02.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Aug 2023 15:02:36 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org, laurent@vivier.eu, =?utf-8?q?Philippe_Mathieu-Da?= =?utf-8?q?ud=C3=A9?= Subject: [PATCH v5 07/20] linux-user: Replace bprm->fd with bprm->src.fd Date: Tue, 29 Aug 2023 15:02:15 -0700 Message-Id: <20230829220228.928506-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230829220228.928506-1-richard.henderson@linaro.org> References: <20230829220228.928506-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2001:4860:4864:20::36; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x36.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 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-bounces+patch=linaro.org@nongnu.org There are only a couple of uses of bprm->fd remaining. Migrate to the other field. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- linux-user/loader.h | 1 - linux-user/flatload.c | 8 ++++---- linux-user/linuxload.c | 5 ++--- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/linux-user/loader.h b/linux-user/loader.h index 311d20f5d1..5b4cdddd50 100644 --- a/linux-user/loader.h +++ b/linux-user/loader.h @@ -74,7 +74,6 @@ struct linux_binprm { char buf[BPRM_BUF_SIZE] __attribute__((aligned)); ImageSource src; abi_ulong p; - int fd; int e_uid, e_gid; int argc, envc; char **argv; diff --git a/linux-user/flatload.c b/linux-user/flatload.c index 8f5e9f489b..15e3ec5f6b 100644 --- a/linux-user/flatload.c +++ b/linux-user/flatload.c @@ -463,7 +463,7 @@ static int load_flat_file(struct linux_binprm * bprm, DBG_FLT("BINFMT_FLAT: ROM mapping of file (we hope)\n"); textpos = target_mmap(0, text_len, PROT_READ|PROT_EXEC, - MAP_PRIVATE, bprm->fd, 0); + MAP_PRIVATE, bprm->src.fd, 0); if (textpos == -1) { fprintf(stderr, "Unable to mmap process text\n"); return -1; @@ -490,7 +490,7 @@ static int load_flat_file(struct linux_binprm * bprm, } else #endif { - result = target_pread(bprm->fd, datapos, + result = target_pread(bprm->src.fd, datapos, data_len + (relocs * sizeof(abi_ulong)), fpos); } @@ -540,10 +540,10 @@ static int load_flat_file(struct linux_binprm * bprm, else #endif { - result = target_pread(bprm->fd, textpos, + result = target_pread(bprm->src.fd, textpos, text_len, 0); if (result >= 0) { - result = target_pread(bprm->fd, datapos, + result = target_pread(bprm->src.fd, datapos, data_len + (relocs * sizeof(abi_ulong)), ntohl(hdr->data_start)); } diff --git a/linux-user/linuxload.c b/linux-user/linuxload.c index 5b7e9ab983..4a794f8cea 100644 --- a/linux-user/linuxload.c +++ b/linux-user/linuxload.c @@ -39,7 +39,7 @@ static int prepare_binprm(struct linux_binprm *bprm) int mode; int retval; - if (fstat(bprm->fd, &st) < 0) { + if (fstat(bprm->src.fd, &st) < 0) { return -errno; } @@ -69,7 +69,7 @@ static int prepare_binprm(struct linux_binprm *bprm) bprm->e_gid = st.st_gid; } - retval = read(bprm->fd, bprm->buf, BPRM_BUF_SIZE); + retval = read(bprm->src.fd, bprm->buf, BPRM_BUF_SIZE); if (retval < 0) { perror("prepare_binprm"); exit(-1); @@ -144,7 +144,6 @@ int loader_exec(int fdexec, const char *filename, char **argv, char **envp, { int retval; - bprm->fd = fdexec; bprm->src.fd = fdexec; bprm->filename = (char *)filename; bprm->argc = count(argv);