From patchwork Fri Feb 1 19:54: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: 157309 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp862661jaa; Fri, 1 Feb 2019 11:57:20 -0800 (PST) X-Google-Smtp-Source: ALg8bN4E92gnv/5bO0KBd6UPBya/WBgA+cwxzml7Ki3h+FLRIL5i0eleSfVgdY1TIty7tgPB12+4 X-Received: by 2002:a25:cc0d:: with SMTP id l13mr39748347ybf.49.1549051040751; Fri, 01 Feb 2019 11:57:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549051040; cv=none; d=google.com; s=arc-20160816; b=0jETti7APS+FmGQ59rLpgmAyCc4soo47IPWaB62g+16Ubv5ZtMSho79zqo9xzTLFfC hkbENVUqr5jY+AyAkUsU+9ALoX0qP3X7G0tt8bK8RuHcB8VYHp+zRS1hkLof7oN3zJ/x KWY+oPXiIUN1IgTUyX2colTAijG1nrtRbgA5DHbkDmIlIpT1KMDJksZuSXqpV1an0Fa0 ENsH8B11tXmI2Q0/7PEw1H4ml4wmJXhg7B9a0s9W0BZSra3ePwctKqGRQGmyBqoB7b21 358QuZpjaYpw4nnNOr9xgFdlpwWk5YcchsOvCOV0b3DoxzpdpfJkW2XM7+wI1m54vSnd jgRQ== 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=oDqWWK8CZe8TYxtes0fJ8gE/IWOJVqR5kUY5OrRtyzE=; b=dvbeJOD9s2VJonSCWytZg1OimzBqjTYhnUumhieBLVT/HNREh6zdrCnDQL4BlR8UsU xEIV0HggxXCsKoMc3FiXguW9mQRx6K7h0PTMz+79Ba92mKGIDFAXtD5osqw+hHdaPhED ntr6TkfxF3sDkhRY3P66jdOehyX/h9sEsbhru5ILKIYPackc42a8bnPJHhKGjhnHoXbz Lbo3nXVen9nGdFlaDQVHOyCVw5a47Tl2MOMJeth5YJ6/rn+NnkilLmz/WhTsOy6iCP30 pDEIDhFIl6F1nGeGlJxR/5HY4h2Rbg2r/ejpcMNbCXNWBANolFS0XrHPHh+JS1CzEDgH JNMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=hiF+pZwu; 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 o3si5161093ywf.48.2019.02.01.11.57.20 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Feb 2019 11:57:20 -0800 (PST) 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=hiF+pZwu; 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]:60897 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gpewC-0001s6-AD for patch@linaro.org; Fri, 01 Feb 2019 14:57:20 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58926) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gpeto-0000tK-8B for qemu-devel@nongnu.org; Fri, 01 Feb 2019 14:54:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gpetm-00028o-7Q for qemu-devel@nongnu.org; Fri, 01 Feb 2019 14:54:52 -0500 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]:33958) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gpeth-0001pR-VC for qemu-devel@nongnu.org; Fri, 01 Feb 2019 14:54:48 -0500 Received: by mail-pl1-x643.google.com with SMTP id w4so3742425plz.1 for ; Fri, 01 Feb 2019 11:54:09 -0800 (PST) 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=oDqWWK8CZe8TYxtes0fJ8gE/IWOJVqR5kUY5OrRtyzE=; b=hiF+pZwuxr2eOh30Ex6hcY9LaOn5eGyxkzxGjdvJY64VUIXvjS4JAKlRF/H1MU0pRS EsNoIUU0U1KXzH4WzeWuQOYe8209X4W2quMCXI8cV5ckeqCiskwjFaATU4NYhSn7xpPL tB+hgSi1uOCkQ97IR+apiTI+54anDhciMxy/o= 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=oDqWWK8CZe8TYxtes0fJ8gE/IWOJVqR5kUY5OrRtyzE=; b=Jj86/VfaJpQZkLR1Qr697inh4gGF0QCMc4rMvUhXhV02yBsFoWG8xrXCHrJpiR667Y Wpnisl6GNVVwwOimA2CcRmDkE1fuEXx3DILMsZkbIxV5Pucxhrr0/9qLUPHLy2GlkGpU 6xwTr2y3c9I48OKjIp8fBIowm1iE8JnlPuanAdvt7JqNclHZCcuRcWbCANGi9s1jOWhb L0YxxFzxXMSuHh3KX3Xr56ueiifNoNPFPRTI4eQ+57meyjFEIN9HTd2f2/lJ8Q2Nr0v0 XOhRMMeeIugQZW6qPs9wf6U2lVHfYoJIlDaWTkNpWd3eaLpFY9zuOg6qILAq9Jtug3xt xJEw== X-Gm-Message-State: AJcUukcYa59kNH5jJWGfjEPLYCVG3KUsAbX3aRdkYbTpHsC/2nJmlLXI /A5up4jNKM8CHyuNbG4jDF04OmyETic= X-Received: by 2002:a17:902:4681:: with SMTP id p1mr41949633pld.184.1549050848334; Fri, 01 Feb 2019 11:54:08 -0800 (PST) Received: from cloudburst.twiddle.net (97-126-115-157.tukw.qwest.net. [97.126.115.157]) by smtp.gmail.com with ESMTPSA id j6sm17351809pfg.126.2019.02.01.11.54.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Feb 2019 11:54:07 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Feb 2019 11:54:03 -0800 Message-Id: <20190201195404.30486-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190201195404.30486-1-richard.henderson@linaro.org> References: <20190201195404.30486-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::643 Subject: [Qemu-devel] [PATCH v2 1/2] linux-user: Implement PR_PAC_RESET_KEYS 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 Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- v2: Check arg3-5 are zero. --- linux-user/aarch64/target_syscall.h | 7 ++++++ linux-user/syscall.c | 36 +++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) -- 2.17.2 diff --git a/linux-user/aarch64/target_syscall.h b/linux-user/aarch64/target_syscall.h index 937fd7989e..b595e5da82 100644 --- a/linux-user/aarch64/target_syscall.h +++ b/linux-user/aarch64/target_syscall.h @@ -22,6 +22,13 @@ struct target_pt_regs { #define TARGET_PR_SVE_SET_VL 50 #define TARGET_PR_SVE_GET_VL 51 +#define TARGET_PR_PAC_RESET_KEYS 54 +# define TARGET_PR_PAC_APIAKEY (1 << 0) +# define TARGET_PR_PAC_APIBKEY (1 << 1) +# define TARGET_PR_PAC_APDAKEY (1 << 2) +# define TARGET_PR_PAC_APDBKEY (1 << 3) +# define TARGET_PR_PAC_APGAKEY (1 << 4) + void arm_init_pauth_key(ARMPACKey *key); #endif /* AARCH64_TARGET_SYSCALL_H */ diff --git a/linux-user/syscall.c b/linux-user/syscall.c index b5786d4fc1..bf076cbf8c 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -9691,6 +9691,42 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } } return ret; + case TARGET_PR_PAC_RESET_KEYS: + { + CPUARMState *env = cpu_env; + ARMCPU *cpu = arm_env_get_cpu(env); + + if (arg3 || arg4 || arg5) { + return -TARGET_EINVAL; + } + if (cpu_isar_feature(aa64_pauth, cpu)) { + int all = (TARGET_PR_PAC_APIAKEY | TARGET_PR_PAC_APIBKEY | + TARGET_PR_PAC_APDAKEY | TARGET_PR_PAC_APDBKEY | + TARGET_PR_PAC_APGAKEY); + if (arg2 == 0) { + arg2 = all; + } else if (arg2 & ~all) { + return -TARGET_EINVAL; + } + if (arg2 & TARGET_PR_PAC_APIAKEY) { + arm_init_pauth_key(&env->apia_key); + } + if (arg2 & TARGET_PR_PAC_APIBKEY) { + arm_init_pauth_key(&env->apib_key); + } + if (arg2 & TARGET_PR_PAC_APDAKEY) { + arm_init_pauth_key(&env->apda_key); + } + if (arg2 & TARGET_PR_PAC_APDBKEY) { + arm_init_pauth_key(&env->apdb_key); + } + if (arg2 & TARGET_PR_PAC_APGAKEY) { + arm_init_pauth_key(&env->apga_key); + } + return 0; + } + } + return -TARGET_EINVAL; #endif /* AARCH64 */ case PR_GET_SECCOMP: case PR_SET_SECCOMP: From patchwork Fri Feb 1 19:54:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 157310 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp862733jaa; Fri, 1 Feb 2019 11:57:26 -0800 (PST) X-Google-Smtp-Source: ALg8bN7GpZQ1ZjfIzH+HR0ka6cVOI8os9SU4kuGmO479EbugicoQy1kPPOKAJBbKYzxhPIJZJxw7 X-Received: by 2002:a81:5404:: with SMTP id i4mr40149947ywb.364.1549051046864; Fri, 01 Feb 2019 11:57:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549051046; cv=none; d=google.com; s=arc-20160816; b=U3o6DRdBIoQZ1kdWEJFc6ivjdx2c+/y3ickChdoq24jE02jZ3fcQirbLbsiiF61dEl Kjt/XzhWB0iv951urnoZD9rqtd3rM8vCqDJZTWyIzdRTyN9trIg+9M8VoHhP+IQgRGw1 0nzpUbtn1+KRaGaVPk/dma5/XkkcX/iU/YA9gJCxkFdzfZ8HEc5G503QE9af/CKJxfQn PBdEeX61XJ5Zourp1/Q5j0zdoJwCZ9VtFyrRb16PpZvXXi7jNoIwuEku9IU7TxJcT6YG r8y8GrTq0iG11bb58S4YiIb2j5OSsaaL/ol6w6DtKsI4FArNwAABLB3vUSQEcF3CCu9M 74kA== 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 :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=M3TKKfqGt93rsoNtYGhEal1qEw2yURPi46cM7O017vk=; b=w8tOwtA9DcBEaNbb7BbA6vfCjWLy3b56/TvrFfWYsr2wnQf6F4tEVjhXxceNCj8daJ XBc1BvsZ+cKCdH2kKn8cZ2ACWyXncMd1/TKhxf0q+9EfeIy1bDC8AbbLhGX0Sowdy9Ao pf0Jc/YmoxeW3Y8TQoPw3dOZhHnn05KEHRQE7uwK9c/OGiAg0IU7pMxREVGTA7EIM9KC lTbnnEM3OZmHupFnaQNYFQud4C+0cKE52s+sv9MXWzjboNkYxepM+e63WSquM3UsLsjA 3N7N1xDTkYrh8etxi/m10cwiHqQ87D3KyfEX0OaGGYpfjfTEmXr4UKEledNjMpwcb/Fk RT1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=LAwbcOaQ; 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 x36si5603010ywj.135.2019.02.01.11.57.26 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Feb 2019 11:57:26 -0800 (PST) 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=LAwbcOaQ; 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]:60899 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gpewI-0001xM-FP for patch@linaro.org; Fri, 01 Feb 2019 14:57:26 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59033) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gpetu-0000xl-Qg for qemu-devel@nongnu.org; Fri, 01 Feb 2019 14:55:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gpets-0002CS-Jj for qemu-devel@nongnu.org; Fri, 01 Feb 2019 14:54:58 -0500 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:37093) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gpets-0001pr-5B for qemu-devel@nongnu.org; Fri, 01 Feb 2019 14:54:56 -0500 Received: by mail-pl1-x644.google.com with SMTP id b5so3736630plr.4 for ; Fri, 01 Feb 2019 11:54:11 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=M3TKKfqGt93rsoNtYGhEal1qEw2yURPi46cM7O017vk=; b=LAwbcOaQlOW/IcJ86pW9JTcy4LeFjgrug8+cG4mB3r6VbF6yNh27PF5jFK7V10+lxt efZbsPzU61sWIdPtaPUcYx9zacz7KCp9BDnjmYKk38AUiuP2MpkUGIdA5Z1c7DLnZXYe lhtr3M54OJw01KBPZurflwVyBIX909JIJ/MV0= 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:mime-version:content-transfer-encoding; bh=M3TKKfqGt93rsoNtYGhEal1qEw2yURPi46cM7O017vk=; b=COyxR25r5q3QIhFl/t12LqBxVYurWyceLUxLNGvSmr+LwPzyATampFuzXmm2mHjvlL lB9vxDaHT2KlTvO6iHE9sJI1UyCt6Bcxxkznu70wJ/UXvtskhk2dJ+OwwYbCM3nsw8Gz GMCI5MI/c0fKOyx1QSIdZcI1BCXMmYKjRaatcayviLlJ/BybgwagB7Qt86+U8BL8sWye r9Juu9Ce/HM6aVwmcF5h2Zadz0JDHHwsDKzztR3eZq+W5O1X+SRvQQSUfNGRS7NukSgd wF7irHAR+3gKZ4FYVCBdGBjpeA9TjBEevzQsosPD+Y2XSeo0MP1Mb0zTlZdUaPm+fhmi 3q7g== X-Gm-Message-State: AJcUukcDlf2vskEYhoO9+vg22tOvt0CQV2pLpC/w4Q5G8dbEjdL7RywJ gCKqCL80JHheC8P11iLqPQ4nrI9JPdE= X-Received: by 2002:a17:902:33c1:: with SMTP id b59mr40438006plc.220.1549050849959; Fri, 01 Feb 2019 11:54:09 -0800 (PST) Received: from cloudburst.twiddle.net (97-126-115-157.tukw.qwest.net. [97.126.115.157]) by smtp.gmail.com with ESMTPSA id j6sm17351809pfg.126.2019.02.01.11.54.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Feb 2019 11:54:09 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Feb 2019 11:54:04 -0800 Message-Id: <20190201195404.30486-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190201195404.30486-1-richard.henderson@linaro.org> References: <20190201195404.30486-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::644 Subject: [Qemu-devel] [PATCH v2 2/2] tests/tcg/aarch64: Add pauth smoke test 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 Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- v2: Pass all 5 arguments to prctl; remove -O1. --- tests/tcg/aarch64/pauth-1.c | 23 +++++++++++++++++++++++ tests/tcg/aarch64/Makefile.target | 6 +++++- 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 tests/tcg/aarch64/pauth-1.c -- 2.17.2 diff --git a/tests/tcg/aarch64/pauth-1.c b/tests/tcg/aarch64/pauth-1.c new file mode 100644 index 0000000000..ae6dc05c2b --- /dev/null +++ b/tests/tcg/aarch64/pauth-1.c @@ -0,0 +1,23 @@ +#include +#include + +asm(".arch armv8.4-a"); + +#ifndef PR_PAC_RESET_KEYS +#define PR_PAC_RESET_KEYS 54 +#define PR_PAC_APDAKEY (1 << 2) +#endif + +int main() +{ + int x; + void *p0 = &x, *p1, *p2; + + asm volatile("pacdza %0" : "=r"(p1) : "0"(p0)); + prctl(PR_PAC_RESET_KEYS, PR_PAC_APDAKEY, 0, 0, 0); + asm volatile("pacdza %0" : "=r"(p2) : "0"(p0)); + + assert(p1 != p0); + assert(p1 != p2); + return 0; +} diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target index 08c45b8470..2bb914975b 100644 --- a/tests/tcg/aarch64/Makefile.target +++ b/tests/tcg/aarch64/Makefile.target @@ -8,10 +8,14 @@ VPATH += $(AARCH64_SRC) # we don't build any of the ARM tests AARCH64_TESTS=$(filter-out $(ARM_TESTS), $(TESTS)) AARCH64_TESTS+=fcvt -TESTS:=$(AARCH64_TESTS) fcvt: LDFLAGS+=-lm run-fcvt: fcvt $(call run-test,$<,$(QEMU) $<, "$< on $(TARGET_NAME)") $(call diff-out,$<,$(AARCH64_SRC)/fcvt.ref) + +AARCH64_TESTS += pauth-1 +run-pauth-%: QEMU += -cpu max + +TESTS:=$(AARCH64_TESTS)