From patchwork Wed Aug 16 14:25:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 1821872 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=b7TtlpSo; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RQrBC4jQfz1yXY for ; Thu, 17 Aug 2023 00:29:39 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qWHSd-0003uN-Kb; Wed, 16 Aug 2023 10:25:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qWHSc-0003s9-9R for qemu-devel@nongnu.org; Wed, 16 Aug 2023 10:25:22 -0400 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qWHSZ-0003jP-Ny for qemu-devel@nongnu.org; Wed, 16 Aug 2023 10:25:22 -0400 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-68874269df4so1119092b3a.2 for ; Wed, 16 Aug 2023 07:25:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692195918; x=1692800718; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=F7z2E+ZFTyywXfCvtaMWwFttBwfNEezUdelxUK+khHc=; b=b7TtlpSo6CRe0ElvxQqvcnIofYK0y3HjOOKx07oXjrs/NbGnbHl0bhaKA48zWjmIdk zZWmWDqZ/xG85Q6uSdeynpCcX5of4JPsoWfkqCazbaG6jlZogXKPopNGEGdL3pm3kWQm 9DcfadKIaxSpSVn/u3H2APS+vnNxeV22Qctepm0qs66EaE1l4IpPkcbqkZd5zVruwjWf GT4iyygFEZoZk2cAPyT8lBw5cXBdgPyQ90JIRSmdCj0umdKNVwy/XxqXcfEoWvCzh9Wv n1bdRH4vrnLjceOfefnCWx9CCFRR2MHPtguNpRcyWn1JNWPkcfXC9aR/E+IDzA3+Qj/7 npTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692195918; x=1692800718; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=F7z2E+ZFTyywXfCvtaMWwFttBwfNEezUdelxUK+khHc=; b=RuLDWzdV4sAHVLH+eXI5aisHezHWcFzsMX8Q5cRNH/PtmCmalowMzUooWrdrIBQI5Y zyWD8GB0kr4PHuS7PGNzgNi8ylNkghjsFeOkpyoH86+CHNwpWXmr2Wu7FOhVUTKbdLW6 Ty/ILN30L4oEBO8oOQCd5vZVwaCah9P0Rv/LcZZqlHtByd0AIG6K7kYchhRGBqfszFk0 G4l90AwKY/MPcAX3Wqe57yeruhL+yM9cd+Ys9DwSJs6D4x8O08gFglYRF/EPz/HkAElK LHHPlcJ/hnAyMV4nHienFSgADUKNDwwg5l29mB5zIOxDnEaN7CXAZqPAkMaTuXKEKzrI zHPw== X-Gm-Message-State: AOJu0YydZLCPDZApK5dfGHmkrEuyq5mdQjChDUTFXau3HEGQsmoiIgI3 gAk8+x+o2alJTB43gxnj4z5URT6xn9FZgiIbxEM= X-Google-Smtp-Source: AGHT+IEVcbCmw6fm9c3gc21EEcdNKFNzd8wxApMiD3gMRmNFK06fRmz8hYL3KAFqE0BeDB8mh7LW5A== X-Received: by 2002:a05:6a00:cce:b0:682:26e4:599e with SMTP id b14-20020a056a000cce00b0068226e4599emr2158557pfv.21.1692195917832; Wed, 16 Aug 2023 07:25:17 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:a064:e3f9:a812:973b]) by smtp.gmail.com with ESMTPSA id i12-20020aa78b4c000000b00678cb337353sm11156019pfd.208.2023.08.16.07.25.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Aug 2023 07:25:17 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 0/4] tcg/aarch64: Enable BTI within the JIT Date: Wed, 16 Aug 2023 07:25:12 -0700 Message-Id: <20230816142516.469743-1-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::429; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x429.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=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Patch 1 is cherry-picked from [PATCH v3 02/14] tcg: Add tcg_out_tb_start backend hook https://lore.kernel.org/qemu-devel/20230815195741.8325-3-richard.henderson@linaro.org/T/#u here used for a different application. There are not as many landing pads as I had imagined, so the overhead here is really quite minimal. The architecture enables the check only when the PTE for the jump target is marked "guarded". Linux implements this by adding a PROT_BTI bit for mmap and mprotect. I have isolated this within a host_prot_read_exec() local function, which seems clean enough. So far, as far as I can tell, Linux it the only OS to support BTI. r~ Richard Henderson (4): tcg: Add tcg_out_tb_start backend hook util/cpuinfo-aarch64: Add CPUINFO_BTI tcg/aarch64: Emit BTI insns at jump landing pads tcg: Map code_gen_buffer with PROT_BTI host/include/aarch64/host/cpuinfo.h | 1 + tcg/region.c | 39 ++++++++++++++++------ tcg/tcg.c | 3 ++ util/cpuinfo-aarch64.c | 4 +++ tcg/aarch64/tcg-target.c.inc | 52 +++++++++++++++++++++-------- tcg/arm/tcg-target.c.inc | 5 +++ tcg/i386/tcg-target.c.inc | 5 +++ tcg/loongarch64/tcg-target.c.inc | 5 +++ tcg/mips/tcg-target.c.inc | 5 +++ tcg/ppc/tcg-target.c.inc | 5 +++ tcg/riscv/tcg-target.c.inc | 5 +++ tcg/s390x/tcg-target.c.inc | 5 +++ tcg/sparc64/tcg-target.c.inc | 5 +++ tcg/tci/tcg-target.c.inc | 5 +++ 14 files changed, 119 insertions(+), 25 deletions(-)