From patchwork Wed Jun 5 20:57:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 165932 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp7864768ili; Wed, 5 Jun 2019 14:09:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqw9kcDyUGvwZoiWzsqtYndA60Dx7/oahgxa3j1xylRzt/jtcIW684kCr1+b4mfTnk8qIoPp X-Received: by 2002:a37:4804:: with SMTP id v4mr36274092qka.330.1559768973594; Wed, 05 Jun 2019 14:09:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559768973; cv=none; d=google.com; s=arc-20160816; b=yMdNlaVvB15EO2ORnpx8ow06CBhievxWL9CUIZ3jYK5GXUtEkMOEG+3eMTN8epBDcQ TmmUVQKioQhg+ZqwIt4og6weZi/U/eWsHjSrnYEfmBkT4LH1YtFhv0Dhap5KdipWOWCC A+iQY2t8/0OCX/jqTcC59qEOwcUGTM3hhEV7b5dJQKZdtVEbtWg37GCDdIWaNCSyxhmp GZ3j/ZTuhyMUOx4WRp9pxXkjldA35dMtEmrud90nlmeQG4qOAwzXGjUxUJzo2cLp90x+ mDfPIcGH/HY+HqdacyejFXpgYjf3tafgoBrn+rxnEfzfCK/WEv7sl8uq9NYLU1LBtoWF rUbw== 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:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=ZCHRkKij7pQF0R23SJZo3xfE1Nbsenr9fc05DQb889w=; b=hJRUiSOXg0oS1Vypu0PQ++6gX1356Y9a/JxggSdBLXhjskjNY/H2q1AgFZ+IzM6uPt 1nrT3ij6efy/YxPMncAVWuEqfg+cHm4bbH21Yj0VTO1Zl5vsbJAsNrnWgQiiakQ5cujn lhXzQUgXHCAqn0E4ktGVnk2SM7zzLb7yGDqd6FgeaKGIvVdFoj5qWrP7uov5kxgOlWfW bv6bWdaSzirSD+WzCcxdIRD6xzaOZAKj3Z+yP/hNVEnR4PgeRwKlVCClzZK+6w8vJHZD 18+x8io80IN1Tz9Ws67JtFcv1HPz81yNHuI8GmX+DRaJiT7GX1YJxY2fBFkV0jXyzxVq XH4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=EovjxdH3; 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 t41si3783875qtt.321.2019.06.05.14.09.33 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 05 Jun 2019 14:09:33 -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=EovjxdH3; 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 ([127.0.0.1]:50086 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hYdA5-00078o-4I for patch@linaro.org; Wed, 05 Jun 2019 17:09:33 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48136) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hYcyF-0006E6-Nq for qemu-devel@nongnu.org; Wed, 05 Jun 2019 16:57:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hYcyD-0008JM-QM for qemu-devel@nongnu.org; Wed, 05 Jun 2019 16:57:19 -0400 Received: from mail-ot1-x342.google.com ([2607:f8b0:4864:20::342]:44391) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hYcyD-0008FC-GF for qemu-devel@nongnu.org; Wed, 05 Jun 2019 16:57:17 -0400 Received: by mail-ot1-x342.google.com with SMTP id b7so2050481otl.11 for ; Wed, 05 Jun 2019 13:57:17 -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; bh=ZCHRkKij7pQF0R23SJZo3xfE1Nbsenr9fc05DQb889w=; b=EovjxdH3T/hFo28fwmEY4teqysvGF3kpTosbWNfLqUUzpCL/8VbOr3ZGjDF1pTpI8B oPHN+5wO3+zDIAIxJRJsvvbX9gAgMWjpbzFADf9Lz5j9VO0UzuruG3h8PqUiUw1Zrt1f y5vuroM/lNzamL3UIV0WTJCsP1I3I3uy+wp9ctYDAGfNBw9ceHa4QzpkjTbsf5uderb6 97i3uUECZOUwXgKhu0RFjLZc6jrzMTogEwJhpyzDTujT6CbfcZi3HNljgukKMl8k4tZt IC2bgX9MZ3N5Y+mnhjF+D5pROkgOhWcOUBHAmwbcjaOjDCjP/JplwRwQ1zaLjJ7DoTCc ze2A== 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; bh=ZCHRkKij7pQF0R23SJZo3xfE1Nbsenr9fc05DQb889w=; b=LKP7UWYACCwNELBUfW+g6tZRzCOrijQTCTOoqpoBGLvZkFZN/k3kyVXqfhdSQiwMRM a3p6uwoqyrRcOxZKIBVVvyut/3yFzq4AA/+4QoLbOpp1NxxohV1/NElDbrCOaQczBJe9 rRUPrqa/tXvEvoBvkWuLttsTMjJi5jMoe2Hstv1ArxhaQ3KwouA+r6MdiuS3tfeKbt4O 6qO5keWJsiBDjThYplC8Phu0USGW5/mwxy+ksOvNPBiJ1pqwZVOvgLXMoDu80B776zQb YWIMDlZmpSxuY/r6J37PiYICSN5Nd5C8oPhdl1ElsnX2BaHLAfOF7FvpiI2nyiwI1mrf oZUQ== X-Gm-Message-State: APjAAAUUOEO6w/LBCyTVLkJsBSu5xLmgCveuoipJYHDThs+QhOPBWKQU h/DsR3F7PEAWEfDQVdU+u7Or10kAyZ5Ucg== X-Received: by 2002:a9d:7c8b:: with SMTP id q11mr4161202otn.161.1559768236302; Wed, 05 Jun 2019 13:57:16 -0700 (PDT) Received: from localhost.localdomain (200-56-192-86-cable.cybercable.net.mx. [200.56.192.86]) by smtp.gmail.com with ESMTPSA id f5sm7414155otl.51.2019.06.05.13.57.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Jun 2019 13:57:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 5 Jun 2019 15:57:03 -0500 Message-Id: <20190605205706.569-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190605205706.569-1-richard.henderson@linaro.org> References: <20190605205706.569-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::342 Subject: [Qemu-devel] [PATCH v6 3/6] linux-user: Set PAGE_TARGET_1 for TARGET_PROT_BTI X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, Dave.Martin@arm.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Transform the prot bit to a qemu internal page bit, and save it in the page tables. Signed-off-by: Richard Henderson --- include/exec/cpu-all.h | 2 ++ linux-user/syscall_defs.h | 4 ++++ linux-user/mmap.c | 16 ++++++++++++++++ target/arm/translate-a64.c | 6 +++--- 4 files changed, 25 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index da07ce311f..e65530acae 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -249,6 +249,8 @@ extern intptr_t qemu_host_page_mask; /* FIXME: Code that sets/uses this is broken and needs to go away. */ #define PAGE_RESERVED 0x0020 #endif +/* Target-specific bits that will be used via page_get_flags(). */ +#define PAGE_TARGET_1 0x0080 #if defined(CONFIG_USER_ONLY) void page_dump(FILE *f); diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 7f141f699c..9a8a14e81e 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -1097,6 +1097,10 @@ struct target_winsize { #define TARGET_PROT_SEM 0x08 #endif +#ifdef TARGET_AARCH64 +#define TARGET_PROT_BTI 0x10 +#endif + /* Common */ #define TARGET_MAP_SHARED 0x01 /* Share changes */ #define TARGET_MAP_PRIVATE 0x02 /* Changes are private */ diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 3117f57fd8..def64a41d5 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -85,6 +85,22 @@ static int validate_prot_to_pageflags(int *host_prot, int prot) */ *host_prot = prot & (PROT_READ | PROT_WRITE | PROT_EXEC); +#ifdef TARGET_AARCH64 + /* + * The PROT_BTI bit is only accepted if the cpu supports the feature. + * Since this is the unusual case, don't bother checking unless + * the bit has been requested. If set and valid, record the bit + * within QEMU's page_flags as PAGE_TARGET_1. + */ + if (prot & TARGET_PROT_BTI) { + ARMCPU *cpu = ARM_CPU(thread_cpu); + if (cpu_isar_feature(aa64_bti, cpu)) { + valid |= TARGET_PROT_BTI; + page_flags |= PAGE_TARGET_1; + } + } +#endif + return prot & ~valid ? 0 : page_flags; } diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 092f0df3c4..5043344eba 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -14115,10 +14115,10 @@ static void disas_data_proc_simd_fp(DisasContext *s, uint32_t insn) */ static bool is_guarded_page(CPUARMState *env, DisasContext *s) { -#ifdef CONFIG_USER_ONLY - return false; /* FIXME */ -#else uint64_t addr = s->base.pc_first; +#ifdef CONFIG_USER_ONLY + return page_get_flags(addr) & PAGE_TARGET_1; +#else int mmu_idx = arm_to_core_mmu_idx(s->mmu_idx); unsigned int index = tlb_index(env, mmu_idx, addr); CPUTLBEntry *entry = tlb_entry(env, mmu_idx, addr);