From patchwork Sat Aug 3 21:08:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 170512 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp2429590ile; Sat, 3 Aug 2019 14:08:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqxN+uY4ugkM/K+AvUyoRHQBLHmgNPJxd7f8Y5RjX1nY5FgsO45J2BOW2W7ZG6pQieYelksn X-Received: by 2002:a17:906:7681:: with SMTP id o1mr106502811ejm.207.1564866525993; Sat, 03 Aug 2019 14:08:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564866525; cv=none; d=google.com; s=arc-20160816; b=Zrco3bQATrCE8VUPG8ngi0vwVFAzXjg3ZsQO5FsgXtqEeNCCjtfxadQzqOPw0ezlhE g7nNffMzXgCVFmc0E3Zb7uW1REfBoZr2UsxmDsFGotqFkBye/RkmeH4+I2RkI0Pq8Cam +xTIV/piv2xwNCqafvhLhT07z6EY1qXn9GbKxDn58O6NUSQEQd3elMmm1TTuKKILzYiK AQaIhwV+gUZcrUIxMgeSVOWXSApCh+PlyEkdeVra4qv84tGMr8vfEZtO+hPUFOZFQG3u T4ZixB/g9dQzDGv1Xi40kSCfHrIS8lMqdiv4UCBAiz+WwbVtYzPa+Tc23ceQ6cWD8jjR vk6w== 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=+dg5JIkpSzmoy0afkqhKVUwUedH22oFzTp8ibzMq0SE=; b=nfRcLJvst0dqiA+Uj28v/QqNJPgZJWfdzCnc+dbbb7LUmsJ5wTD6WQvDukF4YCCWbA NThgTDffljFWmeZa8s0SLApVxkpRp8NWFo2TjoukFE5+UwtF9mu5Xs0+kQfPh/bKYMbZ dxcITvcmY2aMl8zxMyBX/7pVi1b5XBLMWY1u5CmMtyOhxIDWDGWtOn6h/P3l64LCSa3p emn4rFyhaW3doNGwyJiYT2h2j4TSNvnEgUv1pLci8FXLMfMoYADMeNlNny/dwAMN6Gvn i3sQWsgIpyg71ybYajnPVO/aGvFJKjuKj35/94+2VeJl8oBf1yrCMFYAliVaFroydM44 yOpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=qNY3Sw+X; 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 g19si27252965edb.435.2019.08.03.14.08.45 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 03 Aug 2019 14:08:45 -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=qNY3Sw+X; 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 ([::1]:41996 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hu1Gf-0001l9-0i for patch@linaro.org; Sat, 03 Aug 2019 17:08:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51981) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hu1GJ-0000zI-St for qemu-devel@nongnu.org; Sat, 03 Aug 2019 17:08:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hu1GH-0005SZ-U3 for qemu-devel@nongnu.org; Sat, 03 Aug 2019 17:08:23 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:34080) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hu1GD-0005NI-Ls for qemu-devel@nongnu.org; Sat, 03 Aug 2019 17:08:21 -0400 Received: by mail-pf1-x441.google.com with SMTP id b13so37706398pfo.1 for ; Sat, 03 Aug 2019 14:08:11 -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=+dg5JIkpSzmoy0afkqhKVUwUedH22oFzTp8ibzMq0SE=; b=qNY3Sw+XDQzjoWT4PxBw52H0kfB9SJ0QGxQmeR2rPEBDqbj14D4oTAb49uvqILtuwf WxrOCfI64/HwQNLD90HNO3IbbMw4vy9Q1t5WVSr8bmezdG4SuNpu0It8P+BcaLWHNWOV LYfFJsyMA8qzml31pvKrvohZuWzgGf4mhemtCZSC7/aqvrnJMvF6saYOXiE05GGL5UlL iloojqiMDAkHhY8VHGgVZfvtssPRdrgOWS8YllKif4xeo7fJ2PZ3Xl5HL6oLuZXIUorh O2LjuUrL1BX8y28tlurMMo0u/eQXrm8dQDBAWF+S85gtwrIp7tlIA4b6+o21k3VUdCxy F0Nw== 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=+dg5JIkpSzmoy0afkqhKVUwUedH22oFzTp8ibzMq0SE=; b=kKyCgtj7p+n6hkFk8rNoouB7l+OhLynC2IIqd9CrcigVmUWlprMBqvmIFfSs2pAJ8q Ik6cOLdE/eYqZZYHFYUKCCmRZ04X8t78qlSvj8u37nROQKDLS5GqQJSnwO5Evuy6qOpr PoAfZIV0k8T5k39lCpx9T68uaKGQB+umst4aPIisDEKZ3Kn8IYxgG1B0JxvGUmSi1qYG C3+lorZwRFoCHMEfGAbPbPFJaijJXoZiTLoGXQrcn44ixPOHXBK0+3ErGcKJoGYasmmQ vjJH4AV8qOkcH9kCj5k2HhIvaSuFsjIP0y0V6h23P3sy8QUQIgD4037r00An2LSdVj7/ XFfg== X-Gm-Message-State: APjAAAVPFGAaifF72tw4utCB09doxeCSvh/Wb3XYOM0PqvvIRxmh95Hl ribPoS3DIoeHM5WyN7w9VZgGWXFxJIE= X-Received: by 2002:a65:4c4d:: with SMTP id l13mr88114498pgr.156.1564866490564; Sat, 03 Aug 2019 14:08:10 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id x25sm110129644pfa.90.2019.08.03.14.08.09 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 03 Aug 2019 14:08:10 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 3 Aug 2019 14:08:00 -0700 Message-Id: <20190803210803.5701-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190803210803.5701-1-richard.henderson@linaro.org> References: <20190803210803.5701-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::441 Subject: [Qemu-devel] [PATCH v7 3/6] linux-user: Set PAGE_TARGET_1 for TARGET_PROT_BTI 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: peter.maydell@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.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 40b140cbba..27470b73f7 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -248,6 +248,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 0662270300..a59a81e4b6 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -1124,6 +1124,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 c1a188ec0b..c1bed290f6 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -83,6 +83,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 06ff3a7f2e..395e498acf 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -13963,10 +13963,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);