Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp557425lql; Mon, 11 Mar 2024 10:13:40 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVjqjsrsZY6AnRvJ9H4FLHuSCwi7jqLixyX2ZvxWM2YHZ6ZyvokbP2Q+pkIJ1/Id5K7CG5YgyV/hOFjRacGwp/aXwN1xGbF6UrYQp7oPQ== X-Google-Smtp-Source: AGHT+IFas0SBFiZigUB/HQ7f9+6+Tu6GYM5hB6r4YTqoH89cRWzEqGcr/rOZpsRUTa8zNrCFcl/e X-Received: by 2002:a50:cdd4:0:b0:565:f7c7:f23c with SMTP id h20-20020a50cdd4000000b00565f7c7f23cmr4961023edj.3.1710177220040; Mon, 11 Mar 2024 10:13:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710177220; cv=pass; d=google.com; s=arc-20160816; b=kIkyeP/bbrk9xMWBAIcQ78hrdq6qVyG19OcPTkjRQZyNqMxwod/36p714u6M3z+YfQ iJ7pLH7V9Qk6BDcrf144BoMWS7XMPI8gK6p1noXHJECYX4CE9ro9scqcu4AUxzkG4mej wvfYklIGp46fs3QUKilu5AyPOJlxST5ZBK+rzhMNfTkK5ztV9PeXx7Xp9d5NAasijUdv pjwT7zk9dYMzfBvxzX7BtA7dvwPfuJP3HlLhb09wvZV1sqGewPGxxlpiR2/R50nw8d1y 1pN1sdSEpC9qhok41RYN6TgL/MnyUU67YIhiBAyn/M3jykgfW5OznPDVRWQCaLU0XnSX hExw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature; bh=7DHzIRWgki5+Z2bMSQr1Z/xOHasR45VMniFM9OQZ32g=; fh=wP+/4A79eedu3kBMxCEN8oJtVg2xMujkfpUpj4Wcrz8=; b=acUJTKJPn2lc+BYeS6PKAskwwjvPgZMqT1Tz79Je61wKRqc/kBowDsfMBZgrOf8ciw bHQwV9ZLNr6vVxnDkuJ06QmEeAK71Olg4hfpvxFT8omHj4Tk+HWVBAUVQjuaKSyRP7aG XQXew61a4fiqxgGPc+09ExIGY6JXhOUOhrtyhr+JHdyZKPYllL/3ZpPZFzZDdRh2l7a2 Q6lH1YMH8/y6zaEBN6i3U4BJj3VENawkod7d5CB+gyPtxojr/HMR1eNAXt9JnS8pOlIo rfxxUBV3kpsPzBEHpwRH+ueWx7Ss18U6YKi2Xp/q3sw8KI5yvONziwkSRt4IeLke6vCa wgzw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=DzbyFf+3; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-99294-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-99294-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id p7-20020a056402500700b0056856a08fd6si1220395eda.281.2024.03.11.10.13.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 10:13:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-99294-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=DzbyFf+3; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-99294-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-99294-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 9013C1F228EE for ; Mon, 11 Mar 2024 17:13:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8472148CF2; Mon, 11 Mar 2024 17:13:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="DzbyFf+3" Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 00751482CF; Mon, 11 Mar 2024 17:13:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710177210; cv=none; b=RWZUTuWZK4/s3OvmmwFPIU1cVqdJvpQViq/buVtytu33ATdrz/GTthhtS2FsRJ4GDPVWaDBfkQ+jztnhL2g3lOWZwlKw5bw+aj5E8wfpHJngufPr5kIlg3PiwB3Fl2GIjN8L0Rp9h3RxRMerRLznTSn1/IlmpRvjACwR8EUJmg4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710177210; c=relaxed/simple; bh=Lio1nhe7fciU4dYP74sWWd9SRcRxtgnQi2v2J158Cns=; h=Date:From:To:CC:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=NzYRuvHC5+K+4hB29WbnYNt9AB/BZzcwToIqE4k/2beKrGccJWVBZE31lZarO9Vke0IHkrZvnFaBYTeheGVLVL+xVt550PsfyTM1vWEwvUCOYpYPYR2MWlEoA8csOxvrT7xQsWpB+AOnqRfuzape+VmRnzWIozY6tqyJqPBsz2E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=DzbyFf+3; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 42B843Tq021082; Mon, 11 Mar 2024 17:13:06 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=qcppdkim1; bh=7DHzIRWgki5+Z2bMSQr1Z /xOHasR45VMniFM9OQZ32g=; b=DzbyFf+3sade/LZ+DwPXYUP3Wy+6HbL5wzLsa W7SWXeCh0pGkls1m1g5FcoSbg6hJV/4T5D5vzgvdEz8eURmk2K5SmlA+ljbeJQ68 lJ6IdxSktqhOngmZTjIJbt9FafBMcHMenJY88ETrlwuxS7NhfQSFn4cz0KvPgMkU 2EjBrNiQinZpTk9jAimyNNbbbcHG/dCZeOfaYGFwaw2/5BQub8Hr4ZSNAFMzGqri 3aVbK9OwofFhoQ1qg4TEbOtdIaiSW7CJpq3EKtDIY5xT+c2+JfLkiRKq0DK4TPe/ BYlPR91IHrbZquAJhetDkvZsg2kFrOoT1u6zfL0edqWOFfIrA== Received: from nasanppmta05.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3wsx48shaw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 Mar 2024 17:13:05 +0000 (GMT) Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 42BHD4Xt021914 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 Mar 2024 17:13:04 GMT Received: from hu-eberman-lv.qualcomm.com (10.49.16.6) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Mon, 11 Mar 2024 10:13:03 -0700 Date: Mon, 11 Mar 2024 10:13:03 -0700 From: Elliot Berman To: Srivatsa Vaddagiri CC: Alex Elder , Srinivas Kandagatla , Murali Nalajal , Trilok Soni , Carl van Schaik , Philip Derrin , Prakruthi Deepak Heragu , Jonathan Corbet , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Catalin Marinas , Will Deacon , Konrad Dybcio , Bjorn Andersson , Dmitry Baryshkov , "Fuad Tabba" , Sean Christopherson , "Andrew Morton" , , , , , , Subject: Re: Re: [PATCH v17 12/35] virt: gunyah: Add resource tickets Message-ID: <20240311100247856-0700.eberman@hu-eberman-lv.qualcomm.com> Mail-Followup-To: Srivatsa Vaddagiri , Alex Elder , Srinivas Kandagatla , Murali Nalajal , Trilok Soni , Carl van Schaik , Philip Derrin , Prakruthi Deepak Heragu , Jonathan Corbet , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Catalin Marinas , Will Deacon , Konrad Dybcio , Bjorn Andersson , Dmitry Baryshkov , Fuad Tabba , Sean Christopherson , Andrew Morton , linux-arm-msm@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org References: <20240222-gunyah-v17-0-1e9da6763d38@quicinc.com> <20240222-gunyah-v17-12-1e9da6763d38@quicinc.com> <20240311053806.GL440762@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20240311053806.GL440762@quicinc.com> X-ClientProxiedBy: nalasex01c.na.qualcomm.com (10.47.97.35) To nasanex01b.na.qualcomm.com (10.46.141.250) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: 11wI3OtaIF1Dwa5d3RYzieDVyHwG5GVf X-Proofpoint-ORIG-GUID: 11wI3OtaIF1Dwa5d3RYzieDVyHwG5GVf X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-11_10,2024-03-11_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1011 mlxlogscore=999 spamscore=0 impostorscore=0 adultscore=0 phishscore=0 bulkscore=0 lowpriorityscore=0 suspectscore=0 priorityscore=1501 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2402120000 definitions=main-2403110131 On Mon, Mar 11, 2024 at 11:08:06AM +0530, Srivatsa Vaddagiri wrote: > * Elliot Berman [2024-02-22 15:16:35]: > > > Gunyah doesn't process the label and that makes it > > possible for userspace to create multiple resources with the same label. > > I think that description conflicts with what is implemented in this patch? > > int gunyah_vm_add_resource_ticket(struct gunyah_vm *ghvm, > struct gunyah_vm_resource_ticket *ticket) > { > mutex_lock(&ghvm->resources_lock); > list_for_each_entry(iter, &ghvm->resource_tickets, vm_list) { > if (iter->resource_type == ticket->resource_type && > iter->label == ticket->label) { > ret = -EEXIST; > goto out; > } > } > > > // > It's a justification for the next sentence in the commit text: Resource ticket owners need to be prepared for populate to be called multiple times if userspace created multiple resources with the same label. VM manager can make sure that only one entity is going to receive the resources (the check above you highlighted), but I can't make sure that it's only going to exactly one resource. We don't currently have a scenario where we need/want multiple resources with the same label, we might have that in the future and I didn't want to add that restriction in common code. > > @@ -134,6 +246,25 @@ static int gunyah_vm_start(struct gunyah_vm *ghvm) > > } > > ghvm->vm_status = GUNYAH_RM_VM_STATUS_READY; > > > > + ret = gunyah_rm_get_hyp_resources(ghvm->rm, ghvm->vmid, &resources); > > + if (ret) { > > + dev_warn(ghvm->parent, > > + "Failed to get hypervisor resources for VM: %d\n", > > + ret); > > + goto err; > > + } > > Where do we free memory pointed by 'resources' ptr? > Ah, I meant to add the __free(kfree) annotation. I've added it. > > + > > + for (i = 0, n = le32_to_cpu(resources->n_entries); i < n; i++) { > > + ghrsc = gunyah_rm_alloc_resource(ghvm->rm, > > + &resources->entries[i]); > > + if (!ghrsc) { > > + ret = -ENOMEM; > > + goto err; > > + } > > + > > + gunyah_vm_add_resource(ghvm, ghrsc); > > + }