From patchwork Tue Nov 16 11:02:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 519194 Delivered-To: patch@linaro.org Received: by 2002:ac0:c605:0:0:0:0:0 with SMTP id p5csp6967583imj; Tue, 16 Nov 2021 03:04:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJzRTwZzPyl9E/uJJqOPvN+Sksojc63w99N63a/5UyoM61m79bNeIOV07AxIZV5X9VG0OjGq X-Received: by 2002:a05:620a:12ac:: with SMTP id x12mr5342935qki.144.1637060641288; Tue, 16 Nov 2021 03:04:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637060641; cv=none; d=google.com; s=arc-20160816; b=VqbGmtwSYxfZYqkO1Lm4HNzHLlAIT7QLnlFfj6+BFzJaVHNXsu8GTYVLUaYGymbQkf OW+yRh9MbbcmWiLrOScKn9PHysaOg6OHND2zTGBioOXiSm60aGPObg15KM/5Oc8tuu5a +eQ9FmyP+/glnsbeJfT5QdQWPJfQYHrBkPHz5eIu5Ji4pBXNA6gSDUAtfFxI1ZK+pcEK f4yItSfN986jCb+vM3une6Rm8GrTgICb2c1VSOcMf3vjTLTq6TyxVT9lErXRzwdedlrW YTtpY8EOHuilNBtNBa3K1uA+hTOwNxA/39Jt7xoI+HAybfxdCzro2rYUGaG7ycwA/EKI n7aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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=s/HEpXEnNBxz9iHZEfDzUaUwsQCc0aqYlTEzaPR5D7I=; b=YiCDOE8D9yn9T1RfhhFNtWYmIYYlPBgklLvo3p15k6vh+DnAPakslixbRtj6LJhasV pc4aBy/6ueq3cxna35z2FF4cq5C0rI5E9iLnMcCLs2UWXwMUMUcpWIRo0rzdQ8nsoG3Z u92oJ3ka/gEn//cemlBOHiuqE58doq2X+ihne8YPvODS4sjBpiS+UcPVRWgBqGjAJ86Z 8/DIiNw0iCCa8KnLYUW6KBmKsysBIGxaiKJLHXQ7AAIR3zlwbTXZSWRd5nv3YXzDi7mC pwFayEJ/eeTZhJr3EEBO8m53lBPeadzeLl0Ub8WCfhXYeDHoHCL6SmVSuIdJ9GfLpkw9 ZlYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="oAI7f/A/"; 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=fail (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 l10si26109282qkp.155.2021.11.16.03.04.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Nov 2021 03:04:01 -0800 (PST) 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=fail header.i=@linaro.org header.s=google header.b="oAI7f/A/"; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:42300 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mmwFs-0001Th-ON for patch@linaro.org; Tue, 16 Nov 2021 06:04:00 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59936) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmwEy-0001Pd-Os for qemu-devel@nongnu.org; Tue, 16 Nov 2021 06:03:04 -0500 Received: from [2a00:1450:4864:20::42d] (port=37431 helo=mail-wr1-x42d.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mmwEw-0004ue-Ai for qemu-devel@nongnu.org; Tue, 16 Nov 2021 06:03:04 -0500 Received: by mail-wr1-x42d.google.com with SMTP id b12so36785315wrh.4 for ; Tue, 16 Nov 2021 03:03:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=s/HEpXEnNBxz9iHZEfDzUaUwsQCc0aqYlTEzaPR5D7I=; b=oAI7f/A/5Okgc+KopbzT+ZYrWSv3o3wIzjTk7k+p2IaHH5X7pIPxHIeB/qhZqDOx4E bPgrMadJs6EIrh8l1EVGJxp+9KQjF9giCslm4wCzfbiXcAgjzGUgLGBGl7w+Es/K544+ 1TAMMOjWd5+P2xsCvxv+8B55u5V2aJG6LKuYb/wmuyq92YyNYun+b2/fsdZgnHXRIy+W bLQUx8JxR3jR0IS0C8g3R5S7Dmx3/c4yi2LyAa7k5ianf6VLsKMBERMyW9oLBcAXCK9z sh0VdiKlfhuoQA5BL51jcKuyMFVcslepNWb9rNPzWUyAY2d5ofr3h8wyhZZPdhOMcAgS tWKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=s/HEpXEnNBxz9iHZEfDzUaUwsQCc0aqYlTEzaPR5D7I=; b=ekmtbC7LMnpgONjyjlCNc0Y/RNcSkOGXIwkBhnAhsvp+HBoUmvSlFSkS96adivyoYi eqmqJ6NmwpsdohgNXl2IaPGlLvdadqzXJ1rsOfasggovEXm2mB7Wiv63e6k11qHL+zYJ ECXgUEkTio+6YmGE9T+VUTeYtd/T/gqWfFjc+jztZp6lNd9kr+rX2KBm9LmcB7rtx+4u 6BI/J9xZb6CkzYHI1XKm6mLPe2ADaSEfC0sddwmF7K+QoXXZWRRJQs0sbpZoF5c2NFgm UbECmy/YFRccryH7bIZyaZ+CeoPWyXzJT78FYVKu+3EHsjnOt1iheikNLfB4SWWaCvJr iSHA== X-Gm-Message-State: AOAM531XjFVioKxAMQsBCAE1CQ4fUXlOqyq7gMPOvlSJYMTD+p6ZoOzl DqVKEfzpNjDVkJOhRB3xXyJ+sB2Ic0PzCWpbgkg= X-Received: by 2002:a5d:51cf:: with SMTP id n15mr8758804wrv.106.1637060580570; Tue, 16 Nov 2021 03:03:00 -0800 (PST) Received: from localhost.localdomain (145.red-37-158-173.dynamicip.rima-tde.net. [37.158.173.145]) by smtp.gmail.com with ESMTPSA id f15sm2639779wmg.30.2021.11.16.03.02.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Nov 2021 03:03:00 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 1/9] linux-user: Add host_signal_set_pc to set pc in mcontext Date: Tue, 16 Nov 2021 12:02:48 +0100 Message-Id: <20211116110256.365484-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211116110256.365484-1-richard.henderson@linaro.org> References: <20211116110256.365484-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::42d (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x42d.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: , Cc: laurent@vivier.eu, imp@bsdimp.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Warner Losh Add a new function host_signal_set_pc to set the next pc in an mcontext. The caller should ensure this is a valid PC for execution. Signed-off-by: Warner Losh Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Message-Id: <20211113045603.60391-2-imp@bsdimp.com> Signed-off-by: Richard Henderson --- linux-user/host/aarch64/host-signal.h | 5 +++++ linux-user/host/alpha/host-signal.h | 5 +++++ linux-user/host/arm/host-signal.h | 5 +++++ linux-user/host/i386/host-signal.h | 5 +++++ linux-user/host/mips/host-signal.h | 5 +++++ linux-user/host/ppc/host-signal.h | 5 +++++ linux-user/host/riscv/host-signal.h | 5 +++++ linux-user/host/s390/host-signal.h | 5 +++++ linux-user/host/sparc/host-signal.h | 9 +++++++++ linux-user/host/x86_64/host-signal.h | 5 +++++ 10 files changed, 54 insertions(+) diff --git a/linux-user/host/aarch64/host-signal.h b/linux-user/host/aarch64/host-signal.h index 0c0b08383a..9770b36dc1 100644 --- a/linux-user/host/aarch64/host-signal.h +++ b/linux-user/host/aarch64/host-signal.h @@ -35,6 +35,11 @@ static inline uintptr_t host_signal_pc(ucontext_t *uc) return uc->uc_mcontext.pc; } +static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) +{ + uc->uc_mcontext.pc = pc; +} + static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) { struct _aarch64_ctx *hdr; diff --git a/linux-user/host/alpha/host-signal.h b/linux-user/host/alpha/host-signal.h index e080be412f..f4c942948a 100644 --- a/linux-user/host/alpha/host-signal.h +++ b/linux-user/host/alpha/host-signal.h @@ -16,6 +16,11 @@ static inline uintptr_t host_signal_pc(ucontext_t *uc) return uc->uc_mcontext.sc_pc; } +static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) +{ + uc->uc_mcontext.sc_pc = pc; +} + static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) { uint32_t *pc = (uint32_t *)host_signal_pc(uc); diff --git a/linux-user/host/arm/host-signal.h b/linux-user/host/arm/host-signal.h index efb165c0c5..6c095773c0 100644 --- a/linux-user/host/arm/host-signal.h +++ b/linux-user/host/arm/host-signal.h @@ -16,6 +16,11 @@ static inline uintptr_t host_signal_pc(ucontext_t *uc) return uc->uc_mcontext.arm_pc; } +static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) +{ + uc->uc_mcontext.arm_pc = pc; +} + static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) { /* diff --git a/linux-user/host/i386/host-signal.h b/linux-user/host/i386/host-signal.h index 4c8eef99ce..abe1ece5c9 100644 --- a/linux-user/host/i386/host-signal.h +++ b/linux-user/host/i386/host-signal.h @@ -16,6 +16,11 @@ static inline uintptr_t host_signal_pc(ucontext_t *uc) return uc->uc_mcontext.gregs[REG_EIP]; } +static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) +{ + uc->uc_mcontext.gregs[REG_EIP] = pc; +} + static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) { return uc->uc_mcontext.gregs[REG_TRAPNO] == 0xe diff --git a/linux-user/host/mips/host-signal.h b/linux-user/host/mips/host-signal.h index ef341f7c20..c666ed8c3f 100644 --- a/linux-user/host/mips/host-signal.h +++ b/linux-user/host/mips/host-signal.h @@ -16,6 +16,11 @@ static inline uintptr_t host_signal_pc(ucontext_t *uc) return uc->uc_mcontext.pc; } +static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) +{ + uc->uc_mcontext.pc = pc; +} + #if defined(__misp16) || defined(__mips_micromips) #error "Unsupported encoding" #endif diff --git a/linux-user/host/ppc/host-signal.h b/linux-user/host/ppc/host-signal.h index a491c413dc..1d8e658ff7 100644 --- a/linux-user/host/ppc/host-signal.h +++ b/linux-user/host/ppc/host-signal.h @@ -16,6 +16,11 @@ static inline uintptr_t host_signal_pc(ucontext_t *uc) return uc->uc_mcontext.regs->nip; } +static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) +{ + uc->uc_mcontext.regs->nip = pc; +} + static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) { return uc->uc_mcontext.regs->trap != 0x400 diff --git a/linux-user/host/riscv/host-signal.h b/linux-user/host/riscv/host-signal.h index 3b168cb58b..a4f170efb0 100644 --- a/linux-user/host/riscv/host-signal.h +++ b/linux-user/host/riscv/host-signal.h @@ -16,6 +16,11 @@ static inline uintptr_t host_signal_pc(ucontext_t *uc) return uc->uc_mcontext.__gregs[REG_PC]; } +static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) +{ + uc->uc_mcontext.__gregs[REG_PC] = pc; +} + static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) { /* diff --git a/linux-user/host/s390/host-signal.h b/linux-user/host/s390/host-signal.h index 26990e4893..a524f2ab00 100644 --- a/linux-user/host/s390/host-signal.h +++ b/linux-user/host/s390/host-signal.h @@ -16,6 +16,11 @@ static inline uintptr_t host_signal_pc(ucontext_t *uc) return uc->uc_mcontext.psw.addr; } +static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) +{ + uc->uc_mcontext.psw.addr = pc; +} + static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) { uint16_t *pinsn = (uint16_t *)host_signal_pc(uc); diff --git a/linux-user/host/sparc/host-signal.h b/linux-user/host/sparc/host-signal.h index 5e71d33f8e..7342936071 100644 --- a/linux-user/host/sparc/host-signal.h +++ b/linux-user/host/sparc/host-signal.h @@ -20,6 +20,15 @@ static inline uintptr_t host_signal_pc(ucontext_t *uc) #endif } +static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) +{ +#ifdef __arch64__ + uc->uc_mcontext.mc_gregs[MC_PC] = pc; +#else + uc->uc_mcontext.gregs[REG_PC] = pc; +#endif +} + static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) { uint32_t insn = *(uint32_t *)host_signal_pc(uc); diff --git a/linux-user/host/x86_64/host-signal.h b/linux-user/host/x86_64/host-signal.h index 883d2fcf65..c71d597eb2 100644 --- a/linux-user/host/x86_64/host-signal.h +++ b/linux-user/host/x86_64/host-signal.h @@ -15,6 +15,11 @@ static inline uintptr_t host_signal_pc(ucontext_t *uc) return uc->uc_mcontext.gregs[REG_RIP]; } +static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) +{ + uc->uc_mcontext.gregs[REG_RIP] = pc; +} + static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) { return uc->uc_mcontext.gregs[REG_TRAPNO] == 0xe From patchwork Tue Nov 16 11:02:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 519193 Delivered-To: patch@linaro.org Received: by 2002:ac0:c605:0:0:0:0:0 with SMTP id p5csp6967555imj; Tue, 16 Nov 2021 03:04:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJx1aPZNF4FvWwy0zYLAayK56zj7E8cp7+C45YTRh1xOxDBVDmUXwBjvd9owtIqt8malArKj X-Received: by 2002:a05:6214:8e5:: with SMTP id dr5mr44522696qvb.28.1637060640610; Tue, 16 Nov 2021 03:04:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637060640; cv=none; d=google.com; s=arc-20160816; b=zTOYcHL+ebLPUxDD6znxBylFHD53r9PCJYDKUFKPyMbsdBtSB2MW5UpwA+KWq5pIC2 3QHdfPCcdKbxW9rnM8Rgm52JhTkqpPed1Lt0IxBdzxFrmbLrXJM6Kl99UYTWFto1+WwD K/TX6Im2x6nJJeycV8LhTmfg1npZa0ZiwvdLyo6L+tNReY5xFRPKXkrCQNBgnDQnDCGB MBkkXADgj6/cy1hCVJKDIbeXIqHbnpjow4kHJui6aKrPN6arunYbXVjZAQVE1t/q/FxH YhITWev++kx5VS61dA5wNxSt0wdsMM4epI47NBIJcPgzFzQ105u6ZC0rg42XpWgZh6YR Yi8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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=itLhZ0W/RxJYtFiacTtH89yYOTpt74xZSJ/OImafFPs=; b=P/+lnfRz0pAZn3NkU/muTtsOQhz2fUM/rjl/jjOJDw34D3xrnkq9yExT+GSBCqlrof zqpjLLbbwBqggrc1o+/A4so+mneG2nUPfBmSES6gbqTTNu+mJPqRDUfHgUEDji6LRDZO 6OnVbHLNCJWdsgcNMGhUiSqrMDXkQ28tvQHouA0tS+m8bdBkKHqsSW4mphKkfI6qiIwu 0onGqs4U+fWqgJ2YPeGQtSWNto0uJ7swKBt+CkfGqjXjb81ZbAy/qKwuqKt38sWrDWsQ Y2dtH2g272gAeY4dOhDvHrpDRKzq+qsFbqWS2PCEt8zrQSE/W/vvsXoPn7i+wIV5m04C sP2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=tFvNphdd; 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=fail (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 x3si29732015qkp.293.2021.11.16.03.04.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Nov 2021 03:04:00 -0800 (PST) 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=fail header.i=@linaro.org header.s=google header.b=tFvNphdd; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:42320 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mmwFs-0001UK-1d for patch@linaro.org; Tue, 16 Nov 2021 06:04:00 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59952) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmwEz-0001RD-K7 for qemu-devel@nongnu.org; Tue, 16 Nov 2021 06:03:05 -0500 Received: from [2a00:1450:4864:20::432] (port=34427 helo=mail-wr1-x432.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mmwEx-0004uo-GL for qemu-devel@nongnu.org; Tue, 16 Nov 2021 06:03:05 -0500 Received: by mail-wr1-x432.google.com with SMTP id d5so36755648wrc.1 for ; Tue, 16 Nov 2021 03:03:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=itLhZ0W/RxJYtFiacTtH89yYOTpt74xZSJ/OImafFPs=; b=tFvNphddBVCkvQafdJeMpN24ToXCF9JiN5a8kPZhAWZ9TtUqhAmlFp/KTdfeFs7y/v 4tJWCIBtHW8m16ZyPhwnnRBx3gI80uKH6n0sGM+t8UE4DGADTQqm7THx0kXNDu1fGIEO TYJOd7lQ6P4Nib3DfqFg6AmTpzZG23Qkw2wU7Cz0x+mzjGR0z24cHdO24V1Lqa/PpMhz uPTMblOy0FIMfP14P+TuabdCelCFC9YXqM7cWPELG3vn+1dc0WCrmrVdh2m9BZSHZuDp Wf6I5XD4sy0dEOfSnhcR61MGKjQwdxlmQAJtuOnb/1MOyUAqEmjvPjpZk8OcCL3YvTRi xVeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=itLhZ0W/RxJYtFiacTtH89yYOTpt74xZSJ/OImafFPs=; b=r1UIOiBL2QVXa1pBWl6JVbrrNm4xlhA3svSQPvzVBkVBJqLQvQ9PF5/2j+74il8zvc iFBNdhJrxw7ZL9hEwtIsdaZyl5Yj+O6xv+gd/OPz3qBnDBk/+8I0ULKxjqoXkVBmk67t ILDh+7dKh8L5MTlRpjYBbfkumiH82UYRsxwdTNKRTgFAAD1JU/dcLI0c1ARCYlSEePYL EFosNNdOxm5aZIC1cld709tBKI4dzOsoliFvzXt92zEsSok+IIbTTkfmyucnyP92Hcvc bBFNR9tCV9hEpkSGMuoYpJsfxTfnqaccgFNuoNo3LJKfd5rkk/foJRFi3aWNwX+c7ved /0qA== X-Gm-Message-State: AOAM532/O11ErU8bGoDfwaOgUEUrkijN8v/2rTKwoJO8/GohHPRVO6Tu LlUPWreETnRzuU4qgne4253btHxHbyc3pMF4ZPQ= X-Received: by 2002:a05:6000:1842:: with SMTP id c2mr8329039wri.301.1637060582023; Tue, 16 Nov 2021 03:03:02 -0800 (PST) Received: from localhost.localdomain (145.red-37-158-173.dynamicip.rima-tde.net. [37.158.173.145]) by smtp.gmail.com with ESMTPSA id f15sm2639779wmg.30.2021.11.16.03.03.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Nov 2021 03:03:01 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 2/9] linux-user/signal.c: Create a common rewind_if_in_safe_syscall Date: Tue, 16 Nov 2021 12:02:49 +0100 Message-Id: <20211116110256.365484-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211116110256.365484-1-richard.henderson@linaro.org> References: <20211116110256.365484-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::432 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::432; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x432.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: , Cc: laurent@vivier.eu, imp@bsdimp.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Warner Losh All instances of rewind_if_in_safe_syscall are the same, differing only in how the instruction point is fetched from the ucontext and the size of the registers. Use host_signal_pc and new host_signal_set_pc interfaces to fetch the pointer to the PC and adjust if needed. Delete all the old copies of rewind_if_in_safe_syscall. Signed-off-by: Warner Losh Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20211113045603.60391-3-imp@bsdimp.com> [rth: include safe-syscall.h, simplify ifdefs] Signed-off-by: Richard Henderson --- linux-user/host/aarch64/hostdep.h | 20 -------------------- linux-user/host/arm/hostdep.h | 20 -------------------- linux-user/host/i386/hostdep.h | 20 -------------------- linux-user/host/ppc64/hostdep.h | 20 -------------------- linux-user/host/riscv/hostdep.h | 20 -------------------- linux-user/host/s390x/hostdep.h | 20 -------------------- linux-user/host/x86_64/hostdep.h | 20 -------------------- linux-user/safe-syscall.h | 3 +++ linux-user/signal.c | 15 ++++++++++++--- 9 files changed, 15 insertions(+), 143 deletions(-) diff --git a/linux-user/host/aarch64/hostdep.h b/linux-user/host/aarch64/hostdep.h index a8d41a21ad..39299d798a 100644 --- a/linux-user/host/aarch64/hostdep.h +++ b/linux-user/host/aarch64/hostdep.h @@ -15,24 +15,4 @@ /* We have a safe-syscall.inc.S */ #define HAVE_SAFE_SYSCALL -#ifndef __ASSEMBLER__ - -/* These are defined by the safe-syscall.inc.S file */ -extern char safe_syscall_start[]; -extern char safe_syscall_end[]; - -/* Adjust the signal context to rewind out of safe-syscall if we're in it */ -static inline void rewind_if_in_safe_syscall(void *puc) -{ - ucontext_t *uc = puc; - __u64 *pcreg = &uc->uc_mcontext.pc; - - if (*pcreg > (uintptr_t)safe_syscall_start - && *pcreg < (uintptr_t)safe_syscall_end) { - *pcreg = (uintptr_t)safe_syscall_start; - } -} - -#endif /* __ASSEMBLER__ */ - #endif diff --git a/linux-user/host/arm/hostdep.h b/linux-user/host/arm/hostdep.h index 9276fe6ceb..86b137875a 100644 --- a/linux-user/host/arm/hostdep.h +++ b/linux-user/host/arm/hostdep.h @@ -15,24 +15,4 @@ /* We have a safe-syscall.inc.S */ #define HAVE_SAFE_SYSCALL -#ifndef __ASSEMBLER__ - -/* These are defined by the safe-syscall.inc.S file */ -extern char safe_syscall_start[]; -extern char safe_syscall_end[]; - -/* Adjust the signal context to rewind out of safe-syscall if we're in it */ -static inline void rewind_if_in_safe_syscall(void *puc) -{ - ucontext_t *uc = puc; - unsigned long *pcreg = &uc->uc_mcontext.arm_pc; - - if (*pcreg > (uintptr_t)safe_syscall_start - && *pcreg < (uintptr_t)safe_syscall_end) { - *pcreg = (uintptr_t)safe_syscall_start; - } -} - -#endif /* __ASSEMBLER__ */ - #endif diff --git a/linux-user/host/i386/hostdep.h b/linux-user/host/i386/hostdep.h index 073be74d87..ce7136501f 100644 --- a/linux-user/host/i386/hostdep.h +++ b/linux-user/host/i386/hostdep.h @@ -15,24 +15,4 @@ /* We have a safe-syscall.inc.S */ #define HAVE_SAFE_SYSCALL -#ifndef __ASSEMBLER__ - -/* These are defined by the safe-syscall.inc.S file */ -extern char safe_syscall_start[]; -extern char safe_syscall_end[]; - -/* Adjust the signal context to rewind out of safe-syscall if we're in it */ -static inline void rewind_if_in_safe_syscall(void *puc) -{ - ucontext_t *uc = puc; - greg_t *pcreg = &uc->uc_mcontext.gregs[REG_EIP]; - - if (*pcreg > (uintptr_t)safe_syscall_start - && *pcreg < (uintptr_t)safe_syscall_end) { - *pcreg = (uintptr_t)safe_syscall_start; - } -} - -#endif /* __ASSEMBLER__ */ - #endif diff --git a/linux-user/host/ppc64/hostdep.h b/linux-user/host/ppc64/hostdep.h index 98979ad917..0c290dd904 100644 --- a/linux-user/host/ppc64/hostdep.h +++ b/linux-user/host/ppc64/hostdep.h @@ -15,24 +15,4 @@ /* We have a safe-syscall.inc.S */ #define HAVE_SAFE_SYSCALL -#ifndef __ASSEMBLER__ - -/* These are defined by the safe-syscall.inc.S file */ -extern char safe_syscall_start[]; -extern char safe_syscall_end[]; - -/* Adjust the signal context to rewind out of safe-syscall if we're in it */ -static inline void rewind_if_in_safe_syscall(void *puc) -{ - ucontext_t *uc = puc; - unsigned long *pcreg = &uc->uc_mcontext.gp_regs[PT_NIP]; - - if (*pcreg > (uintptr_t)safe_syscall_start - && *pcreg < (uintptr_t)safe_syscall_end) { - *pcreg = (uintptr_t)safe_syscall_start; - } -} - -#endif /* __ASSEMBLER__ */ - #endif diff --git a/linux-user/host/riscv/hostdep.h b/linux-user/host/riscv/hostdep.h index 2ba07456ae..7f67c22868 100644 --- a/linux-user/host/riscv/hostdep.h +++ b/linux-user/host/riscv/hostdep.h @@ -11,24 +11,4 @@ /* We have a safe-syscall.inc.S */ #define HAVE_SAFE_SYSCALL -#ifndef __ASSEMBLER__ - -/* These are defined by the safe-syscall.inc.S file */ -extern char safe_syscall_start[]; -extern char safe_syscall_end[]; - -/* Adjust the signal context to rewind out of safe-syscall if we're in it */ -static inline void rewind_if_in_safe_syscall(void *puc) -{ - ucontext_t *uc = puc; - unsigned long *pcreg = &uc->uc_mcontext.__gregs[REG_PC]; - - if (*pcreg > (uintptr_t)safe_syscall_start - && *pcreg < (uintptr_t)safe_syscall_end) { - *pcreg = (uintptr_t)safe_syscall_start; - } -} - -#endif /* __ASSEMBLER__ */ - #endif diff --git a/linux-user/host/s390x/hostdep.h b/linux-user/host/s390x/hostdep.h index 4f0171f36f..d801145854 100644 --- a/linux-user/host/s390x/hostdep.h +++ b/linux-user/host/s390x/hostdep.h @@ -15,24 +15,4 @@ /* We have a safe-syscall.inc.S */ #define HAVE_SAFE_SYSCALL -#ifndef __ASSEMBLER__ - -/* These are defined by the safe-syscall.inc.S file */ -extern char safe_syscall_start[]; -extern char safe_syscall_end[]; - -/* Adjust the signal context to rewind out of safe-syscall if we're in it */ -static inline void rewind_if_in_safe_syscall(void *puc) -{ - ucontext_t *uc = puc; - unsigned long *pcreg = &uc->uc_mcontext.psw.addr; - - if (*pcreg > (uintptr_t)safe_syscall_start - && *pcreg < (uintptr_t)safe_syscall_end) { - *pcreg = (uintptr_t)safe_syscall_start; - } -} - -#endif /* __ASSEMBLER__ */ - #endif diff --git a/linux-user/host/x86_64/hostdep.h b/linux-user/host/x86_64/hostdep.h index a4fefb5114..9c62bd26bd 100644 --- a/linux-user/host/x86_64/hostdep.h +++ b/linux-user/host/x86_64/hostdep.h @@ -15,24 +15,4 @@ /* We have a safe-syscall.inc.S */ #define HAVE_SAFE_SYSCALL -#ifndef __ASSEMBLER__ - -/* These are defined by the safe-syscall.inc.S file */ -extern char safe_syscall_start[]; -extern char safe_syscall_end[]; - -/* Adjust the signal context to rewind out of safe-syscall if we're in it */ -static inline void rewind_if_in_safe_syscall(void *puc) -{ - ucontext_t *uc = puc; - greg_t *pcreg = &uc->uc_mcontext.gregs[REG_RIP]; - - if (*pcreg > (uintptr_t)safe_syscall_start - && *pcreg < (uintptr_t)safe_syscall_end) { - *pcreg = (uintptr_t)safe_syscall_start; - } -} - -#endif /* __ASSEMBLER__ */ - #endif diff --git a/linux-user/safe-syscall.h b/linux-user/safe-syscall.h index 6bc0390262..aaa9ffc0e2 100644 --- a/linux-user/safe-syscall.h +++ b/linux-user/safe-syscall.h @@ -127,6 +127,9 @@ #ifdef HAVE_SAFE_SYSCALL /* The core part of this function is implemented in assembly */ extern long safe_syscall_base(int *pending, long number, ...); +/* These are defined by the safe-syscall.inc.S file */ +extern char safe_syscall_start[]; +extern char safe_syscall_end[]; #define safe_syscall(...) \ ({ \ diff --git a/linux-user/signal.c b/linux-user/signal.c index 81c45bfce9..6d5e5b698c 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -31,6 +31,7 @@ #include "trace.h" #include "signal-common.h" #include "host-signal.h" +#include "safe-syscall.h" static struct target_sigaction sigact_table[TARGET_NSIG]; @@ -793,12 +794,20 @@ int queue_signal(CPUArchState *env, int sig, int si_type, return 1; /* indicates that the signal was queued */ } -#ifndef HAVE_SAFE_SYSCALL + +/* Adjust the signal context to rewind out of safe-syscall if we're in it */ static inline void rewind_if_in_safe_syscall(void *puc) { - /* Default version: never rewind */ -} +#ifdef HAVE_SAFE_SYSCALL + ucontext_t *uc = (ucontext_t *)puc; + uintptr_t pcreg = host_signal_pc(uc); + + if (pcreg > (uintptr_t)safe_syscall_start + && pcreg < (uintptr_t)safe_syscall_end) { + host_signal_set_pc(uc, (uintptr_t)safe_syscall_start); + } #endif +} static void host_signal_handler(int host_sig, siginfo_t *info, void *puc) { From patchwork Tue Nov 16 11:02:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 519192 Delivered-To: patch@linaro.org Received: by 2002:ac0:c605:0:0:0:0:0 with SMTP id p5csp6967563imj; Tue, 16 Nov 2021 03:04:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJzuWUWu1VN6EntN5tFxII8DSOiDGR18NTC3W5/+rZysOOsSsKYlSbULATcQCt6/rrB9Wx5P X-Received: by 2002:a37:8805:: with SMTP id k5mr5267813qkd.426.1637060640741; Tue, 16 Nov 2021 03:04:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637060640; cv=none; d=google.com; s=arc-20160816; b=JbeKjZZnDStN4xt+Cq2a/nD1LZ+JArpsC7LovpsPxECY8nFMEoryb0f6hfDtBraZ+z SZuR1vcxN6Y+IF+V07Zyaz2KZ/growjS16piE5pRh++OsXlw+uGTF4114LH0FsKy4nBZ dI0XNwwnupvLnqk5H5uEISD9DfKYZM3EKUbaK+bg8q0Gz8XXY+Bdgv0oYvabOLwbv/+0 YOEY5UkoufDqcZbIAfiRbrx2pk9/7MmHiqU9Xwjq5adJUozZ8fvZ0szptl2zGI3kEbhG Do8chOyNrgdmMwcniBkwnkKF7Lx5PVg1KpBNPXOPGF1nS3X/GcakNLdrnZtdEHU1Oudh WPcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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=zpDSDxGnP0doBblMTguXufreu6LAli0ayiyl7WMNWJY=; b=XiVMifPiMj8zAQQvh0RTrQ6LtjvjdLxptszkMFD0WWaXd3uc5B3t9bVrkzUKEyEvSh JBdrVQ6XoZDcVeDujbyHym39ewPGJ0lbmB4fysRwgz5gTL9QMG3DpUIBpU3I8+EIXAte Ksko+2ddzTu8mCx7FaiRpKKs8GWckWujVS3APQuUK4EMawHYh6wWCpi1c7NcnMTQ1Sin KiAtyPGxZgo1WGLACtBwepeVZR4k2MKR1722ThAPR/2vqhNWrMuv4pHqNTYnaIArv5HN oYRBVZtYUwBWw7oFQVgFOfzIdpEi2IH514P3zszb/Web9mxg0QBvTiqxQ0hde/zSFM37 jD9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=gtInK6CV; 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=fail (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 u13si13368107qkp.187.2021.11.16.03.04.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Nov 2021 03:04:00 -0800 (PST) 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=fail header.i=@linaro.org header.s=google header.b=gtInK6CV; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:42368 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mmwFs-0001WL-6m for patch@linaro.org; Tue, 16 Nov 2021 06:04:00 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59958) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmwF0-0001Si-F1 for qemu-devel@nongnu.org; Tue, 16 Nov 2021 06:03:06 -0500 Received: from [2a00:1450:4864:20::331] (port=53861 helo=mail-wm1-x331.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mmwEy-0004uu-OO for qemu-devel@nongnu.org; Tue, 16 Nov 2021 06:03:06 -0500 Received: by mail-wm1-x331.google.com with SMTP id y196so16500353wmc.3 for ; Tue, 16 Nov 2021 03:03:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zpDSDxGnP0doBblMTguXufreu6LAli0ayiyl7WMNWJY=; b=gtInK6CVcGXqXM/aehZyaCSy6jDxd7riN9nIfVMNUjMYehddmqPrFnpkqLjzexupmY cfwupq0cPqlIj/M12/aZ7hn26zfnWb3gx2NByu0bOu/p88rqXpT1x1b+nObC0exi6H0/ vZH4NPwHVmVU+Yf8Aofurta5avu4INciB5zXJVLw+MrNiMzCJoVoRLekfrJE91s8lo1V ymzGUF4hhIoCOqiseeb1a7PMjoD/Ahy3802dpKZWWhiChj8khvfvf9Syk6HTh1yf7kd+ nnU/ULyD7zxO97Ci8a3OS0/ISpWz/M6D6J6lY0T7cFzk2XrFQy71YQq4HMpysvgA746M jbNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zpDSDxGnP0doBblMTguXufreu6LAli0ayiyl7WMNWJY=; b=hgDzypiZFUw2A1qXyKONw60BeXg56tI2bmt7zK6jDh0xRHRYj5cASy2imOVZTfGs3y nCusYvusP4088szHyuX0o6UIgXy0wZcQa1KRnUZQDIFz7n1BKxI7dJavRfPp2X7cMgtx jbxnQgZxVINFgLipYPYwPa4MA5hi+lk+lI6B1UjV6O0WV5lA3Kqvaaly1QaPoSuL9+w+ b1b89bARu9AweVg16TjxFMfNGt0QKEdO6mKJv/WOvZamFhsbU1BnAdr5dqlePCcOENc2 vPbN+A8R38Ke4b07Ox2v40yIBnwjpk6q+HWCgOz4YK7eVXns1061R5hEPGQfaFPpCDI2 cAuw== X-Gm-Message-State: AOAM530drLIi5s7OOvRsXyxzMNoyLtWzwbeWY3u2oy8bODtRk/cGW0sE 4IuyJTWOVRyVk3dPaGCI0R89Vq6my3ZIbyxUHzg= X-Received: by 2002:a05:600c:1d06:: with SMTP id l6mr6430534wms.97.1637060583378; Tue, 16 Nov 2021 03:03:03 -0800 (PST) Received: from localhost.localdomain (145.red-37-158-173.dynamicip.rima-tde.net. [37.158.173.145]) by smtp.gmail.com with ESMTPSA id f15sm2639779wmg.30.2021.11.16.03.03.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Nov 2021 03:03:02 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 3/9] linux-user/safe-syscall.inc.S: Move to common-user Date: Tue, 16 Nov 2021 12:02:50 +0100 Message-Id: <20211116110256.365484-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211116110256.365484-1-richard.henderson@linaro.org> References: <20211116110256.365484-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::331 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x331.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: , Cc: laurent@vivier.eu, imp@bsdimp.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Warner Losh Move all the safe_syscall.inc.S files to common-user. They are almost identical between linux-user and bsd-user to re-use. Signed-off-by: Warner Losh Reviewed-by: Richard Henderson Message-Id: <20211113045603.60391-4-imp@bsdimp.com> Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- meson.build | 1 + {linux-user => common-user}/host/aarch64/hostdep.h | 0 {linux-user => common-user}/host/arm/hostdep.h | 0 {linux-user => common-user}/host/i386/hostdep.h | 0 {linux-user => common-user}/host/ppc64/hostdep.h | 0 {linux-user => common-user}/host/riscv/hostdep.h | 0 {linux-user => common-user}/host/s390x/hostdep.h | 0 {linux-user => common-user}/host/x86_64/hostdep.h | 0 {linux-user => common-user}/host/aarch64/safe-syscall.inc.S | 0 {linux-user => common-user}/host/arm/safe-syscall.inc.S | 0 {linux-user => common-user}/host/i386/safe-syscall.inc.S | 0 {linux-user => common-user}/host/ppc64/safe-syscall.inc.S | 0 {linux-user => common-user}/host/riscv/safe-syscall.inc.S | 0 {linux-user => common-user}/host/s390x/safe-syscall.inc.S | 0 {linux-user => common-user}/host/x86_64/safe-syscall.inc.S | 0 15 files changed, 1 insertion(+) rename {linux-user => common-user}/host/aarch64/hostdep.h (100%) rename {linux-user => common-user}/host/arm/hostdep.h (100%) rename {linux-user => common-user}/host/i386/hostdep.h (100%) rename {linux-user => common-user}/host/ppc64/hostdep.h (100%) rename {linux-user => common-user}/host/riscv/hostdep.h (100%) rename {linux-user => common-user}/host/s390x/hostdep.h (100%) rename {linux-user => common-user}/host/x86_64/hostdep.h (100%) rename {linux-user => common-user}/host/aarch64/safe-syscall.inc.S (100%) rename {linux-user => common-user}/host/arm/safe-syscall.inc.S (100%) rename {linux-user => common-user}/host/i386/safe-syscall.inc.S (100%) rename {linux-user => common-user}/host/ppc64/safe-syscall.inc.S (100%) rename {linux-user => common-user}/host/riscv/safe-syscall.inc.S (100%) rename {linux-user => common-user}/host/s390x/safe-syscall.inc.S (100%) rename {linux-user => common-user}/host/x86_64/safe-syscall.inc.S (100%) diff --git a/meson.build b/meson.build index ccc6cefc25..ec22cf05c1 100644 --- a/meson.build +++ b/meson.build @@ -2878,6 +2878,7 @@ foreach target : target_dirs if 'CONFIG_LINUX_USER' in config_target base_dir = 'linux-user' target_inc += include_directories('linux-user/host/' / config_host['ARCH']) + target_inc += include_directories('common-user/host/' / config_host['ARCH']) endif if 'CONFIG_BSD_USER' in config_target base_dir = 'bsd-user' diff --git a/linux-user/host/aarch64/hostdep.h b/common-user/host/aarch64/hostdep.h similarity index 100% rename from linux-user/host/aarch64/hostdep.h rename to common-user/host/aarch64/hostdep.h diff --git a/linux-user/host/arm/hostdep.h b/common-user/host/arm/hostdep.h similarity index 100% rename from linux-user/host/arm/hostdep.h rename to common-user/host/arm/hostdep.h diff --git a/linux-user/host/i386/hostdep.h b/common-user/host/i386/hostdep.h similarity index 100% rename from linux-user/host/i386/hostdep.h rename to common-user/host/i386/hostdep.h diff --git a/linux-user/host/ppc64/hostdep.h b/common-user/host/ppc64/hostdep.h similarity index 100% rename from linux-user/host/ppc64/hostdep.h rename to common-user/host/ppc64/hostdep.h diff --git a/linux-user/host/riscv/hostdep.h b/common-user/host/riscv/hostdep.h similarity index 100% rename from linux-user/host/riscv/hostdep.h rename to common-user/host/riscv/hostdep.h diff --git a/linux-user/host/s390x/hostdep.h b/common-user/host/s390x/hostdep.h similarity index 100% rename from linux-user/host/s390x/hostdep.h rename to common-user/host/s390x/hostdep.h diff --git a/linux-user/host/x86_64/hostdep.h b/common-user/host/x86_64/hostdep.h similarity index 100% rename from linux-user/host/x86_64/hostdep.h rename to common-user/host/x86_64/hostdep.h diff --git a/linux-user/host/aarch64/safe-syscall.inc.S b/common-user/host/aarch64/safe-syscall.inc.S similarity index 100% rename from linux-user/host/aarch64/safe-syscall.inc.S rename to common-user/host/aarch64/safe-syscall.inc.S diff --git a/linux-user/host/arm/safe-syscall.inc.S b/common-user/host/arm/safe-syscall.inc.S similarity index 100% rename from linux-user/host/arm/safe-syscall.inc.S rename to common-user/host/arm/safe-syscall.inc.S diff --git a/linux-user/host/i386/safe-syscall.inc.S b/common-user/host/i386/safe-syscall.inc.S similarity index 100% rename from linux-user/host/i386/safe-syscall.inc.S rename to common-user/host/i386/safe-syscall.inc.S diff --git a/linux-user/host/ppc64/safe-syscall.inc.S b/common-user/host/ppc64/safe-syscall.inc.S similarity index 100% rename from linux-user/host/ppc64/safe-syscall.inc.S rename to common-user/host/ppc64/safe-syscall.inc.S diff --git a/linux-user/host/riscv/safe-syscall.inc.S b/common-user/host/riscv/safe-syscall.inc.S similarity index 100% rename from linux-user/host/riscv/safe-syscall.inc.S rename to common-user/host/riscv/safe-syscall.inc.S diff --git a/linux-user/host/s390x/safe-syscall.inc.S b/common-user/host/s390x/safe-syscall.inc.S similarity index 100% rename from linux-user/host/s390x/safe-syscall.inc.S rename to common-user/host/s390x/safe-syscall.inc.S diff --git a/linux-user/host/x86_64/safe-syscall.inc.S b/common-user/host/x86_64/safe-syscall.inc.S similarity index 100% rename from linux-user/host/x86_64/safe-syscall.inc.S rename to common-user/host/x86_64/safe-syscall.inc.S From patchwork Tue Nov 16 11:02:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 519198 Delivered-To: patch@linaro.org Received: by 2002:ac0:c605:0:0:0:0:0 with SMTP id p5csp6970527imj; Tue, 16 Nov 2021 03:06:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJwAumwMUkTU5OlHMxEbO3OUTLcOfYX6qA9YfhVMx5A5yX9vI8NJ0zioJe+bAzM2ajxJoiOh X-Received: by 2002:a05:620a:1720:: with SMTP id az32mr5351804qkb.259.1637060787162; Tue, 16 Nov 2021 03:06:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637060787; cv=none; d=google.com; s=arc-20160816; b=NfRVpL/PHZv7Qs/scFdl3fEm73AVlTVTrN08ztVoDIkfhZSq6xZ/dxzR6ZSZnVpVSI jckXtT8DFtxKnuiWc8kJXn2JIE/3WmpTDEcxwC9p1pWo0EGURKZ8C3YbMPp2pWGjHo/v tf26YKqrIWXCrpzIG9UAeCO1cthgTIhUNV+3w+1PwdMwMR/hXv8ZwqkEDZ1gVHtDguFt YeEUw7jxhb/+uvPaVlpAMhdGPGABhCPUNAUwjfvWdxz6I6cUdSGF635PccCbtcYwQygp qVCfnV05OkvOzG5ouvTx4VuANIrTc1mzPYrBQFVB8XdiZT51i0uzTOVhjKxOQD/MZ8bQ bIAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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=Xoq3219+S6QUhn6Pd7je4gi18GFwEZswxg82Ghhg8EE=; b=dPMRwq5Xqc/zHw7HyMLSiRk4rSCI/gJOvuB3TOvbVBXCXtW0+3L6BQOLYg3vfXH40a QaJH+uKcfwZ1299LgVRI2SZ2km5Erg5SRthJJdP1M6sH5dyQo2iFfJZS8qhXwtm3bZi/ 2cmO0fMByHNTdE2pBD+evK0TwBu3ZpQ/MR13c0vmczKhI1qhWKOnvnEtSLIBy0l2bGHG qAo1KfBwCxwoTkCugKVlKl8lKLGz1FVUiBTWWGDuesiiJAb3n+dxnjEOw/J5UHGIpsXz bSLSDmREgL0vSS0Wpu99GQHZYouV5JqTvbkoBlsR643qgvKdF+VAuT7v75e4Kp2N98pN gZrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=oQ7kB9Zb; 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=fail (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 u21si26781321qki.111.2021.11.16.03.06.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Nov 2021 03:06:27 -0800 (PST) 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=fail header.i=@linaro.org header.s=google header.b=oQ7kB9Zb; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:50866 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mmwIE-00079b-G2 for patch@linaro.org; Tue, 16 Nov 2021 06:06:26 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60000) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmwF5-0001lv-QM for qemu-devel@nongnu.org; Tue, 16 Nov 2021 06:03:11 -0500 Received: from [2a00:1450:4864:20::434] (port=39892 helo=mail-wr1-x434.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mmwF0-0004v9-Ga for qemu-devel@nongnu.org; Tue, 16 Nov 2021 06:03:11 -0500 Received: by mail-wr1-x434.google.com with SMTP id d27so36783753wrb.6 for ; Tue, 16 Nov 2021 03:03:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Xoq3219+S6QUhn6Pd7je4gi18GFwEZswxg82Ghhg8EE=; b=oQ7kB9Zb31+yTmJ5UAatXvbOmnRYp7vFwO/2FA8jbqtyIKia8VFWLeJ45C+/EEz9EY gC0YMzJA94h+Lu23spipgiTArMZKK0u9fb/++AQf5SsE+u87VyDna1bN55lve6zoOuBH Qu41nk5rcYjQ9PGZ3zPJ8MA1CE869tibqAndhNaa5hIReIjDVDUogWlHG2mrZRJKmKCN 3Zokk0V4qIzkHN7qCVp8e8VkMCl40/oUbCC5vUPqAwVsJU7evlKLWqhqYtecIkpHA7U9 wrREV0qDlO1G8EGjal0QPC0gBg/pbfs1/lLr11lqhzEcCFmMVzd0mrsrOmYAyAgXsEn3 EYIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Xoq3219+S6QUhn6Pd7je4gi18GFwEZswxg82Ghhg8EE=; b=QRMpVCvdJD+HwV4COm0xp4yi/4E+lsx0QpeRXIcBKmFlUj7CutYsGjgG/TRPGZqDKY /34xOGCivvVe5xS8v32ftjp7GOh4n1ACeoECKm01pNE3xhW+KxNNARsiECpWwdrOEexr +R+tAWQGfdwbGnc3iBMTDbH1dRS4+I2u8Icm7QK+Y/L/cCv63D9Bh6WDt1xuOjbm+8pt gSbUgcEBzeE2Gu77ctintiHCAsG9D9z017tD23NEbZjEdQKtlH6jVcbXb9Vi0nAijSE5 g8CGUEMQZ7z4A8rb01lkz8f52OJEUJHmHoOFXtI/d4+E4WTpp6q7PVlxc0gtBWX4y1B7 mOuQ== X-Gm-Message-State: AOAM533fOfjkTNtVGx6h6b+hMRxwaMYURysc3LenhO204ttejw2s8vAs e5C/X5EIA5+4HAokyGZnYrb2XSs26zrxdvNmCcI= X-Received: by 2002:a5d:5643:: with SMTP id j3mr7882125wrw.138.1637060584827; Tue, 16 Nov 2021 03:03:04 -0800 (PST) Received: from localhost.localdomain (145.red-37-158-173.dynamicip.rima-tde.net. [37.158.173.145]) by smtp.gmail.com with ESMTPSA id f15sm2639779wmg.30.2021.11.16.03.03.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Nov 2021 03:03:04 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 4/9] common-user: Move syscall error detection into safe_syscall_base Date: Tue, 16 Nov 2021 12:02:51 +0100 Message-Id: <20211116110256.365484-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211116110256.365484-1-richard.henderson@linaro.org> References: <20211116110256.365484-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::434 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x434.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: , Cc: laurent@vivier.eu, imp@bsdimp.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The current api from safe_syscall_base() is to return -errno, which is the interface provided by *some* linux kernel abis. The wrapper macro, safe_syscall(), detects error, stores into errno, and returns -1, to match the api of the system syscall(). For those kernel abis that do not return -errno natively, this leads to double syscall error detection. E.g. Linux ppc64, which sets the SO flag for error. Simplify the usage from C by moving the error detection into assembly. Signed-off-by: Richard Henderson --- linux-user/safe-syscall.h | 20 +++--- common-user/host/aarch64/safe-syscall.inc.S | 55 +++++++++------- common-user/host/arm/safe-syscall.inc.S | 58 ++++++++++------- common-user/host/i386/safe-syscall.inc.S | 51 +++++++++------ common-user/host/ppc64/safe-syscall.inc.S | 63 +++++++++++-------- common-user/host/riscv/safe-syscall.inc.S | 50 +++++++++------ common-user/host/s390x/safe-syscall.inc.S | 50 +++++++++------ common-user/host/x86_64/safe-syscall.inc.S | 70 ++++++++++++--------- 8 files changed, 243 insertions(+), 174 deletions(-) diff --git a/linux-user/safe-syscall.h b/linux-user/safe-syscall.h index aaa9ffc0e2..ea0e8a8d24 100644 --- a/linux-user/safe-syscall.h +++ b/linux-user/safe-syscall.h @@ -125,23 +125,17 @@ * kinds of restartability. */ #ifdef HAVE_SAFE_SYSCALL -/* The core part of this function is implemented in assembly */ -extern long safe_syscall_base(int *pending, long number, ...); + +/* The core part of this function is implemented in assembly. */ +extern long safe_syscall_base(int *pending, int *errnop, long number, ...); + /* These are defined by the safe-syscall.inc.S file */ extern char safe_syscall_start[]; extern char safe_syscall_end[]; -#define safe_syscall(...) \ - ({ \ - long ret_; \ - int *psp_ = &((TaskState *)thread_cpu->opaque)->signal_pending; \ - ret_ = safe_syscall_base(psp_, __VA_ARGS__); \ - if (is_error(ret_)) { \ - errno = -ret_; \ - ret_ = -1; \ - } \ - ret_; \ - }) +#define safe_syscall(...) \ + safe_syscall_base(&((TaskState *)thread_cpu->opaque)->signal_pending, \ + &errno, __VA_ARGS__) #else diff --git a/common-user/host/aarch64/safe-syscall.inc.S b/common-user/host/aarch64/safe-syscall.inc.S index bc1f5a9792..95c60d8609 100644 --- a/common-user/host/aarch64/safe-syscall.inc.S +++ b/common-user/host/aarch64/safe-syscall.inc.S @@ -17,22 +17,21 @@ .type safe_syscall_start, #function .type safe_syscall_end, #function - /* This is the entry point for making a system call. The calling + /* + * This is the entry point for making a system call. The calling * convention here is that of a C varargs function with the * first argument an 'int *' to the signal_pending flag, the * second one the system call number (as a 'long'), and all further * arguments being syscall arguments (also 'long'). - * We return a long which is the syscall's return value, which - * may be negative-errno on failure. Conversion to the - * -1-and-errno-set convention is done by the calling wrapper. */ safe_syscall_base: .cfi_startproc - /* The syscall calling convention isn't the same as the - * C one: + /* + * The syscall calling convention isn't the same as the C one: * we enter with x0 == *signal_pending - * x1 == syscall number - * x2 ... x7, (stack) == syscall arguments + * x1 == errno + * x2 == syscall number + * x3 ... x7, (stack) == syscall arguments * and return the result in x0 * and the syscall instruction needs * x8 == syscall number @@ -40,17 +39,18 @@ safe_syscall_base: * and returns the result in x0 * Shuffle everything around appropriately. */ - mov x9, x0 /* signal_pending pointer */ - mov x8, x1 /* syscall number */ - mov x0, x2 /* syscall arguments */ - mov x1, x3 - mov x2, x4 - mov x3, x5 - mov x4, x6 - mov x5, x7 - ldr x6, [sp] + mov x10, x0 /* signal_pending pointer */ + mov x11, x1 /* errno pointer */ + mov x8, x2 /* syscall number */ + mov x0, x3 /* syscall arguments */ + mov x1, x4 + mov x2, x5 + mov x3, x6 + mov x4, x7 + ldp x5, x6, [sp] - /* This next sequence of code works in conjunction with the + /* + * This next sequence of code works in conjunction with the * rewind_if_safe_syscall_function(). If a signal is taken * and the interrupted PC is anywhere between 'safe_syscall_start' * and 'safe_syscall_end' then we rewind it to 'safe_syscall_start'. @@ -59,17 +59,26 @@ safe_syscall_base: */ safe_syscall_start: /* if signal_pending is non-zero, don't do the call */ - ldr w10, [x9] - cbnz w10, 0f + ldr w9, [x10] + cbnz w9, 2f svc 0x0 safe_syscall_end: + /* code path for having successfully executed the syscall */ + cmn x0, #4095 + b.cs 1f ret -0: - /* code path when we didn't execute the syscall */ - mov x0, #-TARGET_ERESTARTSYS + /* code path setting errno */ +0: neg w0, w0 /* create positive errno */ +1: str w0, [x11] /* store errno */ + mov x0, #-1 ret + + /* code path when we didn't execute the syscall */ +2: mov w0, #TARGET_ERESTARTSYS + b 1b + .cfi_endproc .size safe_syscall_base, .-safe_syscall_base diff --git a/common-user/host/arm/safe-syscall.inc.S b/common-user/host/arm/safe-syscall.inc.S index 88c4958504..17839c6486 100644 --- a/common-user/host/arm/safe-syscall.inc.S +++ b/common-user/host/arm/safe-syscall.inc.S @@ -22,33 +22,35 @@ .arm .align 2 - /* This is the entry point for making a system call. The calling + /* + * This is the entry point for making a system call. The calling * convention here is that of a C varargs function with the * first argument an 'int *' to the signal_pending flag, the * second one the system call number (as a 'long'), and all further * arguments being syscall arguments (also 'long'). - * We return a long which is the syscall's return value, which - * may be negative-errno on failure. Conversion to the - * -1-and-errno-set convention is done by the calling wrapper. */ safe_syscall_base: .fnstart .cfi_startproc mov r12, sp /* save entry stack */ - push { r4, r5, r6, r7, r8, lr } - .save { r4, r5, r6, r7, r8, lr } - .cfi_adjust_cfa_offset 24 + push { r4, r5, r6, r7, r8, r9, r10, lr } + .save { r4, r5, r6, r7, r8, r9, r10, lr } + .cfi_adjust_cfa_offset 32 .cfi_rel_offset r4, 0 .cfi_rel_offset r5, 4 .cfi_rel_offset r6, 8 .cfi_rel_offset r7, 12 .cfi_rel_offset r8, 16 - .cfi_rel_offset lr, 20 + .cfi_rel_offset r9, 20 + .cfi_rel_offset r10, 24 + .cfi_rel_offset lr, 28 - /* The syscall calling convention isn't the same as the C one: - * we enter with r0 == *signal_pending - * r1 == syscall number - * r2, r3, [sp+0] ... [sp+12] == syscall arguments + /* + * The syscall calling convention isn't the same as the C one: + * we enter with r0 == &signal_pending + * r1 == &errno + * r2 == syscall number + * r3, [sp+0] ... [sp+16] == syscall arguments * and return the result in r0 * and the syscall instruction needs * r7 == syscall number @@ -58,12 +60,13 @@ safe_syscall_base: * Note the 16 bytes that we pushed to save registers. */ mov r8, r0 /* copy signal_pending */ - mov r7, r1 /* syscall number */ - mov r0, r2 /* syscall args */ - mov r1, r3 - ldm r12, { r2, r3, r4, r5, r6 } + mov r9, r1 /* copy errnop */ + mov r7, r2 /* syscall number */ + mov r0, r3 /* syscall args */ + ldm r12, { r1, r2, r3, r4, r5, r6 } - /* This next sequence of code works in conjunction with the + /* + * This next sequence of code works in conjunction with the * rewind_if_safe_syscall_function(). If a signal is taken * and the interrupted PC is anywhere between 'safe_syscall_start' * and 'safe_syscall_end' then we rewind it to 'safe_syscall_start'. @@ -74,16 +77,25 @@ safe_syscall_start: /* if signal_pending is non-zero, don't do the call */ ldr r12, [r8] /* signal_pending */ tst r12, r12 - bne 1f + bne 2f swi 0 safe_syscall_end: - /* code path for having successfully executed the syscall */ - pop { r4, r5, r6, r7, r8, pc } -1: + /* code path for having successfully executed the syscall */ + cmp r0, #-4096 + bhi 0f +9: pop { r4, r5, r6, r7, r8, r9, r10, pc } + + /* code path setting errno */ +0: neg r0, r0 /* create positive errno */ +1: str r0, [r9] /* store errno */ + mov r0, #-1 + b 9b + /* code path when we didn't execute the syscall */ - ldr r0, =-TARGET_ERESTARTSYS - pop { r4, r5, r6, r7, r8, pc } +2: ldr r0, =TARGET_ERESTARTSYS + b 1b + .fnend .cfi_endproc diff --git a/common-user/host/i386/safe-syscall.inc.S b/common-user/host/i386/safe-syscall.inc.S index 9e58fc6504..ad89521783 100644 --- a/common-user/host/i386/safe-syscall.inc.S +++ b/common-user/host/i386/safe-syscall.inc.S @@ -15,14 +15,12 @@ .global safe_syscall_end .type safe_syscall_base, @function - /* This is the entry point for making a system call. The calling + /* + * This is the entry point for making a system call. The calling * convention here is that of a C varargs function with the * first argument an 'int *' to the signal_pending flag, the * second one the system call number (as a 'long'), and all further * arguments being syscall arguments (also 'long'). - * We return a long which is the syscall's return value, which - * may be negative-errno on failure. Conversion to the - * -1-and-errno-set convention is done by the calling wrapper. */ safe_syscall_base: .cfi_startproc @@ -41,9 +39,10 @@ safe_syscall_base: /* The syscall calling convention isn't the same as the C one: * we enter with 0(%esp) == return address - * 4(%esp) == *signal_pending - * 8(%esp) == syscall number - * 12(%esp) ... 32(%esp) == syscall arguments + * 4(%esp) == &signal_pending + * 8(%esp) == &errno + * 12(%esp) == syscall number + * 16(%esp) ... 36(%esp) == syscall arguments * and return the result in eax * and the syscall instruction needs * eax == syscall number @@ -52,14 +51,15 @@ safe_syscall_base: * Shuffle everything around appropriately. * Note the 16 bytes that we pushed to save registers. */ - mov 12+16(%esp), %ebx /* the syscall arguments */ - mov 16+16(%esp), %ecx - mov 20+16(%esp), %edx - mov 24+16(%esp), %esi - mov 28+16(%esp), %edi - mov 32+16(%esp), %ebp + mov 16+16(%esp), %ebx /* the syscall arguments */ + mov 20+16(%esp), %ecx + mov 24+16(%esp), %edx + mov 28+16(%esp), %esi + mov 32+16(%esp), %edi + mov 36+16(%esp), %ebp - /* This next sequence of code works in conjunction with the + /* + * This next sequence of code works in conjunction with the * rewind_if_safe_syscall_function(). If a signal is taken * and the interrupted PC is anywhere between 'safe_syscall_start' * and 'safe_syscall_end' then we rewind it to 'safe_syscall_start'. @@ -70,12 +70,16 @@ safe_syscall_start: /* if signal_pending is non-zero, don't do the call */ mov 4+16(%esp), %eax /* signal_pending */ cmpl $0, (%eax) - jnz 1f + jnz 2f mov 8+16(%esp), %eax /* syscall number */ int $0x80 safe_syscall_end: + /* code path for having successfully executed the syscall */ - pop %ebx + cmp $-4095, %eax + jae 0f + +9: pop %ebx .cfi_remember_state .cfi_adjust_cfa_offset -4 .cfi_restore ebx @@ -90,11 +94,18 @@ safe_syscall_end: .cfi_restore ebp ret -1: - /* code path when we didn't execute the syscall */ .cfi_restore_state - mov $-TARGET_ERESTARTSYS, %eax - jmp safe_syscall_end + + /* code path setting errno */ +0: neg %eax /* create positive errno */ +1: mov 8+16(%esp), %ebx /* load errno pointer */ + mov %eax, (%ebx) /* store errno */ + mov $-1, %eax + jmp 9b + + /* code path when we didn't execute the syscall */ +2: mov $TARGET_ERESTARTSYS, %eax + jmp 1b .cfi_endproc .size safe_syscall_base, .-safe_syscall_base diff --git a/common-user/host/ppc64/safe-syscall.inc.S b/common-user/host/ppc64/safe-syscall.inc.S index 875133173b..e35408c5fb 100644 --- a/common-user/host/ppc64/safe-syscall.inc.S +++ b/common-user/host/ppc64/safe-syscall.inc.S @@ -17,14 +17,19 @@ .text - /* This is the entry point for making a system call. The calling +#if _CALL_ELF == 2 +#define PARAM_OFS 32 +#else +#define PARAM_OFS 48 +#endif +#define PARAM(X) PARAM_OFS + X*8 + + /* + * This is the entry point for making a system call. The calling * convention here is that of a C varargs function with the * first argument an 'int *' to the signal_pending flag, the * second one the system call number (as a 'long'), and all further * arguments being syscall arguments (also 'long'). - * We return a long which is the syscall's return value, which - * may be negative-errno on failure. Conversion to the - * -1-and-errno-set convention is done by the calling wrapper. */ #if _CALL_ELF == 2 safe_syscall_base: @@ -39,9 +44,11 @@ safe_syscall_base: .L.safe_syscall_base: .cfi_startproc #endif - /* We enter with r3 == *signal_pending - * r4 == syscall number - * r5 ... r10 == syscall arguments + /* + * We enter with r3 == &signal_pending + * r4 == &errno + * r5 == syscall number + * r6 ... r10, (stack) == syscall arguments * and return the result in r3 * and the syscall instruction needs * r0 == syscall number @@ -49,18 +56,18 @@ safe_syscall_base: * and returns the result in r3 * Shuffle everything around appropriately. */ - std 14, 16(1) /* Preserve r14 in SP+16 */ - .cfi_offset 14, 16 - mr 14, 3 /* signal_pending */ - mr 0, 4 /* syscall number */ - mr 3, 5 /* syscall arguments */ - mr 4, 6 - mr 5, 7 - mr 6, 8 - mr 7, 9 - mr 8, 10 + mr 11, 3 /* signal_pending pointer */ + std 4, PARAM(1)(1) /* save errno pointer in param slot */ + mr 0, 5 /* syscall number */ + mr 3, 6 /* syscall arguments */ + mr 4, 7 + mr 5, 8 + mr 6, 9 + mr 7, 10 + ld 8, PARAM(8)(1) - /* This next sequence of code works in conjunction with the + /* + * This next sequence of code works in conjunction with the * rewind_if_safe_syscall_function(). If a signal is taken * and the interrupted PC is anywhere between 'safe_syscall_start' * and 'safe_syscall_end' then we rewind it to 'safe_syscall_start'. @@ -69,23 +76,25 @@ safe_syscall_base: */ safe_syscall_start: /* if signal_pending is non-zero, don't do the call */ - lwz 12, 0(14) + lwz 12, 0(11) cmpwi 0, 12, 0 bne- 0f sc safe_syscall_end: - /* code path when we did execute the syscall */ - ld 14, 16(1) /* restore r14 to its original value */ - bnslr+ - /* syscall failed; return negative errno */ - neg 3, 3 + /* code path for having successfully executed the syscall */ + bnslr+ /* SO set for syscall error */ + + /* code path setting errno */ +1: ld 11, PARAM(1)(1) /* restore errno pointer */ + stw 3, 0(11) /* store errno */ + li 3, -1 blr /* code path when we didn't execute the syscall */ -0: addi 3, 0, -TARGET_ERESTARTSYS - ld 14, 16(1) /* restore r14 to its original value */ - blr +0: li 3, TARGET_ERESTARTSYS + b 1b + .cfi_endproc #if _CALL_ELF == 2 diff --git a/common-user/host/riscv/safe-syscall.inc.S b/common-user/host/riscv/safe-syscall.inc.S index 9ca3fbfd1e..eddede702b 100644 --- a/common-user/host/riscv/safe-syscall.inc.S +++ b/common-user/host/riscv/safe-syscall.inc.S @@ -23,17 +23,15 @@ * first argument an 'int *' to the signal_pending flag, the * second one the system call number (as a 'long'), and all further * arguments being syscall arguments (also 'long'). - * We return a long which is the syscall's return value, which - * may be negative-errno on failure. Conversion to the - * -1-and-errno-set convention is done by the calling wrapper. */ safe_syscall_base: .cfi_startproc /* * The syscall calling convention is nearly the same as C: - * we enter with a0 == *signal_pending - * a1 == syscall number - * a2 ... a7 == syscall arguments + * we enter with a0 == &signal_pending + * a1 == &errno + * a2 == syscall number + * a3 ... a7, [sp] == syscall arguments * and return the result in a0 * and the syscall instruction needs * a7 == syscall number @@ -42,14 +40,19 @@ safe_syscall_base: * Shuffle everything around appropriately. */ mv t0, a0 /* signal_pending pointer */ - mv t1, a1 /* syscall number */ - mv a0, a2 /* syscall arguments */ - mv a1, a3 - mv a2, a4 - mv a3, a5 - mv a4, a6 - mv a5, a7 - mv a7, t1 + mv t1, a1 /* errno pointer */ + mv t2, a2 /* syscall number */ + mv a0, a3 /* syscall arguments */ + mv a1, a4 + mv a2, a5 + mv a3, a6 + mv a4, a7 +#if __riscv_xlen == 32 + lw a5, 0(sp) +#else + ld a5, 0(sp) +#endif + mv a7, t2 /* * This next sequence of code works in conjunction with the @@ -61,17 +64,26 @@ safe_syscall_base: */ safe_syscall_start: /* If signal_pending is non-zero, don't do the call */ - lw t1, 0(t0) - bnez t1, 0f + lw t2, 0(t0) + bnez t2, 2f scall safe_syscall_end: + /* code path for having successfully executed the syscall */ + li t2, -4096 + bgtu a0, t2, 0f ret -0: - /* code path when we didn't execute the syscall */ - li a0, -TARGET_ERESTARTSYS + /* code path setting errno */ +0: neg a0, a0 /* create positive errno */ +1: sw a0, 0(t1) /* store errno */ + li a0, -1 ret + + /* code path when we didn't execute the syscall */ +2: li a0, TARGET_ERESTARTSYS + j 1b + .cfi_endproc .size safe_syscall_base, .-safe_syscall_base diff --git a/common-user/host/s390x/safe-syscall.inc.S b/common-user/host/s390x/safe-syscall.inc.S index 414b44ad38..f2a3bccc13 100644 --- a/common-user/host/s390x/safe-syscall.inc.S +++ b/common-user/host/s390x/safe-syscall.inc.S @@ -15,14 +15,12 @@ .global safe_syscall_end .type safe_syscall_base, @function - /* This is the entry point for making a system call. The calling + /* + * This is the entry point for making a system call. The calling * convention here is that of a C varargs function with the * first argument an 'int *' to the signal_pending flag, the * second one the system call number (as a 'long'), and all further * arguments being syscall arguments (also 'long'). - * We return a long which is the syscall's return value, which - * may be negative-errno on failure. Conversion to the - * -1-and-errno-set convention is done by the calling wrapper. */ safe_syscall_base: .cfi_startproc @@ -44,11 +42,13 @@ safe_syscall_base: stg %r1,0(%r15) /* store back chain */ stg %r0,8(%r15) /* store eos */ - /* The syscall calling convention isn't the same as the + /* + * The syscall calling convention isn't the same as the * C one: - * we enter with r2 == *signal_pending - * r3 == syscall number - * r4, r5, r6, (stack) == syscall arguments + * we enter with r2 == &signal_pending + * r3 == &errno + * r4 == syscall number + * r5, r6, (stack) == syscall arguments * and return the result in r2 * and the syscall instruction needs * r1 == syscall number @@ -57,13 +57,14 @@ safe_syscall_base: * Shuffle everything around appropriately. */ lgr %r8,%r2 /* signal_pending pointer */ - lgr %r1,%r3 /* syscall number */ - lgr %r2,%r4 /* syscall args */ - lgr %r3,%r5 - lgr %r4,%r6 - lmg %r5,%r7,320(%r15) + lgr %r9,%r3 /* errno pointer */ + lgr %r1,%r4 /* syscall number */ + lgr %r2,%r5 /* syscall args */ + lgr %r3,%r6 + lmg %r4,%r7,320(%r15) - /* This next sequence of code works in conjunction with the + /* + * This next sequence of code works in conjunction with the * rewind_if_safe_syscall_function(). If a signal is taken * and the interrupted PC is anywhere between 'safe_syscall_start' * and 'safe_syscall_end' then we rewind it to 'safe_syscall_start'. @@ -73,18 +74,31 @@ safe_syscall_base: safe_syscall_start: /* if signal_pending is non-zero, don't do the call */ icm %r0,15,0(%r8) - jne 2f + jne 1f svc 0 safe_syscall_end: -1: lg %r15,0(%r15) /* load back chain */ + /* code path for having successfully executed the syscall */ + lghi %r0, -4095 /* check for syscall error */ + clgr %r2, %r0 + jgnl 0f + +9: lg %r15,0(%r15) /* load back chain */ .cfi_remember_state .cfi_adjust_cfa_offset -160 lmg %r6,%r15,48(%r15) /* load saved registers */ br %r14 .cfi_restore_state -2: lghi %r2, -TARGET_ERESTARTSYS - j 1b + + /* code path when we didn't execute the syscall */ +1: lghi %r2, -TARGET_ERESTARTSYS + + /* code path setting errno */ +0: lcr %r2, %r2 /* create positive errno */ + st %r2, 0(%r9) /* store errno */ + lghi %r2, -1 + j 9b + .cfi_endproc .size safe_syscall_base, .-safe_syscall_base diff --git a/common-user/host/x86_64/safe-syscall.inc.S b/common-user/host/x86_64/safe-syscall.inc.S index f36992daa3..9a0c4c93b4 100644 --- a/common-user/host/x86_64/safe-syscall.inc.S +++ b/common-user/host/x86_64/safe-syscall.inc.S @@ -14,18 +14,17 @@ .global safe_syscall_end .type safe_syscall_base, @function - /* This is the entry point for making a system call. The calling + /* + * This is the entry point for making a system call. The calling * convention here is that of a C varargs function with the * first argument an 'int *' to the signal_pending flag, the * second one the system call number (as a 'long'), and all further * arguments being syscall arguments (also 'long'). - * We return a long which is the syscall's return value, which - * may be negative-errno on failure. Conversion to the - * -1-and-errno-set convention is done by the calling wrapper. */ safe_syscall_base: .cfi_startproc - /* This saves a frame pointer and aligns the stack for the syscall. + /* + * This saves a frame pointer and aligns the stack for the syscall. * (It's unclear if the syscall ABI has the same stack alignment * requirements as the userspace function call ABI, but better safe than * sorry. Appendix A2 of http://www.x86-64.org/documentation/abi.pdf @@ -35,11 +34,12 @@ safe_syscall_base: .cfi_adjust_cfa_offset 8 .cfi_rel_offset rbp, 0 - /* The syscall calling convention isn't the same as the - * C one: - * we enter with rdi == *signal_pending - * rsi == syscall number - * rdx, rcx, r8, r9, (stack), (stack) == syscall arguments + /* + * The syscall calling convention isn't the same as the C one: + * we enter with rdi == &signal_pending + * rsi == &errno + * rdx == syscall number + * rcx, r8, r9, (stack...) == syscall arguments * and return the result in rax * and the syscall instruction needs * rax == syscall number @@ -48,17 +48,19 @@ safe_syscall_base: * Shuffle everything around appropriately. * Note that syscall will trash rcx and r11. */ - mov %rsi, %rax /* syscall number */ - mov %rdi, %rbp /* signal_pending pointer */ + mov %rdi, %r11 /* signal_pending pointer */ + mov %rsi, %rbp /* errno pointer */ + mov %rdx, %rax /* syscall number */ /* and the syscall arguments */ - mov %rdx, %rdi - mov %rcx, %rsi - mov %r8, %rdx - mov %r9, %r10 - mov 16(%rsp), %r8 - mov 24(%rsp), %r9 + mov %rcx, %rdi + mov %r8, %rsi + mov %r9, %rdx + mov 16(%rsp), %r10 + mov 24(%rsp), %r8 + mov 32(%rsp), %r9 - /* This next sequence of code works in conjunction with the + /* + * This next sequence of code works in conjunction with the * rewind_if_safe_syscall_function(). If a signal is taken * and the interrupted PC is anywhere between 'safe_syscall_start' * and 'safe_syscall_end' then we rewind it to 'safe_syscall_start'. @@ -67,25 +69,31 @@ safe_syscall_base: */ safe_syscall_start: /* if signal_pending is non-zero, don't do the call */ - cmpl $0, (%rbp) - jnz 1f + cmpl $0, (%r11) + jnz 2f syscall safe_syscall_end: + /* code path for having successfully executed the syscall */ - pop %rbp + cmp $-4095, %rax + jae 0f + +9: pop %rbp .cfi_remember_state .cfi_def_cfa_offset 8 .cfi_restore rbp ret - -1: - /* code path when we didn't execute the syscall */ .cfi_restore_state - mov $-TARGET_ERESTARTSYS, %rax - pop %rbp - .cfi_def_cfa_offset 8 - .cfi_restore rbp - ret - .cfi_endproc + /* code path setting errno */ +0: neg %eax /* create positive errno */ +1: mov %eax, (%rbp) /* store errno */ + mov $-1, %rax + jmp 9b + + /* code path when we didn't execute the syscall */ +2: mov $TARGET_ERESTARTSYS, %eax + jmp 1b + + .cfi_endproc .size safe_syscall_base, .-safe_syscall_base From patchwork Tue Nov 16 11:02:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 519199 Delivered-To: patch@linaro.org Received: by 2002:ac0:c605:0:0:0:0:0 with SMTP id p5csp6972947imj; Tue, 16 Nov 2021 03:08:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJwNy5pkZuuDUzvbvrEIkAtJEYzHdM3WAUE2BMqGpbI0KJeVQf72osPXEk8iHpdRJ8u9TZWd X-Received: by 2002:a05:6122:1788:: with SMTP id o8mr71433242vkf.8.1637060921158; Tue, 16 Nov 2021 03:08:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637060921; cv=none; d=google.com; s=arc-20160816; b=0qFrJsfWPUfaSghWJ9ny4OTIClkxwBSzqbaDVX3QiJRg5LPsJPRLXBgtynMR1WOPKQ c/X98MVVVD6KSXhEO9P/e+98bOO+d/Bl6DQslqlYpI/qzJoXHuVnOft9wnrPa0S02CZH kgW9Ke5iS9Yt5VWxTECRE+PZKKG+dEUE0qMbSSUlR1jTqb+z85j9bxLo39nvjBpBdoOM WNarQgXGgDLfIQvaS2MWFBmjdTaCfQcTHypxwE6Q36tdZNBFWP0mc9Y+KdI83BKqpwJ6 Vf4ocf6x+qapP7AW2Rohpif2p/PHQrwIJPeOxYNmRIgSpIefhcAj4AQ7jS/ZdmNYO1Pa 7e8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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=2fImwBgyiUxW2cyko0HSyaGAM3opUFv591S/8+t1daM=; b=zpSNG+YYFnQjxfL0fo4Mm9cY1WxLcB5hQ6ujtfCwOi6sjXn8Q/TxOjOzexpEIK5QdE BBF1eIWZBCU9caiTFu8T9iwmYDfxR6dzwMhwq3mgeWyNf2Mpp4gXeWhjFBBSQHKNhRBw TZkUpmNSx5zxb6850J8UZ95885TD/Y7JOzRGJcz1jwZT3GC5sc+vTDtqOVKlgl0+HDXS k3TFEQzFjw2rrcBnHgEpPdfeao+hoRzXPwd7f76AhfaUh5fomTEr2LKsPuVyUWM1h3Gn Bnimjw0hQuvRhch6ZisZcdeId+/5vLHAFfBjVKQ0g945ZqNR19h7glLUvYFCSMruN4zP 4ANQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Bx1EDe6e; 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=fail (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 b12si18897511vsj.127.2021.11.16.03.08.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Nov 2021 03:08:41 -0800 (PST) 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=fail header.i=@linaro.org header.s=google header.b=Bx1EDe6e; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59268 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mmwKO-0004Jq-IK for patch@linaro.org; Tue, 16 Nov 2021 06:08:40 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60046) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmwF8-0001wQ-D5 for qemu-devel@nongnu.org; Tue, 16 Nov 2021 06:03:14 -0500 Received: from [2a00:1450:4864:20::329] (port=56064 helo=mail-wm1-x329.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mmwF1-0004vL-MM for qemu-devel@nongnu.org; Tue, 16 Nov 2021 06:03:14 -0500 Received: by mail-wm1-x329.google.com with SMTP id p18so7170596wmq.5 for ; Tue, 16 Nov 2021 03:03:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2fImwBgyiUxW2cyko0HSyaGAM3opUFv591S/8+t1daM=; b=Bx1EDe6endb4vBcTy97thv4Fbl2+EuYoq+0wEKIa9Afi8wREUJBOzzxrc5aj5LxGxX SsJGIDQZScqQvsm7gu59K5KRla7wag6/yDq4qFL7t4qsPQBZWuObSzeuOy3YMiNoqUEJ 0CrusgUbwIe5CEZbsC8q3Z+Nd9QOGTK81MJCa/jd86/Hvc/OH8yEB2yDfPbTZPM+/5+c fgWsr4Fkq9os88ZbL5a66sZvWCIOBOU2kqtDHjYRO5+woRbHMvLJXoskgkA1XPnMwiJ1 Y7J0c4nGAAEj12hp8/ME7D67FhteeVTvaeHCNiflvhzBo7Ot0CXgaSUKYt6kMtZJH/BS jgyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2fImwBgyiUxW2cyko0HSyaGAM3opUFv591S/8+t1daM=; b=NqUYjh6wEUPtv9WS30sF9GaSJP7GaIuQUYXIUqIDKSTMOPmVgV8t/3FeNZykyN+oml T/wq2SAUht+aTcRQoGtXdQj1SopAGByz3A7tu1GPgqMNC9ZoDHO0IPSyC4orobJ9OD7w EDJ9SCwJfBb+RJYMz5T7yQzIT3Z+Ofw/n8JBfo7W9v7XjiCtXgSEdHokiAkYk0Co5xzI W8Moa7keBy6UFrqqyoDYrZtDU0hsAJHsYLn98xiWPcDiergQH7xj8h7fqQcb5AQ22w6o Ab6WyLVJMctKEQwnDa1jg9N+oFv/B6RWIjxXLXYC8HQPRz+CrYOGZm8L7c+26JM90fN4 rs8Q== X-Gm-Message-State: AOAM531geGu3A9Z/tBXUA1QjcdoCkp8WMV75AL0NAtZRaAlgbMAF6CXH mDj0ZLcP2RLMhTAcFOvR9QrTAMnd1/Qm3MhhXtU= X-Received: by 2002:a05:600c:299:: with SMTP id 25mr19724470wmk.77.1637060586216; Tue, 16 Nov 2021 03:03:06 -0800 (PST) Received: from localhost.localdomain (145.red-37-158-173.dynamicip.rima-tde.net. [37.158.173.145]) by smtp.gmail.com with ESMTPSA id f15sm2639779wmg.30.2021.11.16.03.03.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Nov 2021 03:03:05 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 5/9] common-user/host/mips: Add safe-syscall.inc.S Date: Tue, 16 Nov 2021 12:02:52 +0100 Message-Id: <20211116110256.365484-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211116110256.365484-1-richard.henderson@linaro.org> References: <20211116110256.365484-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::329 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x329.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: , Cc: laurent@vivier.eu, imp@bsdimp.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- common-user/host/mips/hostdep.h | 2 + common-user/host/mips/safe-syscall.inc.S | 135 +++++++++++++++++++++++ 2 files changed, 137 insertions(+) create mode 100644 common-user/host/mips/hostdep.h create mode 100644 common-user/host/mips/safe-syscall.inc.S diff --git a/common-user/host/mips/hostdep.h b/common-user/host/mips/hostdep.h new file mode 100644 index 0000000000..b18aca1deb --- /dev/null +++ b/common-user/host/mips/hostdep.h @@ -0,0 +1,2 @@ +/* We have a safe-syscall.inc.S */ +#define HAVE_SAFE_SYSCALL diff --git a/common-user/host/mips/safe-syscall.inc.S b/common-user/host/mips/safe-syscall.inc.S new file mode 100644 index 0000000000..1e2f5a079c --- /dev/null +++ b/common-user/host/mips/safe-syscall.inc.S @@ -0,0 +1,135 @@ +/* + * safe-syscall.inc.S : host-specific assembly fragment + * to handle signals occurring at the same time as system calls. + * This is intended to be included by linux-user/safe-syscall.S + * + * Written by Richard Henderson + * Copyright (C) 2021 Linaro, Inc. + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include "sys/regdef.h" +#include "sys/asm.h" + + .text + .set nomips16 + .set noreorder + + .global safe_syscall_start + .global safe_syscall_end + .type safe_syscall_start, @function + .type safe_syscall_end, @function + + /* + * This is the entry point for making a system call. The calling + * convention here is that of a C varargs function with the + * first argument an 'int *' to the signal_pending flag, the + * second one the system call number (as a 'long'), and all further + * arguments being syscall arguments (also 'long'). + */ + +#if _MIPS_SIM == _ABIO32 +/* Do not allocate a stack frame and store into the parameter space. */ +#define FRAME 0 +#define ERRNOP 4 +#else +/* Allocate a stack frame and store into the first allocated slot. */ +#define FRAME 16 +#define ERRNOP 0 +#endif + +NESTED(safe_syscall_base, FRAME, ra) + .cfi_startproc +#if _MIPS_SIM == _ABIO32 + /* + * The syscall calling convention is nearly the same as C: + * we enter with a0 == &signal_pending + * a1 == &errno + * a2 == syscall number + * a3, stack == syscall arguments + * and return the result in a0 + * and the syscall instruction needs + * v0 == syscall number + * a0 ... a3, stack == syscall arguments + * and returns the result in v0 + * Shuffle everything around appropriately. + */ + move t0, a0 /* signal_pending pointer */ + sw a1, ERRNOP(sp) /* errno pointer */ + move v0, a2 /* syscall number */ + move a0, a3 /* syscall arguments */ + lw a1, 16(sp) + lw a2, 20(sp) + lw a3, 24(sp) + lw t4, 28(sp) + lw t5, 32(sp) + lw t6, 40(sp) + lw t7, 44(sp) + sw t4, 16(sp) + sw t5, 20(sp) + sw t6, 24(sp) + sw t7, 28(sp) +#else + PTR_ADDIU sp, sp, -FRAME + .cfi_adjust_cfa_offset FRAME + + /* + * The syscall calling convention is nearly the same as C: + * we enter with a0 == &signal_pending + * a1 == &errno + * a2 == syscall number + * a3 ... a7, stack == syscall arguments + * and return the result in a0 + * and the syscall instruction needs + * v0 == syscall number + * a0 ... a5 == syscall arguments + * and returns the result in v0 + * Shuffle everything around appropriately. + */ + move t0, a0 /* signal_pending pointer */ + PTR_S a1, ERRNOP(sp) /* save errno pointer */ + move v0, a2 /* syscall number */ + move a0, a3 /* syscall arguments */ + move a1, a4 + move a2, a5 + move a3, a6 + move a4, a7 + ld a5, 16(sp) +#endif + + /* + * This next sequence of code works in conjunction with the + * rewind_if_safe_syscall_function(). If a signal is taken + * and the interrupted PC is anywhere between 'safe_syscall_start' + * and 'safe_syscall_end' then we rewind it to 'safe_syscall_start'. + * The code sequence must therefore be able to cope with this, and + * the syscall instruction must be the final one in the sequence. + */ +safe_syscall_start: + /* If signal_pending is non-zero, don't do the call */ + lw t1, 0(t0) + bnez t1, 0f + nop + syscall +safe_syscall_end: + + /* code path for having successfully executed the syscall */ + bnez a3, 1f + nop + jr ra + PTR_ADDIU sp, sp, FRAME + + /* code path when we didn't execute the syscall */ +0: li v0, TARGET_ERESTARTSYS + + /* code path setting errno */ +1: PTR_L t0, ERRNOP(sp) + sw v0, 0(t0) /* store errno */ + li v0, -1 + jr ra + PTR_ADDIU sp, sp, FRAME + + .cfi_endproc +END(safe_syscall_base) From patchwork Tue Nov 16 11:02:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 519196 Delivered-To: patch@linaro.org Received: by 2002:ac0:c605:0:0:0:0:0 with SMTP id p5csp6970504imj; Tue, 16 Nov 2021 03:06:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJxB775SpCBflBZdV4lEnbRC+8IkOjWuoByQ2hek1zE2t2Pk1PnL7klF6rP6keRIBMjb1B3L X-Received: by 2002:a05:622a:590:: with SMTP id c16mr6485784qtb.289.1637060785893; Tue, 16 Nov 2021 03:06:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637060785; cv=none; d=google.com; s=arc-20160816; b=e0kmbb1iknRFWQt9V2rYugzVlOucEJuGWjAtmIYqSoZzJdK9CWLyL6RIYGWiwlTXR4 M3RsPwAQza7e/2sTWDBse6/8jMRW0dMBTFeBroej9f6YRDyu4Bn18PAFIdOWPQ3S4PD2 iTMKA+2iNA3Q+rIrnK6+ff6o9eGgg+pXXASbqT1QIxVYhHggf24UtsImdhGHKwZvZ0L5 5786Uw812HeYdAdtdGziy+oEX/DZ/Lc0MN+ruYbIOdOruLVecnMAFB6IERIOuJDZ89mK +perjWWvp4LlKHghzEYvLG+AyxOkPyrmDTAgCBeFRaDN3zLZaL4vnv4fIwBPER8f7WyT d8jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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=Si5w/xVL8tcePRB9XtTS7XLZl+YblTkzCMS4YZk/72Q=; b=EIi6KW903SjsCD0IcRnpUpODO3XcZsLtaPo8E7n4x5Yv3NF7SLEIx7pVMYXxOTzJmP tBp5jxk0tOwr5q5uj5F2JemZjrPtT/bgK2eqxemO84q+XZuFVWuV8ubHK+0kXNHgdf/5 +FdzOMEfGsraFKjCuAQurpvUPEG+3uTKAeXCjIghY1TX0k93Sq0Qn9h75/16pN8DR6Tm afdq41sNFB5cxfK5aCGjS4qX4wjBoZvSqZ4VJr3WpQLx2zIlraqxr/CHP+uWos2sarNu P0xb1wklRfaYeSdZ9lBbE/lhWZyQG+kAJSQVdEFNhxgNTAyPiSyZFnDtxwczLPMMR88V nJhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Q1EpEtff; 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=fail (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 g1si29246604vsa.441.2021.11.16.03.06.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Nov 2021 03:06:25 -0800 (PST) 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=fail header.i=@linaro.org header.s=google header.b=Q1EpEtff; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:50856 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mmwID-00079F-5P for patch@linaro.org; Tue, 16 Nov 2021 06:06:25 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60022) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmwF7-0001sO-6d for qemu-devel@nongnu.org; Tue, 16 Nov 2021 06:03:13 -0500 Received: from [2a00:1450:4864:20::330] (port=51941 helo=mail-wm1-x330.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mmwF3-0004vP-7A for qemu-devel@nongnu.org; Tue, 16 Nov 2021 06:03:12 -0500 Received: by mail-wm1-x330.google.com with SMTP id z200so16535504wmc.1 for ; Tue, 16 Nov 2021 03:03:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Si5w/xVL8tcePRB9XtTS7XLZl+YblTkzCMS4YZk/72Q=; b=Q1EpEtffCGDP6QxKUCUY5hmACO69iQqdbqzd3oeuV5ZVpwBqX8U2ZbKT6r02TyW7gA mSM3pWbifi9kQpjPD+4AW2DqG+khHLF74yNY2AJNmiz7/pgQnkwTpbp1AV6CTXn8qwum XSfO8Hmh4hHfDhb0CXHpMvepQPHU0gJHWRSwZD0Nsj8LKup6pldvhwXq2wdiD9h8v3Ut lQJcWJMxQD5gnQ11CVI6sMPaAVh5Y1F6iFJH3JHXPC4QWltSaoio5TI+G004QCcQTLmg o1uT8ICDyyQmm07vk0sDxTl0kyKbm8GP45GX/thBt2PNUR0s/C4YGqiBbVuTarJwfVw5 nITQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Si5w/xVL8tcePRB9XtTS7XLZl+YblTkzCMS4YZk/72Q=; b=sV/OyNApp3X6vlBYnC2qUsiTXBUhwXPiDmIvWSWMpyjYtvF81LjLZBirYoldC7unZf cXMEItx5tCJyCvI+51/gDM2iWu+kRJ5zIPDfkgWnQ89UA/ghbKhH7+ny61IS3DIXE/pZ thZD2l20l9PE3K85cU7h/hWbHTaCOh3gXaryC+IvYjp5ynBvoqnCSsGEBLbDadCG5Ml6 8fkbcmxFpbTIUvZ3rIU4La7sWwaEDYCr12SLQiFDpj/bgCbEB8+COnaVg1EDz/Y9Hcb9 nLCcnePvr5QEthcZUrzrU+ktaEQMhR0b79H4j9r/TSvf8WZe+RprWEzxD+y0iFZJooQz 9I/A== X-Gm-Message-State: AOAM533dwDa/qKFRWTER+42rTONn81PHWEfx0cJKgSqpyM0J5kqpEEDm MlNdLC6FZIeZcx1556LtOgysU97YQ6M9vWTjbSE= X-Received: by 2002:a7b:c76e:: with SMTP id x14mr6793608wmk.27.1637060587769; Tue, 16 Nov 2021 03:03:07 -0800 (PST) Received: from localhost.localdomain (145.red-37-158-173.dynamicip.rima-tde.net. [37.158.173.145]) by smtp.gmail.com with ESMTPSA id f15sm2639779wmg.30.2021.11.16.03.03.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Nov 2021 03:03:07 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 6/9] common-user/host/sparc64: Add safe-syscall.inc.S Date: Tue, 16 Nov 2021 12:02:53 +0100 Message-Id: <20211116110256.365484-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211116110256.365484-1-richard.henderson@linaro.org> References: <20211116110256.365484-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::330 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x330.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: , Cc: laurent@vivier.eu, imp@bsdimp.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- common-user/host/sparc64/hostdep.h | 2 + common-user/host/sparc64/safe-syscall.inc.S | 91 +++++++++++++++++++++ 2 files changed, 93 insertions(+) create mode 100644 common-user/host/sparc64/hostdep.h create mode 100644 common-user/host/sparc64/safe-syscall.inc.S diff --git a/common-user/host/sparc64/hostdep.h b/common-user/host/sparc64/hostdep.h new file mode 100644 index 0000000000..b18aca1deb --- /dev/null +++ b/common-user/host/sparc64/hostdep.h @@ -0,0 +1,2 @@ +/* We have a safe-syscall.inc.S */ +#define HAVE_SAFE_SYSCALL diff --git a/common-user/host/sparc64/safe-syscall.inc.S b/common-user/host/sparc64/safe-syscall.inc.S new file mode 100644 index 0000000000..2492fcbd9e --- /dev/null +++ b/common-user/host/sparc64/safe-syscall.inc.S @@ -0,0 +1,91 @@ +/* + * safe-syscall.inc.S : host-specific assembly fragment + * to handle signals occurring at the same time as system calls. + * This is intended to be included by linux-user/safe-syscall.S + * + * Written by Richard Henderson + * Copyright (C) 2021 Red Hat, Inc. + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + + .text + .balign 4 + + .global safe_syscall_base + .global safe_syscall_start + .global safe_syscall_end + .type safe_syscall_base, @function + .type safe_syscall_start, @object + .type safe_syscall_end, @object + +#define STACK_BIAS 2047 +#define PARAM(N) STACK_BIAS + N*8 + + /* + * This is the entry point for making a system call. The calling + * convention here is that of a C varargs function with the + * first argument an 'int *' to the signal_pending flag, the + * second one the system call number (as a 'long'), and all further + * arguments being syscall arguments (also 'long'). + */ +safe_syscall_base: + .cfi_startproc + /* + * The syscall calling convention isn't the same as the C one: + * we enter with o0 == *signal_pending + * o1 == errno + * o2 == syscall number + * o3 ... o5, (stack) == syscall arguments + * and return the result in x0 + * and the syscall instruction needs + * g1 == syscall number + * o0 ... o5 == syscall arguments + * and returns the result in o0 + * Shuffle everything around appropriately. + */ + mov %o0, %g2 /* signal_pending pointer */ + stx %o1, [%sp + PARAM(1)] /* save errno pointer */ + mov %o2, %g1 /* syscall number */ + mov %o3, %o0 /* syscall arguments */ + mov %o4, %o1 + mov %o5, %o2 + ldx [%sp + PARAM(6)], %o3 + ldx [%sp + PARAM(7)], %o4 + ldx [%sp + PARAM(8)], %o5 + + /* + * This next sequence of code works in conjunction with the + * rewind_if_safe_syscall_function(). If a signal is taken + * and the interrupted PC is anywhere between 'safe_syscall_start' + * and 'safe_syscall_end' then we rewind it to 'safe_syscall_start'. + * The code sequence must therefore be able to cope with this, and + * the syscall instruction must be the final one in the sequence. + */ +safe_syscall_start: + /* if signal_pending is non-zero, don't do the call */ + lduw [%g2], %g3 + brnz,pn %g3, 2f + nop + ta 0x6d +safe_syscall_end: + + /* code path for having successfully executed the syscall */ + bcc,pt %xcc, 9f + nop + + /* code path setting errno */ +1: ldx [%sp + PARAM(1)], %g2 + stw %o0, [%g2] /* store errno */ + set -1, %o0 + +9: ret + nop + + /* code path when we didn't execute the syscall */ +2: ba,pt %xcc, 1b + set TARGET_ERESTARTSYS, %o0 + + .cfi_endproc + .size safe_syscall_base, .-safe_syscall_base From patchwork Tue Nov 16 11:02:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 519195 Delivered-To: patch@linaro.org Received: by 2002:ac0:c605:0:0:0:0:0 with SMTP id p5csp6970411imj; Tue, 16 Nov 2021 03:06:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJw5YQQXxixa9+4TT+asHqjxlVcQlR2Q4vbfY9DgwwMJFyHvcTc2h62of2vYKnys/lpSfFUX X-Received: by 2002:a05:6102:c4d:: with SMTP id y13mr53871914vss.43.1637060781907; Tue, 16 Nov 2021 03:06:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637060781; cv=none; d=google.com; s=arc-20160816; b=STsRZkIr0tigiYfoi+FIZMsp4uw33c6V5oTX+7xRRuFlBaH4V+t/+XbLgyo4yEEdaH 50NVMydI8nE1e8DXXQV+p/Ng1VMUAMtDewZoli6jpyKTCcgmeKigkXTwd4GSJRTm4Ejg Fxw0jKY8m/I9qXZrWI1lNXv35L2pTTV8xL8Cn2ZgOhpou84SMFNcGAXq/dwdh8YhuKIw pd0C18zeYGx88ynH32W9QEf2blbIwRJgZVgPipOyzOUpi7ORxoJivx+YgTa7FB4Ewr0K IVG0zQn+E6n9oqRxJSmJzq0oH/WsSqL8OGprRCazJSTLNxQd1EqIpOz+D3tdUOWhYAyQ dAZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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=97TnL/zZTuZneeKyX3ZHf+5FRTGzASpgACrDLgbvpRc=; b=rZPt4Yrrq1o6JBOOkrmLX0VNnYCJ8OyEyIMVLzC7YLV8QEFoQlv7Jq4b5YSegVCvja 6xsx5mwrY+ScpD7eT6amz5LCRMIyySDvXS83FaIgkJe2deIU+nXjKMX2woNSfxqOJJZi Xtm+kFog7xBlZkLm7+tiCIR6Ohd41FfqtdsehH8moRdkHeBfsqjmCZLv2NuIYBJl5FnU jthRb+awiaCj8vuAZHeP/uLDvnyysJfvOeGo0Kg2JRdL3zOe5tvlkFWO3euhUK82Y+Gz WY/b9XcVbm7Sygd6YkcSLYvRDFTt+cxeY34uY3Jc7EoCdwQ6OA9Z0T4712jJe3FeR39h MxaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=rX80InAD; 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=fail (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 l2si38924178uac.120.2021.11.16.03.06.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Nov 2021 03:06:21 -0800 (PST) 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=fail header.i=@linaro.org header.s=google header.b=rX80InAD; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:50432 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mmwI9-0006sv-9I for patch@linaro.org; Tue, 16 Nov 2021 06:06:21 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60040) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmwF8-0001wI-2z for qemu-devel@nongnu.org; Tue, 16 Nov 2021 06:03:14 -0500 Received: from [2a00:1450:4864:20::331] (port=54961 helo=mail-wm1-x331.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mmwF4-0004vV-Nr for qemu-devel@nongnu.org; Tue, 16 Nov 2021 06:03:13 -0500 Received: by mail-wm1-x331.google.com with SMTP id i12so15685099wmq.4 for ; Tue, 16 Nov 2021 03:03:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=97TnL/zZTuZneeKyX3ZHf+5FRTGzASpgACrDLgbvpRc=; b=rX80InADBbCQhLIF1AybPHOr0kfbZPdeXU8/oCnEI0Rrx/wCUlKV1ZqGClpDPRXg3v HYlVQS4wvjXBvXsbIrD6KNkHKPT+yp0fVPRDSWRdCeACuWOjdWJVgYVF2XFUJL9Pb7bf lBaCxDLpWLccz6riAhNUbzUNaG5Fg8108iMLhVmSJx8ivHmrPVbXzFIWyS83ttzoVVYL Uw0dj/RUNOhpb83Oqfj+8Haenv+w6I5uYnlHPYzwmaNJdn8iX0a2foRIhGnsGc0Ar3vr CuJDFM5SaL382N+MMxRtOA0TA/k84NWQyt166Jl+8sfuduK2wKtHQpT5wEJhXUu4GVUy kQoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=97TnL/zZTuZneeKyX3ZHf+5FRTGzASpgACrDLgbvpRc=; b=Pzxc51Bfe7lV4uwZCTo9tUAuln/28dM19Pr5O4v/kyy73jcaNgFR6GDkiMDBmQSu+l 6HcPK91RO3X2jy4FRPnm1ZxidxBoKA0oyuIWTV1IzAav1cLQrDgW8DF5pPKUMVlVnVLl Urcr1Vste1bOlCm7gnyO6Zr3mEXtHO+Y2tmmp2u5mrpHjo4RVi6OszBtXtswBQBUEikP Cq5kdvwZ0RRrQlSjMlZxxcsViah3Y1t4/UKq4O/t8tqtRLOq/uJ4NwV+M8sIsRtqfVqM lxf8thoswxEIO83TVGpDCv6/hgAs69YSS7dB2u8h5RCunC0ddGVmn4K9uisXSGxCMFlu 4fig== X-Gm-Message-State: AOAM530Kt35ECe6p73k9CJAGpKem+E4iz1Rrk4cELbrBmyB4CFFe8Wm9 pS7wi7+29Lx9sO3VNjJHUgjV9mtQ2AZTcraoQ1o= X-Received: by 2002:a05:600c:3586:: with SMTP id p6mr68796483wmq.34.1637060589034; Tue, 16 Nov 2021 03:03:09 -0800 (PST) Received: from localhost.localdomain (145.red-37-158-173.dynamicip.rima-tde.net. [37.158.173.145]) by smtp.gmail.com with ESMTPSA id f15sm2639779wmg.30.2021.11.16.03.03.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Nov 2021 03:03:08 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 7/9] linux-user: Remove HAVE_SAFE_SYSCALL and hostdep.h Date: Tue, 16 Nov 2021 12:02:54 +0100 Message-Id: <20211116110256.365484-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211116110256.365484-1-richard.henderson@linaro.org> References: <20211116110256.365484-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::331 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x331.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: , Cc: laurent@vivier.eu, imp@bsdimp.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" All supported hosts now define HAVE_SAFE_SYSCALL, so remove the ifdefs. This leaves hostdep.h empty, so remove it. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Warner Losh --- common-user/host/aarch64/hostdep.h | 18 ------------------ common-user/host/arm/hostdep.h | 18 ------------------ common-user/host/i386/hostdep.h | 18 ------------------ common-user/host/mips/hostdep.h | 2 -- common-user/host/ppc64/hostdep.h | 18 ------------------ common-user/host/riscv/hostdep.h | 14 -------------- common-user/host/s390x/hostdep.h | 18 ------------------ common-user/host/sparc64/hostdep.h | 2 -- common-user/host/x86_64/hostdep.h | 18 ------------------ linux-user/host/ia64/hostdep.h | 15 --------------- linux-user/host/mips/hostdep.h | 15 --------------- linux-user/host/ppc/hostdep.h | 15 --------------- linux-user/host/s390/hostdep.h | 15 --------------- linux-user/host/sparc/hostdep.h | 15 --------------- linux-user/host/sparc64/hostdep.h | 15 --------------- linux-user/host/x32/hostdep.h | 15 --------------- linux-user/safe-syscall.h | 12 ------------ linux-user/user-internals.h | 1 - linux-user/signal.c | 2 -- linux-user/safe-syscall.S | 3 --- 20 files changed, 249 deletions(-) delete mode 100644 common-user/host/aarch64/hostdep.h delete mode 100644 common-user/host/arm/hostdep.h delete mode 100644 common-user/host/i386/hostdep.h delete mode 100644 common-user/host/mips/hostdep.h delete mode 100644 common-user/host/ppc64/hostdep.h delete mode 100644 common-user/host/riscv/hostdep.h delete mode 100644 common-user/host/s390x/hostdep.h delete mode 100644 common-user/host/sparc64/hostdep.h delete mode 100644 common-user/host/x86_64/hostdep.h delete mode 100644 linux-user/host/ia64/hostdep.h delete mode 100644 linux-user/host/mips/hostdep.h delete mode 100644 linux-user/host/ppc/hostdep.h delete mode 100644 linux-user/host/s390/hostdep.h delete mode 100644 linux-user/host/sparc/hostdep.h delete mode 100644 linux-user/host/sparc64/hostdep.h delete mode 100644 linux-user/host/x32/hostdep.h diff --git a/common-user/host/aarch64/hostdep.h b/common-user/host/aarch64/hostdep.h deleted file mode 100644 index 39299d798a..0000000000 --- a/common-user/host/aarch64/hostdep.h +++ /dev/null @@ -1,18 +0,0 @@ -/* - * hostdep.h : things which are dependent on the host architecture - * - * * Written by Peter Maydell - * - * Copyright (C) 2016 Linaro Limited - * - * This work is licensed under the terms of the GNU GPL, version 2 or later. - * See the COPYING file in the top-level directory. - */ - -#ifndef AARCH64_HOSTDEP_H -#define AARCH64_HOSTDEP_H - -/* We have a safe-syscall.inc.S */ -#define HAVE_SAFE_SYSCALL - -#endif diff --git a/common-user/host/arm/hostdep.h b/common-user/host/arm/hostdep.h deleted file mode 100644 index 86b137875a..0000000000 --- a/common-user/host/arm/hostdep.h +++ /dev/null @@ -1,18 +0,0 @@ -/* - * hostdep.h : things which are dependent on the host architecture - * - * * Written by Peter Maydell - * - * Copyright (C) 2016 Linaro Limited - * - * This work is licensed under the terms of the GNU GPL, version 2 or later. - * See the COPYING file in the top-level directory. - */ - -#ifndef ARM_HOSTDEP_H -#define ARM_HOSTDEP_H - -/* We have a safe-syscall.inc.S */ -#define HAVE_SAFE_SYSCALL - -#endif diff --git a/common-user/host/i386/hostdep.h b/common-user/host/i386/hostdep.h deleted file mode 100644 index ce7136501f..0000000000 --- a/common-user/host/i386/hostdep.h +++ /dev/null @@ -1,18 +0,0 @@ -/* - * hostdep.h : things which are dependent on the host architecture - * - * * Written by Peter Maydell - * - * Copyright (C) 2016 Linaro Limited - * - * This work is licensed under the terms of the GNU GPL, version 2 or later. - * See the COPYING file in the top-level directory. - */ - -#ifndef I386_HOSTDEP_H -#define I386_HOSTDEP_H - -/* We have a safe-syscall.inc.S */ -#define HAVE_SAFE_SYSCALL - -#endif diff --git a/common-user/host/mips/hostdep.h b/common-user/host/mips/hostdep.h deleted file mode 100644 index b18aca1deb..0000000000 --- a/common-user/host/mips/hostdep.h +++ /dev/null @@ -1,2 +0,0 @@ -/* We have a safe-syscall.inc.S */ -#define HAVE_SAFE_SYSCALL diff --git a/common-user/host/ppc64/hostdep.h b/common-user/host/ppc64/hostdep.h deleted file mode 100644 index 0c290dd904..0000000000 --- a/common-user/host/ppc64/hostdep.h +++ /dev/null @@ -1,18 +0,0 @@ -/* - * hostdep.h : things which are dependent on the host architecture - * - * * Written by Peter Maydell - * - * Copyright (C) 2016 Linaro Limited - * - * This work is licensed under the terms of the GNU GPL, version 2 or later. - * See the COPYING file in the top-level directory. - */ - -#ifndef PPC64_HOSTDEP_H -#define PPC64_HOSTDEP_H - -/* We have a safe-syscall.inc.S */ -#define HAVE_SAFE_SYSCALL - -#endif diff --git a/common-user/host/riscv/hostdep.h b/common-user/host/riscv/hostdep.h deleted file mode 100644 index 7f67c22868..0000000000 --- a/common-user/host/riscv/hostdep.h +++ /dev/null @@ -1,14 +0,0 @@ -/* - * hostdep.h : things which are dependent on the host architecture - * - * This work is licensed under the terms of the GNU GPL, version 2 or later. - * See the COPYING file in the top-level directory. - */ - -#ifndef RISCV_HOSTDEP_H -#define RISCV_HOSTDEP_H - -/* We have a safe-syscall.inc.S */ -#define HAVE_SAFE_SYSCALL - -#endif diff --git a/common-user/host/s390x/hostdep.h b/common-user/host/s390x/hostdep.h deleted file mode 100644 index d801145854..0000000000 --- a/common-user/host/s390x/hostdep.h +++ /dev/null @@ -1,18 +0,0 @@ -/* - * hostdep.h : things which are dependent on the host architecture - * - * * Written by Peter Maydell - * - * Copyright (C) 2016 Linaro Limited - * - * This work is licensed under the terms of the GNU GPL, version 2 or later. - * See the COPYING file in the top-level directory. - */ - -#ifndef S390X_HOSTDEP_H -#define S390X_HOSTDEP_H - -/* We have a safe-syscall.inc.S */ -#define HAVE_SAFE_SYSCALL - -#endif diff --git a/common-user/host/sparc64/hostdep.h b/common-user/host/sparc64/hostdep.h deleted file mode 100644 index b18aca1deb..0000000000 --- a/common-user/host/sparc64/hostdep.h +++ /dev/null @@ -1,2 +0,0 @@ -/* We have a safe-syscall.inc.S */ -#define HAVE_SAFE_SYSCALL diff --git a/common-user/host/x86_64/hostdep.h b/common-user/host/x86_64/hostdep.h deleted file mode 100644 index 9c62bd26bd..0000000000 --- a/common-user/host/x86_64/hostdep.h +++ /dev/null @@ -1,18 +0,0 @@ -/* - * hostdep.h : things which are dependent on the host architecture - * - * * Written by Peter Maydell - * - * Copyright (C) 2016 Linaro Limited - * - * This work is licensed under the terms of the GNU GPL, version 2 or later. - * See the COPYING file in the top-level directory. - */ - -#ifndef X86_64_HOSTDEP_H -#define X86_64_HOSTDEP_H - -/* We have a safe-syscall.inc.S */ -#define HAVE_SAFE_SYSCALL - -#endif diff --git a/linux-user/host/ia64/hostdep.h b/linux-user/host/ia64/hostdep.h deleted file mode 100644 index 263bf7658e..0000000000 --- a/linux-user/host/ia64/hostdep.h +++ /dev/null @@ -1,15 +0,0 @@ -/* - * hostdep.h : things which are dependent on the host architecture - * - * * Written by Peter Maydell - * - * Copyright (C) 2016 Linaro Limited - * - * This work is licensed under the terms of the GNU GPL, version 2 or later. - * See the COPYING file in the top-level directory. - */ - -#ifndef IA64_HOSTDEP_H -#define IA64_HOSTDEP_H - -#endif diff --git a/linux-user/host/mips/hostdep.h b/linux-user/host/mips/hostdep.h deleted file mode 100644 index ba111d75c3..0000000000 --- a/linux-user/host/mips/hostdep.h +++ /dev/null @@ -1,15 +0,0 @@ -/* - * hostdep.h : things which are dependent on the host architecture - * - * * Written by Peter Maydell - * - * Copyright (C) 2016 Linaro Limited - * - * This work is licensed under the terms of the GNU GPL, version 2 or later. - * See the COPYING file in the top-level directory. - */ - -#ifndef MIPS_HOSTDEP_H -#define MIPS_HOSTDEP_H - -#endif diff --git a/linux-user/host/ppc/hostdep.h b/linux-user/host/ppc/hostdep.h deleted file mode 100644 index 23d8bd9d47..0000000000 --- a/linux-user/host/ppc/hostdep.h +++ /dev/null @@ -1,15 +0,0 @@ -/* - * hostdep.h : things which are dependent on the host architecture - * - * * Written by Peter Maydell - * - * Copyright (C) 2016 Linaro Limited - * - * This work is licensed under the terms of the GNU GPL, version 2 or later. - * See the COPYING file in the top-level directory. - */ - -#ifndef PPC_HOSTDEP_H -#define PPC_HOSTDEP_H - -#endif diff --git a/linux-user/host/s390/hostdep.h b/linux-user/host/s390/hostdep.h deleted file mode 100644 index afcba5a16a..0000000000 --- a/linux-user/host/s390/hostdep.h +++ /dev/null @@ -1,15 +0,0 @@ -/* - * hostdep.h : things which are dependent on the host architecture - * - * * Written by Peter Maydell - * - * Copyright (C) 2016 Linaro Limited - * - * This work is licensed under the terms of the GNU GPL, version 2 or later. - * See the COPYING file in the top-level directory. - */ - -#ifndef S390_HOSTDEP_H -#define S390_HOSTDEP_H - -#endif diff --git a/linux-user/host/sparc/hostdep.h b/linux-user/host/sparc/hostdep.h deleted file mode 100644 index 391ad923cf..0000000000 --- a/linux-user/host/sparc/hostdep.h +++ /dev/null @@ -1,15 +0,0 @@ -/* - * hostdep.h : things which are dependent on the host architecture - * - * * Written by Peter Maydell - * - * Copyright (C) 2016 Linaro Limited - * - * This work is licensed under the terms of the GNU GPL, version 2 or later. - * See the COPYING file in the top-level directory. - */ - -#ifndef SPARC_HOSTDEP_H -#define SPARC_HOSTDEP_H - -#endif diff --git a/linux-user/host/sparc64/hostdep.h b/linux-user/host/sparc64/hostdep.h deleted file mode 100644 index ce3968fca0..0000000000 --- a/linux-user/host/sparc64/hostdep.h +++ /dev/null @@ -1,15 +0,0 @@ -/* - * hostdep.h : things which are dependent on the host architecture - * - * * Written by Peter Maydell - * - * Copyright (C) 2016 Linaro Limited - * - * This work is licensed under the terms of the GNU GPL, version 2 or later. - * See the COPYING file in the top-level directory. - */ - -#ifndef SPARC64_HOSTDEP_H -#define SPARC64_HOSTDEP_H - -#endif diff --git a/linux-user/host/x32/hostdep.h b/linux-user/host/x32/hostdep.h deleted file mode 100644 index 2c2d6d37da..0000000000 --- a/linux-user/host/x32/hostdep.h +++ /dev/null @@ -1,15 +0,0 @@ -/* - * hostdep.h : things which are dependent on the host architecture - * - * * Written by Peter Maydell - * - * Copyright (C) 2016 Linaro Limited - * - * This work is licensed under the terms of the GNU GPL, version 2 or later. - * See the COPYING file in the top-level directory. - */ - -#ifndef X32_HOSTDEP_H -#define X32_HOSTDEP_H - -#endif diff --git a/linux-user/safe-syscall.h b/linux-user/safe-syscall.h index ea0e8a8d24..0deb87e51a 100644 --- a/linux-user/safe-syscall.h +++ b/linux-user/safe-syscall.h @@ -124,7 +124,6 @@ * need to check SA_RESTART flags in QEMU or distinguish the various * kinds of restartability. */ -#ifdef HAVE_SAFE_SYSCALL /* The core part of this function is implemented in assembly. */ extern long safe_syscall_base(int *pending, int *errnop, long number, ...); @@ -137,15 +136,4 @@ extern char safe_syscall_end[]; safe_syscall_base(&((TaskState *)thread_cpu->opaque)->signal_pending, \ &errno, __VA_ARGS__) -#else - -/* - * Fallback for architectures which don't yet provide a safe-syscall assembly - * fragment; note that this is racy! - * This should go away when all host architectures have been updated. - */ -#define safe_syscall syscall - -#endif - #endif diff --git a/linux-user/user-internals.h b/linux-user/user-internals.h index 661612a088..f71f372829 100644 --- a/linux-user/user-internals.h +++ b/linux-user/user-internals.h @@ -18,7 +18,6 @@ #ifndef LINUX_USER_USER_INTERNALS_H #define LINUX_USER_USER_INTERNALS_H -#include "hostdep.h" #include "exec/user/thunk.h" #include "exec/exec-all.h" #include "qemu/log.h" diff --git a/linux-user/signal.c b/linux-user/signal.c index 6d5e5b698c..ca8f24b9ec 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -798,7 +798,6 @@ int queue_signal(CPUArchState *env, int sig, int si_type, /* Adjust the signal context to rewind out of safe-syscall if we're in it */ static inline void rewind_if_in_safe_syscall(void *puc) { -#ifdef HAVE_SAFE_SYSCALL ucontext_t *uc = (ucontext_t *)puc; uintptr_t pcreg = host_signal_pc(uc); @@ -806,7 +805,6 @@ static inline void rewind_if_in_safe_syscall(void *puc) && pcreg < (uintptr_t)safe_syscall_end) { host_signal_set_pc(uc, (uintptr_t)safe_syscall_start); } -#endif } static void host_signal_handler(int host_sig, siginfo_t *info, void *puc) diff --git a/linux-user/safe-syscall.S b/linux-user/safe-syscall.S index 42ea7c40ba..7ddc997801 100644 --- a/linux-user/safe-syscall.S +++ b/linux-user/safe-syscall.S @@ -10,15 +10,12 @@ * See the COPYING file in the top-level directory. */ -#include "hostdep.h" #include "target_errno_defs.h" /* We have the correct host directory on our include path * so that this will pull in the right fragment for the architecture. */ -#ifdef HAVE_SAFE_SYSCALL #include "safe-syscall.inc.S" -#endif /* We must specifically say that we're happy for the stack to not be * executable, otherwise the toolchain will default to assuming our From patchwork Tue Nov 16 11:02:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 519197 Delivered-To: patch@linaro.org Received: by 2002:ac0:c605:0:0:0:0:0 with SMTP id p5csp6970564imj; Tue, 16 Nov 2021 03:06:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJzNxfL6E6KH+IVnfx1UYgfuMPqgXyrmdE3UJo1oNVi1GGDntJnsjf0Uq12Tn7/UbxPp0cfT X-Received: by 2002:a37:4015:: with SMTP id n21mr5371524qka.524.1637060788659; Tue, 16 Nov 2021 03:06:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637060788; cv=none; d=google.com; s=arc-20160816; b=0mKYUFRwEKv5K9qy74Xe7lNow+2ga1Px1GTE0QxIe3GXgIhaCHHwSlKeP4CWin10zL 1A9Fxk2jGtCNKm6yHQ0tLx0QsY7B//UCWWEIt43rbulGEu3aJz7pzXv9RWmau094t5zY 7DSYX1kl5P43MAOhWa5phn9P1zIOegPH3AmyeDxISGydkIovtCXVTedhGY8+byMg0oEA HzR+jv9Q8b/4E1bNl4MeCkqXvIlTodFJQYeHSWq6ihdHYfq/t6Arqq/XjHu0ZIEXvsR6 2hSGhumTq1Gsz+TJrGS8ug5CUZj+neYrbnZ/haiv+6dgG3UH5UGtQEIKHijnfnBGYwbr nemw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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=YpcjTT4P6M+JhDh0Vs6QNN1pw9wodcEf+Q7kgbhpHC8=; b=aB6bqQQJfQDwOn2iZQAm9v89FhSTvmtFxFIc6xc5nJcTc2mYNbXzyUeP0aalsFqAE4 p3UNHZGImICAssYOwVzAawv76NfujPFVUTfcxlFkBCRSz7fIJjWvUqhMswjJERz0dAJ2 gnvI/JKnwbS68U9KWYocciToPlXHYehIJBhtAsZxzyZILXpPuJnH44ukQ9PjyNvvLxuT HdJim5vNhGUYph7vXpUfQV/wyzV8pgZwN2qGcz1QPwnCISGjghJwOxuVc8S784XNphgo pi5PQ1AqO3oGOFjVUXupAE4cFj/9oKlP8InOw8T++Y5eqNzNlxjgP9k0mJDZ0h4mp0+E 9VSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=z2kbWq2k; 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=fail (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 x2si15052452qkp.44.2021.11.16.03.06.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Nov 2021 03:06:28 -0800 (PST) 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=fail header.i=@linaro.org header.s=google header.b=z2kbWq2k; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:51076 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mmwIG-0007Hn-1e for patch@linaro.org; Tue, 16 Nov 2021 06:06:28 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60050) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmwF8-0001wR-FV for qemu-devel@nongnu.org; Tue, 16 Nov 2021 06:03:15 -0500 Received: from [2a00:1450:4864:20::333] (port=56074 helo=mail-wm1-x333.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mmwF6-0004vZ-9A for qemu-devel@nongnu.org; Tue, 16 Nov 2021 06:03:14 -0500 Received: by mail-wm1-x333.google.com with SMTP id p18so7170825wmq.5 for ; Tue, 16 Nov 2021 03:03:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YpcjTT4P6M+JhDh0Vs6QNN1pw9wodcEf+Q7kgbhpHC8=; b=z2kbWq2kH8YguRruTmzFN6QLvoIAvBXEhWBf9jvrdn5T16KVBik5OamQB7j8KWBac3 U1SYa2w7udX3p386QLVLoVW6sGeFOJF7gJX2d9etwbjLP+9zwtaoCbvP6Gd0gEEHmBoH HqjKrZuZ1lfnWSmrXNGs6hhTORylBwa4MADYUvTBUKItVuC2tVWk4IsK4ZrH17W5+Qd0 8DqPlRVaeQlpuojcYcPLBMkuCXnwswkv7+SS4AlYmPjwqZiCAyT2MmSoL6znrHllRBT9 Z6xxTLE0+AWQX+JNnlZF3lIbI88qo0btkZQnwYJLu3rES95DWOawvQ2m7RaaSNkTNNfn XRLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YpcjTT4P6M+JhDh0Vs6QNN1pw9wodcEf+Q7kgbhpHC8=; b=XngFbG59wgWEgg9TZFGyBjJTyQ3IWr5v5G+nbZxifnVJjmAZtPiB2zPTSEIORZaHcy um3Qc1V7YIXIP2NJBVyE/XsFfDxKO8bimAHD97hSruUZoXo8x+c38/+8o+DGFt3Bl6qm 4b1gxRORoX0Z8J7rTwxL/LQXTtmk20ZQpuF4O6HQ24wF8gKErpsReJ/ojMoieZh5IuuF pWjS6nG1S4zhshUQ/4rcux2rvN4x/HMYJmu/zivhT+OuNqSwLLfJ4/qMMI1hTwOT9/Q2 UgG1o+nmxe4ui7Nn63AhLls9Wkm6HK1bNlp2l4ZgMKY4MweGQR/iOVCyexaq/oSTvh5a 34bA== X-Gm-Message-State: AOAM531avsOQhVx40gA+fW/3qtlO0iuSWYR2+Qo4JWlFyWCi70Xmu1Px QuQ80oS+bwiLs5l7CjmrmfL0TcscWUeQWLaLDNQ= X-Received: by 2002:a05:600c:19d0:: with SMTP id u16mr6596521wmq.111.1637060590888; Tue, 16 Nov 2021 03:03:10 -0800 (PST) Received: from localhost.localdomain (145.red-37-158-173.dynamicip.rima-tde.net. [37.158.173.145]) by smtp.gmail.com with ESMTPSA id f15sm2639779wmg.30.2021.11.16.03.03.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Nov 2021 03:03:09 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 8/9] common-user: Adjust system call return on FreeBSD Date: Tue, 16 Nov 2021 12:02:55 +0100 Message-Id: <20211116110256.365484-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211116110256.365484-1-richard.henderson@linaro.org> References: <20211116110256.365484-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::333 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x333.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: , Cc: laurent@vivier.eu, imp@bsdimp.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Warner Losh FreeBSD system calls return positive errno. On the 4 hosts for which we have support, error is indicated by the C bit set or clear. Signed-off-by: Warner Losh [rth: Rebase on new safe_syscall_base api; add #error check.] Signed-off-by: Richard Henderson --- common-user/host/aarch64/safe-syscall.inc.S | 12 +++++++++++- common-user/host/arm/safe-syscall.inc.S | 11 +++++++++++ common-user/host/i386/safe-syscall.inc.S | 10 ++++++++++ common-user/host/x86_64/safe-syscall.inc.S | 10 ++++++++++ 4 files changed, 42 insertions(+), 1 deletion(-) diff --git a/common-user/host/aarch64/safe-syscall.inc.S b/common-user/host/aarch64/safe-syscall.inc.S index 95c60d8609..d3f065cdef 100644 --- a/common-user/host/aarch64/safe-syscall.inc.S +++ b/common-user/host/aarch64/safe-syscall.inc.S @@ -65,12 +65,22 @@ safe_syscall_start: safe_syscall_end: /* code path for having successfully executed the syscall */ - cmn x0, #4095 +#if defined(__linux__) + /* Linux kernel returns (small) negative errno. */ + cmn x0, #4096 + b.hi 0f +#elif defined(__FreeBSD__) + /* FreeBSD kernel returns positive errno and C bit set. */ b.cs 1f +#else +#error "unsupported os" +#endif ret /* code path setting errno */ +#ifdef __linux__ 0: neg w0, w0 /* create positive errno */ +#endif 1: str w0, [x11] /* store errno */ mov x0, #-1 ret diff --git a/common-user/host/arm/safe-syscall.inc.S b/common-user/host/arm/safe-syscall.inc.S index 17839c6486..328299021d 100644 --- a/common-user/host/arm/safe-syscall.inc.S +++ b/common-user/host/arm/safe-syscall.inc.S @@ -82,12 +82,23 @@ safe_syscall_start: safe_syscall_end: /* code path for having successfully executed the syscall */ +#if defined(__linux__) + /* Linux kernel returns (small) negative errno. */ cmp r0, #-4096 bhi 0f +#elif defined(__FreeBSD__) + /* FreeBSD kernel returns positive errno and C bit set. */ + bcs 1f +#else +#error "unsupported os" +#endif + 9: pop { r4, r5, r6, r7, r8, r9, r10, pc } /* code path setting errno */ +#ifdef __linux__ 0: neg r0, r0 /* create positive errno */ +#endif 1: str r0, [r9] /* store errno */ mov r0, #-1 b 9b diff --git a/common-user/host/i386/safe-syscall.inc.S b/common-user/host/i386/safe-syscall.inc.S index ad89521783..a9382f777e 100644 --- a/common-user/host/i386/safe-syscall.inc.S +++ b/common-user/host/i386/safe-syscall.inc.S @@ -76,8 +76,16 @@ safe_syscall_start: safe_syscall_end: /* code path for having successfully executed the syscall */ +#if defined(__linux__) + /* Linux kernel returns (small) negative errno. */ cmp $-4095, %eax jae 0f +#elif defined(__FreeBSD__) + /* FreeBSD kernel returns positive errno and C bit set. */ + jcs 1f +#else +#error "unsupported os" +#endif 9: pop %ebx .cfi_remember_state @@ -97,7 +105,9 @@ safe_syscall_end: .cfi_restore_state /* code path setting errno */ +#ifdef __linux__ 0: neg %eax /* create positive errno */ +#endif 1: mov 8+16(%esp), %ebx /* load errno pointer */ mov %eax, (%ebx) /* store errno */ mov $-1, %eax diff --git a/common-user/host/x86_64/safe-syscall.inc.S b/common-user/host/x86_64/safe-syscall.inc.S index 9a0c4c93b4..36b7efe2ca 100644 --- a/common-user/host/x86_64/safe-syscall.inc.S +++ b/common-user/host/x86_64/safe-syscall.inc.S @@ -75,8 +75,16 @@ safe_syscall_start: safe_syscall_end: /* code path for having successfully executed the syscall */ +#if defined(__linux__) + /* Linux kernel returns (small) negative errno. */ cmp $-4095, %rax jae 0f +#elif defined(__FreeBSD__) + /* FreeBSD kernel returns positive errno and C bit set. */ + jcs 1f +#else +#error "unsupported os" +#endif 9: pop %rbp .cfi_remember_state @@ -86,7 +94,9 @@ safe_syscall_end: .cfi_restore_state /* code path setting errno */ +#ifdef __linux__ 0: neg %eax /* create positive errno */ +#endif 1: mov %eax, (%rbp) /* store errno */ mov $-1, %rax jmp 9b From patchwork Tue Nov 16 11:02:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 519200 Delivered-To: patch@linaro.org Received: by 2002:ac0:c605:0:0:0:0:0 with SMTP id p5csp6972976imj; Tue, 16 Nov 2021 03:08:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJzeOQxtau8aYa15EaSPGvk+ZnbS93cOnZBIbjsV8KSCwDEavr9l5BuHaRamR5+2ZVqVCQ05 X-Received: by 2002:a05:620a:44d4:: with SMTP id y20mr5273322qkp.25.1637060923297; Tue, 16 Nov 2021 03:08:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637060923; cv=none; d=google.com; s=arc-20160816; b=qvygu2z7gq2wfJ/LONLJTzGtdGTqkofx8vGiVBy1bU4CTmTPnz+jYBD+rfqPHr9H/k GmPkk20dK8nCnT4hDC2/o38QyDCl2CJERbnEQmGtqrFmD1/+y/FrNH8wuqxNc4gDrvV7 GUcQro3nV/RsgpwA56aAaDX/gwTq8PcbRki9B8ihdp7k24y/VG+Q5otYE6TUEi4uPDOV TMvkzLrO8cDemjL2+m6Jk6fQN29vXaoIJXL+iXsLQ6ib+x+kDtabs7y9O8VO7iN21SHp wtR8ZN9/8/5TRGRCueIPEVuz6KclivmlEidCkuDAWBs+HhIiRp9hIoxG6mGosPkzRc6L B7Wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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=5ersVyP4dai2FHOQSCztPDbnZ5yJisq87sPVkJZJ0M0=; b=Pm5p3xGEqA9FZICeApPoNR9gCY8Ut82b7+vSsW+CXhEEsLRWaLzAb1HipUnPk2Vp9b /wp5BNI7fmr2RtaONi3P3jW/oGIFk7nWOK1ozl/dRXCvZPWygbCK9cu65TaF+5rEBgeC tlTZAAwngK2V5jw/krDYh0r0D3OuoyYaIsq1k9EAHytO5GOFFJWw8yB83I6oqBoTYUml SY+WgPmoPcas52/9TEnAoDpZBXPm7uHqO0ea/z3zMMejz/HjF4zGhzfEyRb2/j2cVUG2 QAsorJLlX1PBcxgQhRj/mqc4fBRqHemKy5l6XAL0nj9c85uLGG6l1maMAStR5xqmMtFE 59lQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=J1vR8Eb6; 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=fail (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 bm4si27497724qkb.66.2021.11.16.03.08.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Nov 2021 03:08:43 -0800 (PST) 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=fail header.i=@linaro.org header.s=google header.b=J1vR8Eb6; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59470 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mmwKQ-0004Rr-NI for patch@linaro.org; Tue, 16 Nov 2021 06:08:42 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60054) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmwF9-0001xF-4W for qemu-devel@nongnu.org; Tue, 16 Nov 2021 06:03:15 -0500 Received: from [2a00:1450:4864:20::336] (port=41843 helo=mail-wm1-x336.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mmwF7-0004vl-Je for qemu-devel@nongnu.org; Tue, 16 Nov 2021 06:03:14 -0500 Received: by mail-wm1-x336.google.com with SMTP id f7-20020a1c1f07000000b0032ee11917ceso2088100wmf.0 for ; Tue, 16 Nov 2021 03:03:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5ersVyP4dai2FHOQSCztPDbnZ5yJisq87sPVkJZJ0M0=; b=J1vR8Eb6AjJQj1Z3potXlFnMnTGQQI9Eogdymx8WjOKL9SEs3qV2Gx2TJuMuFADdoU IdN0en/wjSle+U5BTvUO8wooIuNevPVjzwDHwFYmBp88lHb8LGIiWlJp1K1etQHcXVui jBRpRZTpXa4B9y9guQqm2U1VGR5ARJTHYhStpxLKTl86eGJadSy6KQeWzJcK/U9p18dk skoH9OFha1Sh5zmPiwvusLhWVqdhqcgbUZrfiT1kLvtHh1vxog7NMQz5fe6SWB2l+eHg 7jngmIB0w/2mKFKXcGwdu/PBX5suBtLXar9jjmEl8baGIjKkAQYBoqpoxj+cp09kTp6w nNzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5ersVyP4dai2FHOQSCztPDbnZ5yJisq87sPVkJZJ0M0=; b=QfKZ/lUAVupQOQ6j/H5yDq9GvWvL1mBywOZCpfA5W3k1fkmXghzxt+UJKV/RSuXWd6 W7UB8f4axY2Ref+YxxnQi5w5kb6KaHz+p2FgDBtvsDRN86WMe0+Txg+gBOAI/mrquBqP YDB/laYcW4RpP+YHtGa56+7nT5RvnO3J1mxs+pADk2MGL0QYURJR0D0Dm4DJjJhkLOQ6 n2byVcjJsuyzRCFcaALGMPXVB7l7Mz4wRRrgivGptneFszJKOwoHaoMlAhUI8FL6ZTyL ntuaZvLuNcGDTpTdoam4639yiBvPuNe6Xnn32Z1qMAGftBPN6XhEKajxnooxOkaCM05O Q7TA== X-Gm-Message-State: AOAM533zGdtVBX43zImORX3gROZuYTshJxCGGaoUeWBbcQA1EUUNZ3ow IdTD7+oOcKNeSxW/CZ82J+YyVHcIFpKoh63dv3A= X-Received: by 2002:a1c:f319:: with SMTP id q25mr6602325wmq.33.1637060592322; Tue, 16 Nov 2021 03:03:12 -0800 (PST) Received: from localhost.localdomain (145.red-37-158-173.dynamicip.rima-tde.net. [37.158.173.145]) by smtp.gmail.com with ESMTPSA id f15sm2639779wmg.30.2021.11.16.03.03.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Nov 2021 03:03:11 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 9/9] common-user: Move safe-syscall.* from *-user Date: Tue, 16 Nov 2021 12:02:56 +0100 Message-Id: <20211116110256.365484-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211116110256.365484-1-richard.henderson@linaro.org> References: <20211116110256.365484-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::336 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x336.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: , Cc: laurent@vivier.eu, imp@bsdimp.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Warner Losh Move linux-user/safe-syscall.S to common-user so that bsd-user can also use it. Also move safe-syscall.h to include/user/. Signed-off-by: Warner Losh [rth: Adjust build rules to eliminate common-save-syscall.S.] Signed-off-by: Richard Henderson --- meson.build | 8 ++++++-- {linux-user => include/user}/safe-syscall.h | 0 linux-user/signal.c | 2 +- linux-user/syscall.c | 2 +- common-user/meson.build | 2 ++ {linux-user => common-user}/safe-syscall.S | 0 linux-user/meson.build | 1 - 7 files changed, 10 insertions(+), 5 deletions(-) rename {linux-user => include/user}/safe-syscall.h (100%) create mode 100644 common-user/meson.build rename {linux-user => common-user}/safe-syscall.S (100%) diff --git a/meson.build b/meson.build index ec22cf05c1..c5b0b2b247 100644 --- a/meson.build +++ b/meson.build @@ -2359,6 +2359,7 @@ block_ss = ss.source_set() bsd_user_ss = ss.source_set() chardev_ss = ss.source_set() common_ss = ss.source_set() +common_user_ss = ss.source_set() crypto_ss = ss.source_set() hwcore_ss = ss.source_set() io_ss = ss.source_set() @@ -2605,12 +2606,15 @@ subdir('accel') subdir('plugins') subdir('bsd-user') subdir('linux-user') +subdir('common-user') subdir('ebpf') -specific_ss.add_all(when: 'CONFIG_BSD_USER', if_true: bsd_user_ss) +specific_ss.add_all(when: 'CONFIG_BSD_USER', + if_true: [bsd_user_ss, common_user_ss]) linux_user_ss.add(files('thunk.c')) -specific_ss.add_all(when: 'CONFIG_LINUX_USER', if_true: linux_user_ss) +specific_ss.add_all(when: 'CONFIG_LINUX_USER', + if_true: [linux_user_ss, common_user_ss]) # needed for fuzzing binaries subdir('tests/qtest/libqos') diff --git a/linux-user/safe-syscall.h b/include/user/safe-syscall.h similarity index 100% rename from linux-user/safe-syscall.h rename to include/user/safe-syscall.h diff --git a/linux-user/signal.c b/linux-user/signal.c index ca8f24b9ec..0744c6bf20 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -31,7 +31,7 @@ #include "trace.h" #include "signal-common.h" #include "host-signal.h" -#include "safe-syscall.h" +#include "user/safe-syscall.h" static struct target_sigaction sigact_table[TARGET_NSIG]; diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 544f5b662f..0c5f63d08c 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -132,7 +132,7 @@ #include "signal-common.h" #include "loader.h" #include "user-mmap.h" -#include "safe-syscall.h" +#include "user/safe-syscall.h" #include "qemu/guest-random.h" #include "qemu/selfmap.h" #include "user/syscall-trace.h" diff --git a/common-user/meson.build b/common-user/meson.build new file mode 100644 index 0000000000..233b69199c --- /dev/null +++ b/common-user/meson.build @@ -0,0 +1,2 @@ +# TODO: reorg the *-user headers so that this can be built once. +common_user_ss.add(when: 'CONFIG_USER_ONLY', if_true: files('safe-syscall.S')) diff --git a/linux-user/safe-syscall.S b/common-user/safe-syscall.S similarity index 100% rename from linux-user/safe-syscall.S rename to common-user/safe-syscall.S diff --git a/linux-user/meson.build b/linux-user/meson.build index bf62c13e37..af8d39aecc 100644 --- a/linux-user/meson.build +++ b/linux-user/meson.build @@ -9,7 +9,6 @@ linux_user_ss.add(files( 'linuxload.c', 'main.c', 'mmap.c', - 'safe-syscall.S', 'signal.c', 'strace.c', 'syscall.c',