From patchwork Tue Apr 9 05:02:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 787192 Delivered-To: patch@linaro.org Received: by 2002:adf:fdd2:0:b0:346:15ad:a2a with SMTP id i18csp57970wrs; Mon, 8 Apr 2024 22:07:17 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWkujFRY36rBsdulODYSP7cPwOI+BerMp/wGeWdQdt12y3CUtsqjc1fAwmV6OWCnq5mgcIQkgRiGfhGEUWNb3sK X-Google-Smtp-Source: AGHT+IFUwL20orADl+1Uc6JCC2mcHCw6QMcY8OCTlkHSRPB2EtV6pncKt5oKhiZOqfGu/cjbS+JN X-Received: by 2002:a1f:eecb:0:b0:4d4:1340:df12 with SMTP id m194-20020a1feecb000000b004d41340df12mr7135480vkh.0.1712639236840; Mon, 08 Apr 2024 22:07:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712639236; cv=none; d=google.com; s=arc-20160816; b=BZVe6rO5ZNPL89XC9kOXh4XpqWgw71N1CCWncpk//atpBRY6BIkHVyKOE9+owc/tzr 3cq8tGzFygsN+vqof6l7QMWU9/Dra5JA0z4dx7oBeptEwszohUoHMeyoEjfERaL22KST Nd8MU0GjKJ4CifILO+eJfxLARaPSzpMcRRVlpRqPcYaqbjbfHhcA5q7sXPfhQfPgUi1B FMZuBwzhhHUupTGu7dI8H82k3pFzuvZovO7Zqfzn18m2kot2va3HUuhDevmEprDqPHJx kfFx+hgv/lbVo4j06EtGD7QJqcsq+3srxohMhCUfdkjUDhurEbejgXu0mnEqgqDoOkMT SvLw== 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:to:from :dkim-signature; bh=Lwz2AVaZ4jMxsAZ0LmeafrPRZnLD2nezi1yCURh51Zs=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=O+8O/hdMtpNVsRIBgNCDRexGFNtbSTcXvJgHYftSSJePLBgKoSc1ztPJRJOAz3jNiT 6aM0IFMVf/Jg54SZO9ZjEpinJrlBHrnfgh+LSO5NYApHnfbpJ5F/xn0lm31Dz2oOODUw 3u4ZxX6xhzq3NlCokz3qA5/NaueNyC5P+w/13C53GxAT/TtgmGopIH05X+KQk5V7Ri56 TLCrs/bKzr5BYx50brZ8UnYjl1Sh3nNPWFVjcptwjEH+JbUPlEHYj0fpyNn1ursURw5u NPFmzY5PbiUQfpoxFDaPUHkbJ7/+7oqk7UBNV3XLP31Agld3Re83Acz75pysXnkZI/mj pArQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZZXtMsrM; 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 z2-20020ad44142000000b006992c2d0c66si9644993qvp.458.2024.04.08.22.07.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 08 Apr 2024 22:07:16 -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=ZZXtMsrM; 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 1ru3dv-0003E9-Py; Tue, 09 Apr 2024 01:03:35 -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 1ru3du-0003DR-Cv for qemu-devel@nongnu.org; Tue, 09 Apr 2024 01:03:34 -0400 Received: from mail-oi1-x22d.google.com ([2607:f8b0:4864:20::22d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ru3dp-0005Kh-Q1 for qemu-devel@nongnu.org; Tue, 09 Apr 2024 01:03:34 -0400 Received: by mail-oi1-x22d.google.com with SMTP id 5614622812f47-3c60019eecaso73182b6e.0 for ; Mon, 08 Apr 2024 22:03:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712639008; x=1713243808; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=Lwz2AVaZ4jMxsAZ0LmeafrPRZnLD2nezi1yCURh51Zs=; b=ZZXtMsrMIMFCRBfcRuYB3Pzyi+O6Fu35oYPgbCQ0oHPfUYAif/kVHhgWYIKaSwgsqv jciv1xGynDGzRAsdM95rrQj7ieGqD7gZQfHHyPv0evcYR6MSAltbcHDvYPhq+xFbydUx Z1nbfE3pBYvJuXGD1HasbSIPITMhCnLT55XTBnMoJEmCdq/QH9de7/Zb7wpUuLdcX9aC h679+VRqYYJgRlm+gIuT497S4+mmZ2btO7g30Z3OPgSfhIemvDl/dOICPyTI86hBmQrs wZ7gJCd1nmthS9D53T3LIEipJYYs7xoPm5g3wEHN54l5DFkUeyplZmw2tadz+SziS6GK 53FQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712639008; x=1713243808; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Lwz2AVaZ4jMxsAZ0LmeafrPRZnLD2nezi1yCURh51Zs=; b=LzUcc+0irV0fhmsTyNlb1mxmrpUv/xg6PQr3uVXV4s+QduDoUBVU8P3X3rWFsYQ1Ky DoxejkFagDQCSbVT0SiNVkbIYqrmEoPXIrArMr30CThqcjCORyWbHMWaUgnQGIPPK1FY Z2AUNeRJVWc3LvFZ/Dk0EdJYmoWgTK/cq+Y4d32ptGkI8OoLHhRfsnUCLu82KI1v/8a8 voIWsJZitu5smwzeJgOoCv48z32cwKM1OSzRuiJrum+n6fddV8DlNTTthKerOKifAI+A rpOHoag2kXghXkCWIqKNgi9/kjSGI74+TsZ5f1GTv+PMTM7/0v9u1p6RbhzSgNdYiRKL SAgg== X-Gm-Message-State: AOJu0YwvcoAryWElWVIlkhuIc6iyJwh5Jh3G0cb+ujBGUfvqvAyF8Lzh hi19RfZJo2XJ76QkuBZW7ycadJ7uyz6Y4s+DuG8zAcf6QVepL08lWyuvBNn8rl+5AbhioURY1Z7 y X-Received: by 2002:aca:2313:0:b0:3c5:e553:475a with SMTP id e19-20020aca2313000000b003c5e553475amr7552060oie.45.1712639008712; Mon, 08 Apr 2024 22:03:28 -0700 (PDT) Received: from stoup.. (098-147-007-212.res.spectrum.com. [98.147.7.212]) by smtp.gmail.com with ESMTPSA id z26-20020aa785da000000b006e64ddfa71asm7654894pfn.170.2024.04.08.22.03.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 22:03:28 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 19/28] linux-user/i386: Fix -mregparm=3 for signal delivery Date: Mon, 8 Apr 2024 19:02:53 -1000 Message-Id: <20240409050302.1523277-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240409050302.1523277-1-richard.henderson@linaro.org> References: <20240409050302.1523277-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::22d; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x22d.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 Since v2.6.19, the kernel has supported -mregparm=3. Signed-off-by: Richard Henderson --- linux-user/i386/signal.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/linux-user/i386/signal.c b/linux-user/i386/signal.c index 559b63c25b..f8cc0cff07 100644 --- a/linux-user/i386/signal.c +++ b/linux-user/i386/signal.c @@ -427,6 +427,11 @@ void setup_frame(int sig, struct target_sigaction *ka, env->regs[R_ESP] = frame_addr; env->eip = ka->_sa_handler; + /* Make -mregparm=3 work */ + env->regs[R_EAX] = sig; + env->regs[R_EDX] = 0; + env->regs[R_ECX] = 0; + cpu_x86_load_seg(env, R_DS, __USER_DS); cpu_x86_load_seg(env, R_ES, __USER_DS); cpu_x86_load_seg(env, R_SS, __USER_DS); @@ -448,9 +453,6 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, target_sigset_t *set, CPUX86State *env) { abi_ulong frame_addr; -#ifndef TARGET_X86_64 - abi_ulong addr; -#endif struct rt_sigframe *frame; int i; @@ -460,14 +462,6 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) goto give_sigsegv; - /* These fields are only in rt_sigframe on 32 bit */ -#ifndef TARGET_X86_64 - __put_user(sig, &frame->sig); - addr = frame_addr + offsetof(struct rt_sigframe, info); - __put_user(addr, &frame->pinfo); - addr = frame_addr + offsetof(struct rt_sigframe, uc); - __put_user(addr, &frame->puc); -#endif if (ka->sa_flags & TARGET_SA_SIGINFO) { frame->info = *info; } @@ -507,9 +501,13 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, env->eip = ka->_sa_handler; #ifndef TARGET_X86_64 + /* Store arguments for both -mregparm=3 and standard. */ env->regs[R_EAX] = sig; + __put_user(sig, &frame->sig); env->regs[R_EDX] = frame_addr + offsetof(struct rt_sigframe, info); + __put_user(env->regs[R_EDX], &frame->pinfo); env->regs[R_ECX] = frame_addr + offsetof(struct rt_sigframe, uc); + __put_user(env->regs[R_ECX], &frame->puc); #else env->regs[R_EAX] = 0; env->regs[R_EDI] = sig;