From nobody Tue Feb 10 06:58:25 2026 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544179656295297.29502764768426; Fri, 7 Dec 2018 02:47:36 -0800 (PST) Received: from localhost ([::1]:45307 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVDfT-00043c-6H for importer@patchew.org; Fri, 07 Dec 2018 05:47:35 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59299) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVDVP-0008Mu-3h for qemu-devel@nongnu.org; Fri, 07 Dec 2018 05:37:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gVDVN-0007xm-6V for qemu-devel@nongnu.org; Fri, 07 Dec 2018 05:37:10 -0500 Received: from mail-oi1-x22b.google.com ([2607:f8b0:4864:20::22b]:41787) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gVDVM-0007vI-V5 for qemu-devel@nongnu.org; Fri, 07 Dec 2018 05:37:09 -0500 Received: by mail-oi1-x22b.google.com with SMTP id j21so2985213oii.8 for ; Fri, 07 Dec 2018 02:37:07 -0800 (PST) Received: from cloudburst.twiddle.net (172.189-204-159.bestel.com.mx. [189.204.159.172]) by smtp.gmail.com with ESMTPSA id c19sm2037594otl.16.2018.12.07.02.37.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Dec 2018 02:37:06 -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=mluYwWpzbSidK6xqnbY4fc6xxXyLqYViTVIwxlRneVs=; b=VERZwzWNIYP3tKJNbCIpC+sVX+JmL6s2Hcu87dpx3NNjUBqYeZywF1WvAglL5zMXUf o/92TZaoM9MufJVb5JgcUsbeoKQjNJ1kc6UHzT88IOTJ5Y5o6h7sKua5T+frcMlyz/VT Li1J+iKM8sg1D7tK8KigrSGIgVFAKh5sbaQr8= 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=mluYwWpzbSidK6xqnbY4fc6xxXyLqYViTVIwxlRneVs=; b=Ba4HgaHRe7NdMZlW4+T144nijBLhTAOTJobk5SqjimqtqQsLQ6FfkB6xTuA3EpM2T6 SR7UTmgTij/kbqVkDPLGe+8bQiOmtPFDTvcRXfiC35QbMNK4jjNyq0byqtzfw8ZpxqNT QbMHOw2S5qGQM+BQTZgO5/eJUlrFlsyWWl1qfaMb02H1YJakGeo3iWYCIrI7M52u0H6a 3fp0fBc/afxLnnALhWbcGozrdNps6ISjcPuaJUTJhjG9YZstYRqLcEKXDGsP5ENhYbBg 3BmEj8C39NJu2WylUJ5g6HToLF7pb1dftsHOcq/ea7NH12guP0BKsQrfi5ThHnVzQfut eoRQ== X-Gm-Message-State: AA+aEWYtePdOTzvefGGo5tayFeQhwSI6JB2cg1gA0UrccuTuWnJGJHHk AmLW13d1x3e+9gz/b9UsLS2oB6noSw4= X-Google-Smtp-Source: AFSGD/V1vCw6PHt5biuthbZ3EDFNVLTfl6y++TtZgWwt6to2OwvsIyTkOmCEhhJcfnFr0cbzwxBi/Q== X-Received: by 2002:aca:53cd:: with SMTP id h196mr959337oib.355.1544179026640; Fri, 07 Dec 2018 02:37:06 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 7 Dec 2018 04:36:26 -0600 Message-Id: <20181207103631.28193-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181207103631.28193-1-richard.henderson@linaro.org> References: <20181207103631.28193-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::22b Subject: [Qemu-devel] [PATCH 21/26] target/arm: Implement pauth_addpac 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, ramana.radhakrishnan@arm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This is not really functional yet, because the crypto is not yet implemented. This, however follows the AddPAC pseudo function. Signed-off-by: Richard Henderson --- target/arm/helper-a64.c | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c index 2c14a71f03..28bdf6f0b2 100644 --- a/target/arm/helper-a64.c +++ b/target/arm/helper-a64.c @@ -1066,7 +1066,45 @@ static uint64_t pauth_computepac(uint64_t data, uint= 64_t modifier, static uint64_t pauth_addpac(CPUARMState *env, uint64_t ptr, uint64_t modi= fier, uint64_t *key, bool data) { - g_assert_not_reached(); /* FIXME */ + ARMMMUIdx mmu_idx =3D arm_mmu_idx(env); + ARMVAParameters param =3D aa64_va_parameters(env, ptr, mmu_idx, data); + uint64_t pac, ext_ptr, ext, test; + int bot_bit, top_bit; + + /* If tagged pointers are in use, use ptr<55>, otherwise ptr<63>. */ + if (param.tbi) { + ext =3D sextract64(ptr, 55, 1); + } else { + ext =3D sextract64(ptr, 63, 1); + } + + /* Build a pointer with known good extension bits. */ + top_bit =3D 64 - 8 * param.tbi; + bot_bit =3D 64 - param.tsz; + ext_ptr =3D deposit64(ptr, bot_bit, top_bit - bot_bit, ext); + + pac =3D pauth_computepac(ext_ptr, modifier, key[1], key[0]); + + /* Check if the ptr has good extension bits and corrupt the + * pointer authentication code if not. + */ + test =3D sextract64(ptr, bot_bit, top_bit - bot_bit); + if (test !=3D 0 && test !=3D -1) { + pac ^=3D 1ull << (top_bit - 1); + } + + /* Preserve the determination between upper and lower at bit 55, + * and insert pointer authentication code. + */ + if (param.tbi) { + ptr &=3D ~MAKE_64BIT_MASK(bot_bit, 55 - bot_bit); + pac &=3D MAKE_64BIT_MASK(bot_bit, 54 - bot_bit); + } else { + ptr &=3D MAKE_64BIT_MASK(0, bot_bit - 1); + pac &=3D ~(MAKE_64BIT_MASK(55, 1) | MAKE_64BIT_MASK(0, bot_bit - 1= )); + } + ext &=3D MAKE_64BIT_MASK(55, 1); + return pac | ext | ptr; } =20 static uint64_t pauth_original_ptr(uint64_t ptr, ARMVAParameters param) --=20 2.17.2