From patchwork Thu May 13 12:20:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 437321 Delivered-To: patch@linaro.org Received: by 2002:a02:c901:0:0:0:0:0 with SMTP id t1csp277535jao; Thu, 13 May 2021 05:21:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxs6fHiQO0+1toWAoPZTGyXDUSORgOuy+e4pmqOubbskON8pDilb2lH3oMiDSK4H57ajx0O X-Received: by 2002:a92:6804:: with SMTP id d4mr35505014ilc.5.1620908477322; Thu, 13 May 2021 05:21:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620908477; cv=none; d=google.com; s=arc-20160816; b=Hk4ykODLvWV/qOGhadSS1F76but2O3jckVLFzm/pLAGaakpRwCUpYyUkyIVuriRSan yBpQPEw1EQmCgY8HvZBbDjr1kKplkrPEGwZDkV+Tb4HqzxYBNO9D33DM1HgxhlGBjz50 JQXttgwg2pOMEeutAFA85MYANYa/IJADERFqmsdRKyFjZZeBbpoez7UKMrWnP4zpogHW 1eSCW43Jf9YLZULQiN+4UUfW2w/7mhh8ueeiFqQG89VDqpj2XNQ2kAjwOzNDjQ9q4cDd +qh20r41xTvcLShBrPzIsdzVx1QbI2WScLVallYQSXUm1RmrWyGt+GZjqS4Vfa1iE3n9 zjMg== 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=XBNO43ndtkHe3HspPtwZPAlVXKJsSD5gwavNah1YJ6o=; b=ZXCMK09pcdqf7pF75L4WDyhm4hU8gmPaxR1bzlhoLQXSr/1Cy6SIXLiHr+nrBv4cGS mZn2g7abcgYiBynbb+CVJHUFVaJCbGB6uQLt7S9kFrql/0yHzqMXtRvnGCDHTxveRDvd RyA4fhvhWMAfB8yUyXTu/kwAGivnGz8mDITuh8Mn21+4IoQ7vz9RHLmWIVWWU/Skivoj tX+gS0kXaMBbdztYgbsrPf2jWt0+qT7zmuElzQpSzzp06wf649wfWMuYH1mBsZr1C7hY xAlPp/gYT30/1OQf2dYVnc+nCjV1ngj/bML6VrCNWOU3qP9qaWskYZssJhMxMsbAoLMD pv+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=odounVDk; 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 d9si3741574ioh.18.2021.05.13.05.21.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 May 2021 05:21:17 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=odounVDk; 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]:59440 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lhAL6-00064q-PC for patch@linaro.org; Thu, 13 May 2021 08:21:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59586) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lhAK8-00061w-Ok for qemu-devel@nongnu.org; Thu, 13 May 2021 08:20:17 -0400 Received: from mail-qt1-x82b.google.com ([2607:f8b0:4864:20::82b]:41739) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lhAK6-0001GX-Dq for qemu-devel@nongnu.org; Thu, 13 May 2021 08:20:16 -0400 Received: by mail-qt1-x82b.google.com with SMTP id t20so15258120qtx.8 for ; Thu, 13 May 2021 05:20:13 -0700 (PDT) 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=XBNO43ndtkHe3HspPtwZPAlVXKJsSD5gwavNah1YJ6o=; b=odounVDkwM9Wwv/e7AgnKS82o6mwKSBFVzddxEYLB9dZ9q4KYU/ihykOsqxmUY1ITY nzum+FoYtYmsQE+tlPp/McYAG/SeKyiYIgRWIxEx3hX8y7iuOCM9dQjANat34ZX/MUss WCy0sp4RQI/k7ToMWi26lBhNfZbJvpLc/rYTVKmvQAMCSZzCV7KDP75zoQ8WB7jCtflW X1DMLawJXPJO1FTUI/hP1HxDts58vgaS5mmMXC9TW1jnGoflfq/9rfOT28BheHiXu+Zm GpUI4oVqI74qzxwwJQ0kvWfn7u8Exv+5iuXFNcN0BJ5GJD2Dr70vXY0vwqMPyE7kbbmh RReg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XBNO43ndtkHe3HspPtwZPAlVXKJsSD5gwavNah1YJ6o=; b=UrJbrwC1dr/XERRng016JCG6ui19fjO5MMXf1u14AvmOimZtnyn+Pggdq8k2cLUtgD tUVSWFZHbjseCARHYepZyGObwXGBsYLu1zoTka0NjIpiIFL9s9r3VQTQIOC6vnmUaKQo /o6i2ZCgDyddgqj3Bxypfrscx7I92KMY5llpl5OWCWr4TZdyAPeJXBLMBeX3zZDVeb87 p0Xj2gvVVkwaamOyJjn9Opi2zGzIp0HBnECip4cWLY4RCyCirsPnPvzFM3dz6NkCAwwC 3dTfhDMmb6PkZz+IHdZvNRDgrKxrHmi51s3h98VtdcJPNLtcalENllwNiibrFyt/enXd 7CyA== X-Gm-Message-State: AOAM533wstIS7YaqYPRWqSoUjT5ZJp8zloWaidQ+16WM0IRhtI0peTON jTZZf7/EjABggx+pa32A8Jji7US5Cuu2hEBLr+4= X-Received: by 2002:a05:622a:138c:: with SMTP id o12mr39155299qtk.190.1620908413319; Thu, 13 May 2021 05:20:13 -0700 (PDT) Received: from localhost.localdomain (163.189-204-200.bestelclientes.com.mx. [189.204.200.163]) by smtp.gmail.com with ESMTPSA id b3sm847262qtg.55.2021.05.13.05.20.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 May 2021 05:20:13 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 3/4] tcg: Use correct trap number for page faults on *BSD systems Date: Thu, 13 May 2021 07:20:07 -0500 Message-Id: <20210513122008.207491-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210513122008.207491-1-richard.henderson@linaro.org> References: <20210513122008.207491-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::82b; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x82b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, Mark Johnston , Warner Losh , Juergen Lock Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Warner Losh The trap number for a page fault on BSD systems is T_PAGEFLT not 0xe. 0xe is used by Linux and represents the intel hardware trap vector. The BSD kernels, however, translate this to T_PAGEFLT in their Xpage, Xtrap0e, Xtrap14, etc fault handlers. This is true for i386 and x86_64, though the name of the trap hanlder can very on the flavor of BSD. As far as I can tell, Linux doesn't provide a define for this value. Invent a new one (PAGE_FAULT_TRAP) and use it instead to avoid uglier ifdefs. Signed-off-by: Mark Johnston Signed-off-by: Juergen Lock [ Rework to avoid ifdefs and expand it to i386 ] Signed-off-by: Warner Losh Message-Id: <20210506173826.72832-1-imp@bsdimp.com> Signed-off-by: Richard Henderson --- accel/tcg/user-exec.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) -- 2.25.1 diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index fb2d43e6a9..d2acf6e82c 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -259,6 +259,7 @@ void *probe_access(CPUArchState *env, target_ulong addr, int size, #define TRAP_sig(context) ((context)->uc_mcontext.__gregs[_REG_TRAPNO]) #define ERROR_sig(context) ((context)->uc_mcontext.__gregs[_REG_ERR]) #define MASK_sig(context) ((context)->uc_sigmask) +#define PAGE_FAULT_TRAP T_PAGEFLT #elif defined(__FreeBSD__) || defined(__DragonFly__) #include @@ -266,16 +267,19 @@ void *probe_access(CPUArchState *env, target_ulong addr, int size, #define TRAP_sig(context) ((context)->uc_mcontext.mc_trapno) #define ERROR_sig(context) ((context)->uc_mcontext.mc_err) #define MASK_sig(context) ((context)->uc_sigmask) +#define PAGE_FAULT_TRAP T_PAGEFLT #elif defined(__OpenBSD__) #define EIP_sig(context) ((context)->sc_eip) #define TRAP_sig(context) ((context)->sc_trapno) #define ERROR_sig(context) ((context)->sc_err) #define MASK_sig(context) ((context)->sc_mask) +#define PAGE_FAULT_TRAP T_PAGEFLT #else #define EIP_sig(context) ((context)->uc_mcontext.gregs[REG_EIP]) #define TRAP_sig(context) ((context)->uc_mcontext.gregs[REG_TRAPNO]) #define ERROR_sig(context) ((context)->uc_mcontext.gregs[REG_ERR]) #define MASK_sig(context) ((context)->uc_sigmask) +#define PAGE_FAULT_TRAP 0xe #endif int cpu_signal_handler(int host_signum, void *pinfo, @@ -301,7 +305,8 @@ int cpu_signal_handler(int host_signum, void *pinfo, pc = EIP_sig(uc); trapno = TRAP_sig(uc); return handle_cpu_signal(pc, info, - trapno == 0xe ? (ERROR_sig(uc) >> 1) & 1 : 0, + trapno == PAGE_FAULT_TRAP ? + (ERROR_sig(uc) >> 1) & 1 : 0, &MASK_sig(uc)); } @@ -312,11 +317,13 @@ int cpu_signal_handler(int host_signum, void *pinfo, #define TRAP_sig(context) ((context)->uc_mcontext.__gregs[_REG_TRAPNO]) #define ERROR_sig(context) ((context)->uc_mcontext.__gregs[_REG_ERR]) #define MASK_sig(context) ((context)->uc_sigmask) +#define PAGE_FAULT_TRAP T_PAGEFLT #elif defined(__OpenBSD__) #define PC_sig(context) ((context)->sc_rip) #define TRAP_sig(context) ((context)->sc_trapno) #define ERROR_sig(context) ((context)->sc_err) #define MASK_sig(context) ((context)->sc_mask) +#define PAGE_FAULT_TRAP T_PAGEFLT #elif defined(__FreeBSD__) || defined(__DragonFly__) #include @@ -324,11 +331,13 @@ int cpu_signal_handler(int host_signum, void *pinfo, #define TRAP_sig(context) ((context)->uc_mcontext.mc_trapno) #define ERROR_sig(context) ((context)->uc_mcontext.mc_err) #define MASK_sig(context) ((context)->uc_sigmask) +#define PAGE_FAULT_TRAP T_PAGEFLT #else #define PC_sig(context) ((context)->uc_mcontext.gregs[REG_RIP]) #define TRAP_sig(context) ((context)->uc_mcontext.gregs[REG_TRAPNO]) #define ERROR_sig(context) ((context)->uc_mcontext.gregs[REG_ERR]) #define MASK_sig(context) ((context)->uc_sigmask) +#define PAGE_FAULT_TRAP 0xe #endif int cpu_signal_handler(int host_signum, void *pinfo, @@ -346,7 +355,8 @@ int cpu_signal_handler(int host_signum, void *pinfo, pc = PC_sig(uc); return handle_cpu_signal(pc, info, - TRAP_sig(uc) == 0xe ? (ERROR_sig(uc) >> 1) & 1 : 0, + TRAP_sig(uc) == PAGE_FAULT_TRAP ? + (ERROR_sig(uc) >> 1) & 1 : 0, &MASK_sig(uc)); }