From 138c9f1dec8a9bf22f322c8198668d7ac23faad1 Mon Sep 17 00:00:00 2001 From: Prakruthi Deepak Heragu Date: Thu, 10 Apr 2025 17:25:51 -0700 Subject: [PATCH] ANDROID: gunyah: qtvm: Check if VMM has provided the device-tree Operate on the device-tree config only if a device-tree has been provided by the VMM. The offsets won't make sense to RM otherwise. Bug: 410870784 Change-Id: Ia2ccd3ebe8cce5400a5ff0f023f3262a340fab08 Signed-off-by: Prakruthi Deepak Heragu --- drivers/virt/gunyah/gunyah_qtvm.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/virt/gunyah/gunyah_qtvm.c b/drivers/virt/gunyah/gunyah_qtvm.c index 5ed23ca12818..08a9e9253c07 100644 --- a/drivers/virt/gunyah/gunyah_qtvm.c +++ b/drivers/virt/gunyah/gunyah_qtvm.c @@ -78,19 +78,21 @@ static int gunyah_qtvm_pre_vm_configure(struct gunyah_vm *ghvm) ghvm->config_image.image_offset = 0; ghvm->config_image.image_size = PAS_VM_METADATA_SZ; - ghvm->config_image.dtb_offset = ghvm->dtb.config.guest_phys_addr - + if (ghvm->dtb.config.size > 0) { + ghvm->config_image.dtb_offset = ghvm->dtb.config.guest_phys_addr - gunyah_gfn_to_gpa(ghvm->config_image.parcel.start); - ghvm->config_image.dtb_size = ghvm->dtb.config.size; + ghvm->config_image.dtb_size = ghvm->dtb.config.size; - if ((ghvm->dtb.config.guest_phys_addr + ghvm->config_image.dtb_size) > - (gunyah_gfn_to_gpa(ghvm->config_image.parcel.start) + + if ((ghvm->dtb.config.guest_phys_addr + ghvm->config_image.dtb_size) > + (gunyah_gfn_to_gpa(ghvm->config_image.parcel.start) + gunyah_gfn_to_gpa(ghvm->config_image.parcel.pages))) { - /* - * DTB is out of the config image bounds. - * This is should not happen! - */ - dev_err(ghvm->parent, "DTB is outside the image parcel\n"); - return -EINVAL; + /* + * DTB is out of the config image bounds. + * This is should not happen! + */ + dev_err(ghvm->parent, "DTB is outside the image parcel\n"); + return -EINVAL; + } } /*