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: 714027 Delivered-To: patch@linaro.org Received: by 2002:a5d:4012:0:b0:317:ecd7:513f with SMTP id n18csp2373943wrp; Wed, 16 Aug 2023 07:29:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEAfKRAKr30nkGtECuVDciU/u08keRhwNUVrLMmhx0c3R5LUZ4J/HeIWX3SBc880RtPG80x X-Received: by 2002:a0c:b455:0:b0:647:1230:ef82 with SMTP id e21-20020a0cb455000000b006471230ef82mr1701551qvf.44.1692196178463; Wed, 16 Aug 2023 07:29:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692196178; cv=none; d=google.com; s=arc-20160816; b=TqIaKncaLMrGZQQ9uN79CYUWb+2FgFBhk+4/pYr26rc/CyRSkH1Gl+R5Bo4mbzrnWp bCOhkdRbBexUehUiDqBW1AQBlWOqt+JlEE5oeNEl1ZZl8Vll89jBc06BH+1/M4PLL/KU pb4BcD9IRUWep+/A/2Q/Tk9HXFqdMPZNFlDAAOHW5Gl3s7vc9nvj8GSq/VlQmsqOBk3+ EZrDUNx3/OgLEo0GqJRHeq+YLC6C0agh5VZqyOXkeykdU8HfMd2NeLPkcgKkBvYMe3j1 4T8ZjB+74K7nOoe4ydxV86DffTw+peS+wn+M3LppgV9Z+XzdorrP1XFIrsRQ4OZjyTyD mo7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=F7z2E+ZFTyywXfCvtaMWwFttBwfNEezUdelxUK+khHc=; fh=oweadga+1U1BKjDqlK8hSmEWEC1EUfcsKuPkDinEDsU=; b=K2Ru/VgZGyqUJkskmyji0f99cs6hiCr6HBck/PRF5CZAUZtbkxeOTI8jOHreJWnaXK ZlYEprXj6A5wyUlMXNwxF3b+sCYFnhZJN+YemifMcZEbZVkZQYT4u6ZLj40WlEsYN8gu T5Bfya2crLiMqB10206Oni1bowMSCLs7wOizvvBoDCvy4pkn4khDc5QYCIRz6voSEYr8 gRbnmGp+AJS4IC0luNX++Wo7wRhfmjkPIkPUB29g2UdwK1dmi7hL1daRFifFwOJWQjq4 0QYVs2VIBj9nfqUMhf8uRXETCTnIM/I8ufhFC9EXgXmI7L9Xvj118KSsIFdGIzgn5lHE Peqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=b7TtlpSo; 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 j8-20020a0ce008000000b00644c880072fsi6732600qvk.58.2023.08.16.07.29.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 Aug 2023 07:29:38 -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=b7TtlpSo; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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-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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.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(-)