From patchwork Sat Mar 30 00:58:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 161483 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp2808913jan; Fri, 29 Mar 2019 20:35:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqyJCFEMvwSLhbd2bY1nWYmiHn4iBqZCDTSderN+SMpQ/vyYgmdoOXPgRZ7qAg1QiwBHTAUI X-Received: by 2002:a02:3b6e:: with SMTP id i46mr25391342jaf.138.1553916912580; Fri, 29 Mar 2019 20:35:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553916912; cv=none; d=google.com; s=arc-20160816; b=rcu7O2p85+puwCROY/pf+54tOJj0HeGoQEN0PdcpjLFJRG0tHlh4gF+pzQSU2QPerJ GhJV3uDntcDQzU6ql5WlsDM6wdLagW+5uyD2iT/dC/ejX2fHPZ9CR/T6Ljnv1uxSgwym zsMSd9JHxAcACZ7uuyeEeYuWM1TlRgF0AvqPAN+BWsUp13OkFOLgfPBYFsmnbgO+MV1E Ls0qnie6L2Sipz7AU8B0k4VPgIM2bjIy6EqDGW4TtLw81pSJZEY6oarHbXpFrTRbE4tv aicNlSlOP1dHYMBJgsGgs0yZxLFT0tNPiwgYc6xGFa0UWakS/8dwLg1v2bnTNBWiJJYQ 1jDQ== 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=+BPmCxbz0CPP0QJi6QmliFS0UpMvpjSbAC3AIaHbJHo=; b=fqDpBXQc0iITFr1DmKcJ1sZoyhDESRXja35Lrjhl59910LPlenK5ire/3RIA0eOb5b fB+xbXUoBXFzh8oUVwo0/hyunowvgcInxSI7egZKho4L2H9KL8Q5lCdlVg2KRaKss4fI WcqRxC2qE/y59UspL8Ou6M9ZXVX5kc187E0Esgpa0l4FE/kSCMF9oD1jE5h0rZ4RfTVZ 3UTp7zBFdXsV1KnL2zJQMW5D3avI74zcvhFOL7UH4aLzDDulyaE9MlLJHSY2GLrMbPrI mbgauZ7m5ZXm6+LO746efmyVqARZFjtpO4CW419mL7wBRueY4c0q/jmAIDQz2yR9itmP +gaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=UbcO9oUl; 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 t24si1943969jap.64.2019.03.29.20.35.12 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 29 Mar 2019 20:35:12 -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=UbcO9oUl; 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]:49988 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hA4lz-0006zh-MC for patch@linaro.org; Fri, 29 Mar 2019 23:35:11 -0400 Received: from eggs.gnu.org ([209.51.188.92]:32973) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hA2L0-00078Q-1i for qemu-devel@nongnu.org; Fri, 29 Mar 2019 20:59:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hA2Ky-0001dR-Kc for qemu-devel@nongnu.org; Fri, 29 Mar 2019 20:59:09 -0400 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:46190) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hA2Ky-0001cl-By for qemu-devel@nongnu.org; Fri, 29 Mar 2019 20:59:08 -0400 Received: by mail-pf1-x444.google.com with SMTP id 9so1798838pfj.13 for ; Fri, 29 Mar 2019 17:59:08 -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=+BPmCxbz0CPP0QJi6QmliFS0UpMvpjSbAC3AIaHbJHo=; b=UbcO9oUle46EuG2Mr4m1za7OVs5vE9EMkaCeFufWRpL4GSwxVU7GKtaPSn8Am/MLoG cq/eVp1RwVp4jnCmDlaiZqf7r6lpwpvRwaB4EkwFoRNPZrRgZ11g+vQdE+5XEMEZlZKu Y00Wmg1fu2irDvQ8uXvlflAh9aSFmHV4UPDy1kCvpEDKWzDWNo2laaZDfCcg5DtN7iA6 ZB0mIfNHGOwlRp+hrEhuqkI9zwOuMYmIwl8ZZWWEE9CoPR4/JcOJlORVwx12g5z7fXiT nXtDNhP8dsR/lrHHWVKejJW4NdjP2PHnJ1ab5IMbePgvn/aluMKLBkD9lJOCgjJXYuMn 4RZA== 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=+BPmCxbz0CPP0QJi6QmliFS0UpMvpjSbAC3AIaHbJHo=; b=rSFEerqWmotaULVHu8V6vn/fLnrZ1VXskF4pb/TE83Xvk4XLBzzxkm3vNrRpJ/gww1 fV5aHsxBLEgP1MkJk4DlAR5NTdgLVxZ4OOHHyRimDPKf1KwGE8YTh3yAsegPFn0Kkp+R dJpEhrPybbeNqK40KvcQxUi1ihHqolYQ3F/Ib1Xtz5Qwsbj+qp2bfw2Bb8uhgvwvstId L0QDnHACKReIlTHf8nzfwCoWS4fW5N1cHX/GoSvvYNfflu8n7l20bwjJl1aSw9JHEaoy N+XsAXajzMXiy9qzOngpqHUZGg34WAZElKz5GFHAkMVad3e2FmGuphw02Vd/3Iz3r7TJ 96AQ== X-Gm-Message-State: APjAAAUz6BoGagMfEzWkYTtEmsP9rTNObg6zo377zTV7bl833YjohIRL kD66QtElLTgU0lxhih8F0REJzkF0Hjc= X-Received: by 2002:a65:4008:: with SMTP id f8mr36780976pgp.253.1553907547120; Fri, 29 Mar 2019 17:59:07 -0700 (PDT) Received: from cloudburst.ASUS (cpe-66-75-72-255.hawaii.res.rr.com. [66.75.72.255]) by smtp.gmail.com with ESMTPSA id e1sm2229900pfn.187.2019.03.29.17.59.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Mar 2019 17:59:06 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 29 Mar 2019 14:58:58 -1000 Message-Id: <20190330005900.17282-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190330005900.17282-1-richard.henderson@linaro.org> References: <20190330005900.17282-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::444 Subject: [Qemu-devel] [PATCH v4 2/4] 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, alex.bennee@linaro.org, ramana.radhakrishnan@arm.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" There is agreement that there will be a mmap/mprotect bit, although no word yet on the value or the name. Invent a name to make forward progress. The PAGE_TARGET_1 bit, is qemu internal, and allows the target something to query from the guest page tables. Signed-off-by: Richard Henderson --- include/exec/cpu-all.h | 12 +++++++++--- linux-user/syscall_defs.h | 5 +++++ linux-user/mmap.c | 13 ++++++++++++- target/arm/translate-a64.c | 6 +++--- 4 files changed, 29 insertions(+), 7 deletions(-) -- 2.17.1 diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index b16c9ec513..fb38467ed1 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -242,13 +242,19 @@ extern intptr_t qemu_host_page_mask; /* original state of the write flag (used when tracking self-modifying code */ #define PAGE_WRITE_ORG 0x0010 -/* Invalidate the TLB entry immediately, helpful for s390x - * Low-Address-Protection. Used with PAGE_WRITE in tlb_set_page_with_attrs() */ -#define PAGE_WRITE_INV 0x0040 #if defined(CONFIG_BSD) && defined(CONFIG_USER_ONLY) /* FIXME: Code that sets/uses this is broken and needs to go away. */ #define PAGE_RESERVED 0x0020 #endif +/* + * Invalidate the TLB entry immediately, helpful for s390x + * Low-Address-Protection. Used with PAGE_WRITE in tlb_set_page_with_attrs() + */ +#define PAGE_WRITE_INV 0x0040 +/* + * Some 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 12c8407144..563f752081 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -1090,6 +1090,11 @@ struct target_winsize { #define TARGET_PROT_SEM 0x08 #endif +#ifdef TARGET_AARCH64 +/* FIXME: Placeholder while waiting on the official ABI. */ +#define TARGET_PROT_BTI 0x1000 +#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 e0249efe4f..48b4d9ea02 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -362,6 +362,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot, int flags, int fd, abi_ulong offset) { abi_ulong ret, end, real_start, real_end, retaddr, host_offset, host_len; + int page_flags; mmap_lock(); #ifdef DEBUG_MMAP @@ -451,6 +452,16 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot, } } + page_flags = (prot & PAGE_BITS) | PAGE_VALID; + +#ifdef TARGET_AARCH64 + /* Remember the BTI bit for page_get_flags, but don't pass to host. */ + if (prot & TARGET_PROT_BTI) { + page_flags |= PAGE_TARGET_1; + prot &= ~TARGET_PROT_BTI; + } +#endif + if (!(flags & MAP_FIXED)) { unsigned long host_start; void *p; @@ -562,7 +573,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot, } } the_end1: - page_set_flags(start, start + len, prot | PAGE_VALID); + page_set_flags(start, start + len, page_flags); the_end: #ifdef DEBUG_MMAP printf("ret=0x" TARGET_ABI_FMT_lx "\n", start); diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index dcdeb80176..5b7bdc3926 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -14144,10 +14144,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);