From patchwork Thu Dec 29 15:23:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 637566 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2985093pvb; Thu, 29 Dec 2022 07:27:08 -0800 (PST) X-Google-Smtp-Source: AMrXdXsQ93gzbETPFIFDRFHHAhFQwG4QOFUcoj2zH+JPwa6vqU6fDjtdh9zPT5wIWMnio+A9Kk18 X-Received: by 2002:a05:622a:1f99:b0:3a8:faf:296a with SMTP id cb25-20020a05622a1f9900b003a80faf296amr42714276qtb.54.1672327628773; Thu, 29 Dec 2022 07:27:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672327628; cv=none; d=google.com; s=arc-20160816; b=bJ7OKp1Oh++mnjefxvMEZ/Q9geWHNmkUZf6QKTiadec8x/sZAtk/VVwDqs9wLNKpgJ /KWKpuAujOwmqMbH6w8K8Rhk5aVz811txIw5hpoNB2MrgE+mzniLG7QbxNUrNl8+kW3Z u+I5HawYsvQySG+DtOAVBh7GelOtepquai1+hKboyUFVvwrrWwJVgnGkBgK9rHpOZaAS rKtwKkWWW3nKKZMKvSUqHPvaoN6szfRX4+NqwhyGpckzpqW1lNsUMz28qa+uhk4ch0xr CkMai477Ca0BLm4lCVSCJSYuzu7PYnn9wMGwhEkc2E1M+eOCsI3gwDrsKc2DewHssHba qayg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=aCgnhtUtjHBW/yqoLfaL4OuLziOvgUY438yt3+i+waA=; b=oGluYPStoQPHbt2ltgfVrd36VCZpJvHcZftplLZd+6OpKQFo+wTIJQj/hfNXllLbUg XXKGk44tbv7Dm+bnJqoNB2bbkCghZNV088Pg1JMVa8uVBgVvdggBF4hyEk8E4cyhM1U0 WnrX4bCEcn6G+RP+ezJJ7IbSqJHPSBO+LCjH1STKgkg6nDE6aepk++Lk2IH/cdETWpZ6 a9K3mkhfF0uPjeG8KCG5HYgQDDJBpfGeRN2M+JY1nYqs/Hs0Eqd/CbsJmgazK9dITzoY 0m/mpGy+yZ3Sbcz/PnE01o8xwWqd5+Q36UVvI0QueQPWwaBMNCd8uwL1yV9ONp4WkhIm Zl4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="miLPU/S5"; 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=pass (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 r6-20020ac85e86000000b003a53ae2db4esi7668084qtx.721.2022.12.29.07.27.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 29 Dec 2022 07:27:08 -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=pass header.i=@linaro.org header.s=google header.b="miLPU/S5"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pAulL-0001KR-D3; Thu, 29 Dec 2022 10:24:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pAulI-0001JK-Vh for qemu-devel@nongnu.org; Thu, 29 Dec 2022 10:24:05 -0500 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pAulG-0007vO-Hx for qemu-devel@nongnu.org; Thu, 29 Dec 2022 10:24:04 -0500 Received: by mail-wm1-x334.google.com with SMTP id o15so13336586wmr.4 for ; Thu, 29 Dec 2022 07:24:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=aCgnhtUtjHBW/yqoLfaL4OuLziOvgUY438yt3+i+waA=; b=miLPU/S5nvsYHRvE36PrDlhDT0rNGGSLx5NoaMCHU63dwzSX3HAAeO8pMg3ExVACBx kfNLnqyoNkcuDOOmcTMaLc46VIPpgYPurqdRQaKbBJ7dimXUFn04i0CwPZt948d9EX0f IJ7pT7CkBwQbKlImxqWI95t8veR+2NTOHtG8y2rA7jP4KNsJiAQuNAWrip+/ADjwG2ru a5UqNesTOyobcx3SyN+SwlVRa/4SHgBZJEuvv6HG+zedzRIPbnQop77AmCcw0+elYS6W DbjGK6a74KJNfgE8y+weJc04paNY11UX80LCbPwjGZhelY0S+GiD37Una+vkHEQPhRzu MnAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aCgnhtUtjHBW/yqoLfaL4OuLziOvgUY438yt3+i+waA=; b=Ojga91DQSF+fMSIGlVzGQGht9nJ4eO+M4fw7eNg3DfN6doHk9oy4CKhYrOmvwaNzd1 e+gyzCj5epLwVxtePifq62dctPnPFJM0vFKpV+C6hHDJoPoZRJzSME3W6Bz19nMTDL5c x+nZBjBkjonYMQoSAoGogD58fCI3XlBzMFtV1a5bO7Yt5dFvMIkVrT1NZm4k1NnF9oD1 VTE7zrYUQp449PbZ/aVd7e0nLkpHMt56bu6I7tGo3HRb8sqTcnGDmuzwM4qfvHbJk3uj jowmNJU8Yvo8TrIyqomSsYNSu4cR8sd8KkvtOgYWfBd8nBA0abyldRX+bYYfnxkFoLxh UXeg== X-Gm-Message-State: AFqh2koNZ3LWLxACJP4b5Kfhk/FGAdGkeJp/fdflJENdiHVPxDE4UQsG cyirVOkoTEBDCVU5R39drMY0ozGjSVbHS4zZ X-Received: by 2002:a05:600c:41d1:b0:3d2:3d7b:6118 with SMTP id t17-20020a05600c41d100b003d23d7b6118mr20309828wmh.24.1672327441621; Thu, 29 Dec 2022 07:24:01 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id f20-20020a1cc914000000b003a3170a7af9sm24426873wmb.4.2022.12.29.07.24.00 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 29 Dec 2022 07:24:01 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Steven Lee , Peter Delevoryas , Peter Delevoryas , qemu-arm@nongnu.org, Cleber Rosa , Peter Maydell , Beraldo Leal , Wainer dos Santos Moschetta , Troy Lee , Andrew Jeffery , Joel Stanley , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Delevoryas , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jamin Lin Subject: [PATCH 6/9] hw/arm/aspeed_ast10x0: Map HACE peripheral Date: Thu, 29 Dec 2022 16:23:22 +0100 Message-Id: <20221229152325.32041-7-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221229152325.32041-1-philmd@linaro.org> References: <20221229152325.32041-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=philmd@linaro.org; helo=mail-wm1-x334.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Since I don't have access to the datasheet, the relevant values were found in: https://github.com/AspeedTech-BMC/zephyr/blob/v00.01.08/dts/arm/aspeed/ast10x0.dtsi Before on Zephyr: uart:~$ crypto aes256_cbc_vault aes256_cbc vault key 1 [00:00:06.699,000] hace_global: aspeed_crypto_session_setup [00:00:06.699,000] hace_global: data->cmd: 1c2098 [00:00:06.699,000] hace_global: crypto_data_src: 93340 [00:00:06.699,000] hace_global: crypto_data_dst: 93348 [00:00:06.699,000] hace_global: crypto_ctx_base: 93300 [00:00:06.699,000] hace_global: crypto_data_len: 80000040 [00:00:06.699,000] hace_global: crypto_cmd_reg: 11c2098 [00:00:09.743,000] hace_global: HACE_STS: 0 [00:00:09.743,000] hace_global: HACE poll timeout [00:00:09.743,000] crypto: CBC mode ENCRYPT - Failed [00:00:09.743,000] hace_global: aspeed_crypto_session_free uart:~$ After: uart:~$ crypto aes256_cbc_vault aes256_cbc vault key 1 Was waiting for: 6b c1 be e2 2e 40 9f 96 e9 3d 7e 11 73 93 17 2a ae 2d 8a 57 1e 03 ac 9c 9e b7 6f ac 45 af 8e 51 30 c8 1c 46 a3 5c e4 11 e5 fb c1 19 1a 0a 52 ef f6 9f 24 45 df 4f 9b 17 ad 2b 41 7b e6 6c 37 10 But got: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [00:00:05.771,000] hace_global: aspeed_crypto_session_setup [00:00:05.772,000] hace_global: data->cmd: 1c2098 [00:00:05.772,000] hace_global: crypto_data_src: 93340 [00:00:05.772,000] hace_global: crypto_data_dst: 93348 [00:00:05.772,000] hace_global: crypto_ctx_base: 93300 [00:00:05.772,000] hace_global: crypto_data_len: 80000040 [00:00:05.772,000] hace_global: crypto_cmd_reg: 11c2098 [00:00:05.772,000] hace_global: HACE_STS: 1000 [00:00:05.772,000] crypto: Output length (encryption): 80 [00:00:05.772,000] hace_global: aspeed_crypto_session_free [00:00:05.772,000] hace_global: aspeed_crypto_session_setup [00:00:05.772,000] hace_global: data->cmd: 1c2018 [00:00:05.772,000] hace_global: crypto_data_src: 93340 [00:00:05.772,000] hace_global: crypto_data_dst: 93348 [00:00:05.772,000] hace_global: crypto_ctx_base: 93300 [00:00:05.772,000] hace_global: crypto_data_len: 80000040 [00:00:05.772,000] hace_global: crypto_cmd_reg: 11c2018 [00:00:05.772,000] hace_global: HACE_STS: 1000 [00:00:05.772,000] crypto: Output length (decryption): 64 [00:00:05.772,000] crypto: CBC mode DECRYPT - Mismatch between plaintext and decrypted cipher text [00:00:05.774,000] hace_global: aspeed_crypto_session_free uart:~$ Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Peter Delevoryas --- Should we rename HACE 'dram' as 'secram' / 'secure-ram'? --- hw/arm/aspeed_ast10x0.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/hw/arm/aspeed_ast10x0.c b/hw/arm/aspeed_ast10x0.c index 21a2e62345..02636705b6 100644 --- a/hw/arm/aspeed_ast10x0.c +++ b/hw/arm/aspeed_ast10x0.c @@ -29,6 +29,7 @@ static const hwaddr aspeed_soc_ast1030_memmap[] = { [ASPEED_DEV_SPI1] = 0x7E630000, [ASPEED_DEV_SPI2] = 0x7E640000, [ASPEED_DEV_UDC] = 0x7E6A2000, + [ASPEED_DEV_HACE] = 0x7E6D0000, [ASPEED_DEV_SCU] = 0x7E6E2000, [ASPEED_DEV_JTAG0] = 0x7E6E4000, [ASPEED_DEV_JTAG1] = 0x7E6E4100, @@ -166,6 +167,9 @@ static void aspeed_soc_ast1030_init(Object *obj) snprintf(typename, sizeof(typename), "aspeed.gpio-%s", socname); object_initialize_child(obj, "gpio", &s->gpio, typename); + snprintf(typename, sizeof(typename), "aspeed.hace-%s", socname); + object_initialize_child(obj, "hace", &s->hace, typename); + object_initialize_child(obj, "iomem", &s->iomem, TYPE_UNIMPLEMENTED_DEVICE); object_initialize_child(obj, "sbc-unimplemented", &s->sbc_unimplemented, TYPE_UNIMPLEMENTED_DEVICE); @@ -359,6 +363,17 @@ static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp) } aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->sbc), 0, sc->memmap[ASPEED_DEV_SBC]); + /* HACE */ + object_property_set_link(OBJECT(&s->hace), "dram", OBJECT(&s->secsram), + &error_abort); + if (!sysbus_realize(SYS_BUS_DEVICE(&s->hace), errp)) { + return; + } + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->hace), 0, + sc->memmap[ASPEED_DEV_HACE]); + sysbus_connect_irq(SYS_BUS_DEVICE(&s->hace), 0, + aspeed_soc_get_irq(s, ASPEED_DEV_HACE)); + /* Watch dog */ for (i = 0; i < sc->wdts_num; i++) { AspeedWDTClass *awc = ASPEED_WDT_GET_CLASS(&s->wdt[i]);