From nobody Sat Jul 25 17:34:03 2026 Received: from mail-wm1-f74.google.com (mail-wm1-f74.google.com [209.85.128.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A781944C653 for ; Wed, 15 Jul 2026 12:21:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784118116; cv=none; b=TTDzNsDI3oJ8JWKC3h5Lg0mhndG90lOdXMn0lHndB4yUyciosfATBL4HVC7zJXDQAjY1iq/P/xWBKZgtQ0q3GFkuYnYTfAqtAJT0EyQWAjBLr/O8EbVDSsd+BxfUbJvqVwhhwmVgOVPCPYXYAP5vwAJrOEx/hK9NkZhXEBh8+OI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784118116; c=relaxed/simple; bh=27+I1n8CCrlAppK7FavKpCDgL8Oz7SRSvXW4jCFhQeA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=AD4RoLWxG2HnMD/0Z3hsaKUguZ7Z5YkxYkWaseYDpgGO80ePXDfYfvPS44kX8oNOsxSifjzjy+q74cLoyYS8v+d0LDFR2bkUc9R7GOr8+Um3oc6CXqIk/iJijQl6GaU5UJq8EJEjYrkedYxZcNxf5F7Ftu/m4NusFLeR6uMNZV0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--songguo.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=efynYqp1; arc=none smtp.client-ip=209.85.128.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--songguo.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="efynYqp1" Received: by mail-wm1-f74.google.com with SMTP id 5b1f17b1804b1-493a7fa8481so4467525e9.1 for ; Wed, 15 Jul 2026 05:21:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1784118113; x=1784722913; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=RytOD9QI2NCJQSiSLFVG72euBbLNbvbdAxJ/RIBJjJg=; b=efynYqp1QRarP0yWr0uK/RlAR6obk2snf6qj+3pU+E15pqESrgXEgVQhWELf/KyNRl 9Gm3QmMykXkxcMYzFIpTg+rUQ2q8kBtyi3+WscWzvL49yUmrRNAVgwXXQWQVunEEaK3H ozIvGXFi4Wuo4LQqF/iHgXI9Dwub3r2pcNOkfP1uE6vA+ISA1kzanb7YiH7bKQItbj1O G8Gd5O6i/haCjKZmYzW7XIEhgxWFKGeqq+9vwwL4kQcui268OGQDKNCrM7nKI16SJOMu notXx3hwDmW0pjgZqrORDe3YtZtWZaXnuZzlpTV00g3xFNIEQi1LpvDNel84ZP099uAV bTZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784118113; x=1784722913; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=RytOD9QI2NCJQSiSLFVG72euBbLNbvbdAxJ/RIBJjJg=; b=Hvpq0oHSDliOMcSKCbB9ZyA77m/cALJaXqRWjGSoHPJ723ZXYSrHxbzGeY/gkgu42L 7GKp/VpZhihDDPOyNF3LrciZnVYzCJzIBperxZlhUuZTVjNRSJi15WP/k42AelLo4br0 MSvQWwIvr5enWfi6sDY7IzQAZqDJETKfVf6G3kYE20t/w+h6m30EAUEmCpphO3ZQA2Zt FZdKSXnbASOZqFJsKqAXNoCjmJR6lLD9rm10U4Gt2OpKQaXZgGR/PYi6gtxRi4vWkkL2 4GQO/+pa5/VXkaaqLn+8XdPz4o/iUXWDW+XsUGbHlqKCbrhgU2IXhzTK6SwLUVunJltN HpEQ== X-Forwarded-Encrypted: i=1; AHgh+RqsLKAvNrB4C168ZUU4lG7+hl4dJmQ+MmSaLpaFoGx/OoAAA7PqcBfm8tLpt5+p8IUgL+nIcyo5/jSwSMs=@vger.kernel.org X-Gm-Message-State: AOJu0YyQIdLMUq/2GvQwkvXJKSSM/uutokTR0uK1hgZCOpXuW8yYduWl ZQi4MXSeOeBbfsv9Wn4eRl/EHIiORzOHquS36enwtV1iiUm6UQculiXDuMg/2fNBAmmSL5YF1BG l/kzYuttn2Q== X-Received: from wmiv11.prod.google.com ([2002:a05:600c:e40b:b0:493:ab17:3e61]) (user=songguo job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600d:8444:20b0:493:e2c3:af25 with SMTP id 5b1f17b1804b1-493f88bd90emr140028105e9.12.1784118112588; Wed, 15 Jul 2026 05:21:52 -0700 (PDT) Date: Wed, 15 Jul 2026 12:21:44 +0000 In-Reply-To: <20260715122146.4069884-1-songguo@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260715122146.4069884-1-songguo@google.com> X-Mailer: git-send-email 2.55.0.141.g00534a21ce-goog Message-ID: <20260715122146.4069884-2-songguo@google.com> Subject: [PATCH v2 1/3] misc: open-dice: do not assume dev->of_node is valid From: Song Guo To: Arnd Bergmann , Greg Kroah-Hartman , linux-kernel@vger.kernel.org Cc: Song Guo Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" dev->of_node is not null only when the device is configured via device tree. When the matching device is configured by other means (like ACPI), the current code will cause null pointer dereference. Signed-off-by: Song Guo --- drivers/misc/open-dice.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/misc/open-dice.c b/drivers/misc/open-dice.c index 45060fb4ea27..094b24dfc6ea 100644 --- a/drivers/misc/open-dice.c +++ b/drivers/misc/open-dice.c @@ -118,13 +118,18 @@ static int __init open_dice_probe(struct platform_dev= ice *pdev) { static unsigned int dev_idx; struct device *dev =3D &pdev->dev; - struct reserved_mem *rmem; + struct reserved_mem *rmem =3D NULL; struct open_dice_drvdata *drvdata; int ret; =20 - rmem =3D of_reserved_mem_lookup(dev->of_node); - if (!rmem) { - dev_err(dev, "failed to lookup reserved memory\n"); + if (dev->of_node) { + rmem =3D of_reserved_mem_lookup(dev->of_node); + if (!rmem) { + dev_err(dev, "failed to lookup reserved memory\n"); + return -EINVAL; + } + } else { + dev_err(dev, "device not supported (no DT node)\n"); return -EINVAL; } =20 --=20 2.55.0.141.g00534a21ce-goog From nobody Sat Jul 25 17:34:03 2026 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 788A245BD6C for ; Wed, 15 Jul 2026 12:21:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784118118; cv=none; b=tWdJvuC65YWylrAUf5soONquJd4naMcm3BwMudZvJNESeluDESwhckWglshsulqBMp1nWdggPg56nDmICJuOIS9BQYwW7s2PXn5Hy+7ZOIwhq6V7oa0w8y2z7Zzel40uJ9+4a2l43nFnpJXJ52cAGr9Rv3sxbxaNBBhOikYdXUw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784118118; c=relaxed/simple; bh=Ot1w1WR0v9f4olihVB5r9QKPBke8SaWYsYXb6jt38OQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=UWXjvsH8E1l1m1y2J1mbeix4/HBloJiv41PAozsc8DN/J/YJFepWjWZcYZH2hBXbN56YN0H2kS3f7PCBNYcbQCoa7s6f7ck7pB7nOlVfs1n4qFWSMSCLfCB7ZrdAC+3Suc2Xkzwr6Eh1PL+i8QUGhVrJhyDK6R7W8vzEmQA0bIY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--songguo.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=QOad1ysJ; arc=none smtp.client-ip=209.85.128.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--songguo.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="QOad1ysJ" Received: by mail-wm1-f73.google.com with SMTP id 5b1f17b1804b1-4926596eebcso14662245e9.3 for ; Wed, 15 Jul 2026 05:21:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1784118115; x=1784722915; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=8iXqQJujJHX38cm3eF8JGftX3O9nEiTDSX86Mf8sVJA=; b=QOad1ysJoaRq6GeI3ntoVsuwoNoWtD+WLLzDILCyUsLdcCkT2SIsk0jn7gSc4N2OFv aiokDN8rrA2O9PbhPeZ82iwxiAtKZX+fASY9b0/MTt3oZ0JVCSXmfWOQqRz4Vc5iYJiT pR9MfGA36mvgTQiRlCVQdcuVwsQEY62jTddZZJBS7+sBOg8t9HRVVeFhihkMfVkDqr36 isUMraIyAf2lboE/3KU09SLE+33aN+/29tcILWh1xQ0SPKVVhr6loN8Pqwpv/YThumas 0R5NVrlxanKnmttOblaui1zlTeBchA04RexzMaOM7y3193iP1qFyEBCbxPAVn4cp8gsn P4rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784118115; x=1784722915; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=8iXqQJujJHX38cm3eF8JGftX3O9nEiTDSX86Mf8sVJA=; b=lGjroG0WASkhwq38qbM8RH9qh3rJ4pUYK1ddAB4z8U9Cr69lhZMhh8MYc+m8NONsq3 Lvs9NxpY2SgBCrG74m4CoXaAN+G2PoL7Q+FH74Oo2Nfbo0MzL6blMSaqbzfRq2OFMSjN aI+mZPkp6U81hbBoriMvxMRrlkfQE+bbqy1R39AXvaRs6cjnj8cxotkUnuvoM44rrGUV 6qwA3vZV+y9luOXWa3RztT1CEvwDzJrBI5aEoPEMwOhO81Ytt5io1kSoxYMe5rj5/ubL R9wJXJHz499M2Ihv2XxeqDbCTVbotP3EdsOdAoKkpbumFrmx02GgDAWdEQpIJe+9Qu70 sMWw== X-Forwarded-Encrypted: i=1; AHgh+Rr6Qk9cAeGoRC4T6I0/YvQ7o3vPI481yT5L1TJ/69CDpWEaq3AStBQol55SWzvS/kwanUubqBy+yY/BR7A=@vger.kernel.org X-Gm-Message-State: AOJu0YzNAcVT6aHBXF3Aas5Bcva5r8faZYAdHTtq3hX/oRUlIy1fL5Kx vkcaLNQ2cvSVw8qfTTzEGTUriQUw+Snwc0u78rXFGsCVMdpKk8v8KYwlX5tF8Pf8oL2RdtTtxO5 18cr1a+44aw== X-Received: from wmoj18.prod.google.com ([2002:a05:600c:4852:b0:493:f83f:e2c7]) (user=songguo job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:3acf:b0:492:3754:15f2 with SMTP id 5b1f17b1804b1-493f8829917mr172362995e9.32.1784118114580; Wed, 15 Jul 2026 05:21:54 -0700 (PDT) Date: Wed, 15 Jul 2026 12:21:45 +0000 In-Reply-To: <20260715122146.4069884-1-songguo@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260715122146.4069884-1-songguo@google.com> X-Mailer: git-send-email 2.55.0.141.g00534a21ce-goog Message-ID: <20260715122146.4069884-3-songguo@google.com> Subject: [PATCH v2 2/3] misc: open-dice: save mem_base and mem_size in drvdata From: Song Guo To: Arnd Bergmann , Greg Kroah-Hartman , linux-kernel@vger.kernel.org Cc: Song Guo Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The reserved_mem only works on device tree systems. This commit replaced it by phys_addr_t and resource_size_t to make it possible to use open dice on non-DT platforms. Signed-off-by: Song Guo --- drivers/misc/open-dice.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/drivers/misc/open-dice.c b/drivers/misc/open-dice.c index 094b24dfc6ea..aabece6ed3d1 100644 --- a/drivers/misc/open-dice.c +++ b/drivers/misc/open-dice.c @@ -31,7 +31,8 @@ struct open_dice_drvdata { struct mutex lock; char name[16]; - struct reserved_mem *rmem; + phys_addr_t mem_base; + resource_size_t mem_size; struct miscdevice misc; }; =20 @@ -45,14 +46,14 @@ static int open_dice_wipe(struct open_dice_drvdata *drv= data) void *kaddr; =20 mutex_lock(&drvdata->lock); - kaddr =3D devm_memremap(drvdata->misc.this_device, drvdata->rmem->base, - drvdata->rmem->size, MEMREMAP_WC); + kaddr =3D devm_memremap(drvdata->misc.this_device, drvdata->mem_base, + drvdata->mem_size, MEMREMAP_WC); if (IS_ERR(kaddr)) { mutex_unlock(&drvdata->lock); return PTR_ERR(kaddr); } =20 - memset(kaddr, 0, drvdata->rmem->size); + memset(kaddr, 0, drvdata->mem_size); devm_memunmap(drvdata->misc.this_device, kaddr); mutex_unlock(&drvdata->lock); return 0; @@ -64,7 +65,7 @@ static int open_dice_wipe(struct open_dice_drvdata *drvda= ta) static ssize_t open_dice_read(struct file *filp, char __user *ptr, size_t = len, loff_t *off) { - unsigned long val =3D to_open_dice_drvdata(filp)->rmem->size; + unsigned long val =3D to_open_dice_drvdata(filp)->mem_size; =20 return simple_read_from_buffer(ptr, len, off, &val, sizeof(val)); } @@ -102,8 +103,8 @@ static int open_dice_mmap_prepare(struct vm_area_desc *= desc) /* Create write-combine mapping so all clients observe a wipe. */ desc->page_prot =3D pgprot_writecombine(desc->page_prot); vma_desc_set_flags(desc, VMA_DONTCOPY_BIT, VMA_DONTDUMP_BIT); - mmap_action_simple_ioremap(desc, drvdata->rmem->base, - drvdata->rmem->size); + mmap_action_simple_ioremap(desc, drvdata->mem_base, + drvdata->mem_size); return 0; } =20 @@ -118,27 +119,31 @@ static int __init open_dice_probe(struct platform_dev= ice *pdev) { static unsigned int dev_idx; struct device *dev =3D &pdev->dev; - struct reserved_mem *rmem =3D NULL; struct open_dice_drvdata *drvdata; + phys_addr_t mem_base; + resource_size_t mem_size; int ret; =20 if (dev->of_node) { - rmem =3D of_reserved_mem_lookup(dev->of_node); + struct reserved_mem *rmem =3D of_reserved_mem_lookup(dev->of_node); + if (!rmem) { dev_err(dev, "failed to lookup reserved memory\n"); return -EINVAL; } + mem_base =3D rmem->base; + mem_size =3D rmem->size; } else { dev_err(dev, "device not supported (no DT node)\n"); return -EINVAL; } =20 - if (!rmem->size || (rmem->size > ULONG_MAX)) { + if (!mem_size || (mem_size > ULONG_MAX)) { dev_err(dev, "invalid memory region size\n"); return -EINVAL; } =20 - if (!PAGE_ALIGNED(rmem->base) || !PAGE_ALIGNED(rmem->size)) { + if (!PAGE_ALIGNED(mem_base) || !PAGE_ALIGNED(mem_size)) { dev_err(dev, "memory region must be page-aligned\n"); return -EINVAL; } @@ -148,7 +153,8 @@ static int __init open_dice_probe(struct platform_devic= e *pdev) return -ENOMEM; =20 *drvdata =3D (struct open_dice_drvdata){ - .rmem =3D rmem, + .mem_base =3D mem_base, + .mem_size =3D mem_size, .misc =3D (struct miscdevice){ .parent =3D dev, .name =3D drvdata->name, --=20 2.55.0.141.g00534a21ce-goog From nobody Sat Jul 25 17:34:03 2026 Received: from mail-wr1-f74.google.com (mail-wr1-f74.google.com [209.85.221.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A112D44C67C for ; Wed, 15 Jul 2026 12:21:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784118120; cv=none; b=V3GohcKR/6Qd42xAmaiB8GeGPetKlgIIwwZKbR2zZ/jyrmWmXf/1KdEuj61z24LEjXlaAuplyjqq7du/YkWgNtcif8m6XjMJcruUwBiTDdyRPnk4oT0Oci5wt203Wz3d0J1CSE04IRauMrehlt5SVuMBhvRYYahiRUQj+g/sd3A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784118120; c=relaxed/simple; bh=Wko7dV/qiP0IAVWrfG8FOD/GwZmeMXiWSdkNzUhgg04=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Y6GNbtuW36U6yF4MEIzhHAuFz5cFIxvWG00LyCHwq4+joO1C8L7gNlmyY5GwWdNnvJxD2Q1hmGcTH1THC0YRd9Atv2fzt3onp05DfW8VXUimrK2euV0ckqr4SCNAi2vnnoT+kU/YJW8W7sSYyFlukQhdPWFhnxYI4grCMphmdoc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--songguo.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=LIY72bJh; arc=none smtp.client-ip=209.85.221.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--songguo.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="LIY72bJh" Received: by mail-wr1-f74.google.com with SMTP id ffacd0b85a97d-4784d0fb9cfso1498058f8f.2 for ; Wed, 15 Jul 2026 05:21:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1784118117; x=1784722917; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=c6TDHAy25Sdii7kVf0v30mxZgPi6sif6xiGNODK8L4I=; b=LIY72bJhvYsEezUZRV0zllHUecoKNmJUFIGqwtxjopOSPStfm3RU7djtt3IKpMoJct 60gAL2xXqXcXZjMPMSqE9i5WK8CYUxkKRCDPAks4crPzHvLZuUcqpiKJ9gv5LOImv26E 113LvgM4xu5xAxP97VH8PmG5lXyPvjh4hKELdVA05qeXvoByiMvLvgv44Z3qaHy6YGYz oCWOdjhgWdQTO0SRNmsoQvdCdvOIZVC52qH2EeoNhktcIfmz6fpRk2xlXinIMJrQBdTk fFAa1KqeBOrWZ6RpA4S60KnuG8Q5qn85ykPimxw8eGgUJjllyFssvA4ufgNWMa1LmPMh 0eRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784118117; x=1784722917; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=c6TDHAy25Sdii7kVf0v30mxZgPi6sif6xiGNODK8L4I=; b=KGah78/I2BsLGM5D7gd5Ut02OUA/LSVrS8F3rS54aEecBU9EHmg48I6XKhVLO9Fo+2 xWgpRABlVxe9v63okvgDxoyDf2R0ZfmCQddT5+oG/z343AJviZgjB08Qy1p9HIZdh7c9 9lz8W+2fu20ipSamOl8OMYKRQqETi3FHBGkDr6zl5BG6xetshHMvNbeZyMHPeZdpJpzW VEP3kJ+H4UcMiGEVdtX9gXci5rYBqhvVWKVaSl8BFlCU6D6ydvrWDOkth4aHmDuJmkkw tc+inxzzGuhkZvKH8ZLkKCwK/42+PGn6x9K539Uq9DvWILAIzZEQeQzTVPsf4TcTS3/b HyNA== X-Forwarded-Encrypted: i=1; AHgh+RomVxUokf8AxmULLe1LifIDUXx6hGwBGDsgvpRu1486KpSDU8H4vdajku6/8rg2ONBkriuFZUXbNlnjYgA=@vger.kernel.org X-Gm-Message-State: AOJu0YyMQviXemE3cWE0kABfOFhBXPvBIzqmYg3QWeizdS6hzcfLrIak gQCJxHYMRy/+sCBthWWZhqsJPC8RSuuegj5qeIb5RAfAeEsub80x/c1D3zXfoMxClnUHG5P+Gtq lEAMkONInHQ== X-Received: from wmbeq5.prod.google.com ([2002:a05:600c:8485:b0:490:b258:4672]) (user=songguo job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:c4b7:b0:493:bd2a:93be with SMTP id 5b1f17b1804b1-493f89523d2mr175325925e9.6.1784118116472; Wed, 15 Jul 2026 05:21:56 -0700 (PDT) Date: Wed, 15 Jul 2026 12:21:46 +0000 In-Reply-To: <20260715122146.4069884-1-songguo@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260715122146.4069884-1-songguo@google.com> X-Mailer: git-send-email 2.55.0.141.g00534a21ce-goog Message-ID: <20260715122146.4069884-4-songguo@google.com> Subject: [PATCH v2 3/3] misc: open-dice: add ACPI device discovery support From: Song Guo To: Arnd Bergmann , Greg Kroah-Hartman , linux-kernel@vger.kernel.org Cc: Song Guo Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" OpenDICE can also used on x86 platforms for attestation, one of the usecase is Android's protected VM. The OpenDICE device driver only supports device tree, adding ACPI support so it can also be used on x86 environments easily. The patch is verified using crosvm, with the following ACPI table passed using --acpi-table, with --file-backed-mapping for the corresponding memory region. DefinitionBlock ( "opendice.aml", "SSDT", 2, "GOOGLE", "OpenDICE", 0x00000001 ) { Scope (\_SB) { Device (DICE) { Name (_HID, "PRP0001") Name (_DSD, Package () { ToUUID ("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), Package () { Package () { "compatible", Package () { "google,open-dice" } } } }) Name (_CRS, ResourceTemplate () { Memory32Fixed (ReadOnly, 0x9D1C3000, 0x00001000) }) } } } Signed-off-by: Song Guo --- drivers/misc/open-dice.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/misc/open-dice.c b/drivers/misc/open-dice.c index aabece6ed3d1..303b35b03cb4 100644 --- a/drivers/misc/open-dice.c +++ b/drivers/misc/open-dice.c @@ -2,6 +2,7 @@ /* * Copyright (C) 2021 - Google LLC * Author: David Brazdil + * Author: Song Guo * * Driver for Open Profile for DICE. * @@ -19,6 +20,7 @@ * close(fd); */ =20 +#include #include #include #include @@ -133,8 +135,17 @@ static int __init open_dice_probe(struct platform_devi= ce *pdev) } mem_base =3D rmem->base; mem_size =3D rmem->size; + } else if (is_acpi_node(dev->fwnode)) { + struct resource *res =3D platform_get_resource(pdev, IORESOURCE_MEM, 0); + + if (!res) { + dev_err(dev, "failed to get MMIO resource\n"); + return -EINVAL; + } + mem_base =3D res->start; + mem_size =3D resource_size(res); } else { - dev_err(dev, "device not supported (no DT node)\n"); + dev_err(dev, "device not supported (no DT or ACPI node)\n"); return -EINVAL; } =20 @@ -218,3 +229,4 @@ module_exit(open_dice_exit); MODULE_DESCRIPTION("Driver for Open Profile for DICE."); MODULE_LICENSE("GPL v2"); MODULE_AUTHOR("David Brazdil "); +MODULE_AUTHOR("Song Guo "); --=20 2.55.0.141.g00534a21ce-goog