From patchwork Sat Sep 18 18:45:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514221 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp667547jao; Sat, 18 Sep 2021 11:51:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxCVqzhH3cBGMcesdNZhQE/OHr/EtEnna2k9gcPMhX2qdoyq41ZahZGH+qMgV7C3sg6zx8c X-Received: by 2002:a05:620a:5f7:: with SMTP id z23mr16305849qkg.449.1631991082216; Sat, 18 Sep 2021 11:51:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631991082; cv=none; d=google.com; s=arc-20160816; b=cM5xTOmagFqHqoBwNblgs8eLipAAXGHxAwZHApAloqj5vbuGHfyCIZe0A3uRgM1CLX 8v01DffwARoAk+repMBptbr8QQnY8MF3dJZRfWld3nS37FaLmvuWZS7ESTIWLWGRQqeG PTC6xVQ1c+ZyNRrowrA2WZ/WzvvcleWWE5iSVwCH6XU+4Ah/pR6m/ClxJThBM+K8OHmi hyFek7wsLNtRzz+evTBwoqXlbI+cK9kXRVMIwgzvizHSGNCqQdbUe+a7LgVvtljXb5ak tPnwoI/Rm/FxH+CknywNdKXnD6VgTAprkCdD3USMBPsdnMWBKAigPiaHPteFfzcarbHJ BVgA== 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=nrD8E65gnfBNS6+ihjsgMJcAs7qIa3jYuvmEwiwusrE=; b=DbNpU5na30KLdjX8WcvjbKsiVPSl5kLHBVCRyMxEawsCf2Pgkqxk2RJA6stsuhF68a khB5drcAENRBPWbSN+W3Qx4rA52bxn0qfAPyBabB8TOInkI+99RVxn1WLNzTq4IGWyN4 v5XUMS+LkAsnraox1E0dknSqy+rNWw33S7r38KMNqQOenz4/woNhTzlF/CGl6MVtRLrF CopJe7+OPI0E8bwxUzGoyxjSwVyryzBy44iw07gvJkTycO1wWs95TCt/BG7OKDqLgwwZ HNU/yzex0p9KyrrzY86aaH4wMk59oZ3znByS7OAKE+2/B+ItGHMpIMQh/eMDQLoQTpoc Zq8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xzQZf8q0; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ib6si1667248qvb.93.2021.09.18.11.51.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 18 Sep 2021 11:51:22 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xzQZf8q0; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:44572 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mRfQm-0002RN-My for patch@linaro.org; Sat, 18 Sep 2021 14:51:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54430) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mRfLb-0005Bb-9q for qemu-devel@nongnu.org; Sat, 18 Sep 2021 14:46:00 -0400 Received: from mail-pg1-x529.google.com ([2607:f8b0:4864:20::529]:40626) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mRfLN-0006qv-Sf for qemu-devel@nongnu.org; Sat, 18 Sep 2021 14:45:53 -0400 Received: by mail-pg1-x529.google.com with SMTP id h3so13086393pgb.7 for ; Sat, 18 Sep 2021 11:45:45 -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=nrD8E65gnfBNS6+ihjsgMJcAs7qIa3jYuvmEwiwusrE=; b=xzQZf8q0aioXJDqYBn2Hva+H5t5SIO5qSkagItq/E7Yd5xot92n0AcOwyqJapGf1NU IH9gKiFNJEiS2aZvBEKPALKxiOdofYKkQHeMNkPOt5oHdNIxLObA3lldX47h94+zdH4q FozT686IM7OUdnRbb1pptcMqlh/xBw24DMD8abpbaEAwKliTN7LJogEtJv5xSL6lwC4+ 3qO3U11h7mGx93ODo2VAAWdpYAcgOoYHY2z5qBuca1yiw5LroE8gRW2QgzALQqd3643w /od4Wz7wmME3ImSL9PvNrmrvnU5rV/3XvlPT7nuEWbZ8r45+lPtGE3B9zEdwdKLBpM7E 3+9w== 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=nrD8E65gnfBNS6+ihjsgMJcAs7qIa3jYuvmEwiwusrE=; b=BRO/gz535i2rUhfL0xxk0vjvIZTJSk5NvRp8l5GhhJ3y1lj09Ol/5ZgKcpgS66nhhZ PsFXQmcNvxWlTNX7vbW/yTJTzflnoRELefFD/C9teXAjP15utp7OqMr+wIFYj8fgwtTb QgE11sM/NdsOMtvbhTILbOcGE3fhtGPByUCTvdY917QCmY7c+5yGWZrr7BPLPQSbA3b0 wiUkPLHEOFE+xfZdZFWPz9V5p+zvQ+RG6lS/EFU+Nq7As9a6RtA24VMgduKpg5Dle6nD W2xluMw58Lk7lY8dctbRNTWWDIJipUuM1UO0uM920VOL+8Tob0h6YKRYtikB2JBfFFgl f+oA== X-Gm-Message-State: AOAM530XxHvWODhaPFurMJZ4YVs47aGZYseBvzdFx3r4Bo5dOwiku5EC WestgpapKwaGY9j1iX89ht5HFFNJ40wvZA== X-Received: by 2002:a62:194a:0:b0:43d:f06e:4f4a with SMTP id 71-20020a62194a000000b0043df06e4f4amr17025444pfz.20.1631990744594; Sat, 18 Sep 2021 11:45:44 -0700 (PDT) Received: from localhost.localdomain ([71.212.134.125]) by smtp.gmail.com with ESMTPSA id y26sm9555858pfe.69.2021.09.18.11.45.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Sep 2021 11:45:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 19/41] hw/core: Add TCGCPUOps.record_sigsegv Date: Sat, 18 Sep 2021 11:45:05 -0700 Message-Id: <20210918184527.408540-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210918184527.408540-1-richard.henderson@linaro.org> References: <20210918184527.408540-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::529; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x529.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: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Add a new user-only interface for updating cpu state before raising a signal. This will replace tlb_fill for user-only and should result in less boilerplate for each guest. Signed-off-by: Richard Henderson --- include/hw/core/tcg-cpu-ops.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) -- 2.25.1 Reviewed-by: Philippe Mathieu-Daudé diff --git a/include/hw/core/tcg-cpu-ops.h b/include/hw/core/tcg-cpu-ops.h index 4a4c4053e3..e229a40772 100644 --- a/include/hw/core/tcg-cpu-ops.h +++ b/include/hw/core/tcg-cpu-ops.h @@ -114,6 +114,32 @@ struct TCGCPUOps { */ bool (*io_recompile_replay_branch)(CPUState *cpu, const TranslationBlock *tb); +#else + /** + * record_sigsegv: + * @cpu: cpu context + * @addr: faulting guest address + * @access_type: access was read/write/execute + * @maperr: true for invalid page, false for permission fault + * @ra: host pc for unwinding + * + * We are about to raise SIGSEGV with si_code set for @maperr, + * and si_addr set for @addr. Record anything further needed + * for the signal ucontext_t. + * + * If the emulated kernel does not provide anything to the signal + * handler with anything besides the user context registers, and + * the siginfo_t, then this hook need do nothing and may be omitted. + * Otherwise, record the data and return; the caller will raise + * the signal, unwind the cpu state, and return to the main loop. + * + * If it is simpler to re-use the sysemu tlb_fill code, @ra is provided + * so that a "normal" cpu exception can be raised. In this case, + * the signal must be raised by the architecture cpu_loop. + */ + void (*record_sigsegv)(CPUState *cpu, vaddr addr, + MMUAccessType access_type, + bool maperr, uintptr_t ra); #endif /* CONFIG_SOFTMMU */ #endif /* NEED_CPU_H */