From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0F3D7C636CC for ; Mon, 20 Feb 2023 09:55:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229729AbjBTJzP (ORCPT ); Mon, 20 Feb 2023 04:55:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229678AbjBTJzO (ORCPT ); Mon, 20 Feb 2023 04:55:14 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28C83B475; Mon, 20 Feb 2023 01:55:13 -0800 (PST) Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31K5kGWl014593; Mon, 20 Feb 2023 09:54:54 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=date : from : to : cc : subject : message-id : reply-to : references : mime-version : content-type : in-reply-to; s=qcppdkim1; bh=ybKhwuDmZUHTj/uqJj1khzGF3Icxc2G5a4I1bJt4+xE=; b=XezZBHDh2SqPH7SJ4RKr5TC662RnebwnclVGhXUUnvVJfQVUf5eW+to+ir3n+70G4xJB HVM6xCKXsAWh1Wnd5Ggnwuc3cBCLQ5NHxlGcwNpcUDKGF+K3o71+LsGfobGrXfOL6RnS mZjfQ+lOLjPBrpUyfAEHLHpuqKiyq8s8UpCTdXrj2Y0yc/TPHYef08pa4KflVw+ynoeo jBMTC1AhdIrIw0P9eUU+sMIXeysEQhUVpI6HQzT1HC7pGBys10IVI7Cbyix3lWkfc5FS W0Wrpn0/lykgXfBEavbIDxFXCgnK6cTBu78nkY2iodg8yuoApQg9QCoToTp8gDTWOQSA 9g== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3ntps1cs5r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Feb 2023 09:54:54 +0000 Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 31K9srmV007829 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Feb 2023 09:54:53 GMT Received: from quicinc.com (10.80.80.8) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Mon, 20 Feb 2023 01:54:46 -0800 Date: Mon, 20 Feb 2023 15:24:42 +0530 From: Srivatsa Vaddagiri To: Elliot Berman CC: Alex Elder , Srinivas Kandagatla , Prakruthi Deepak Heragu , Murali Nalajala , Trilok Soni , Carl van Schaik , Dmitry Baryshkov , Bjorn Andersson , Konrad Dybcio , Arnd Bergmann , Greg Kroah-Hartman , Rob Herring , "Krzysztof Kozlowski" , Jonathan Corbet , Bagas Sanjaya , Catalin Marinas , Jassi Brar , , , , , Subject: Re: [PATCH v10 13/26] gunyah: vm_mgr: Add ioctls to support basic non-proxy VM boot Message-ID: <20230220095442.GA787573@quicinc.com> Reply-To: Srivatsa Vaddagiri References: <20230214211229.3239350-1-quic_eberman@quicinc.com> <20230214212427.3316544-1-quic_eberman@quicinc.com> <20230220091544.GN332@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Disposition: inline In-Reply-To: <20230220091544.GN332@quicinc.com> X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: nIAT3YKYaTsYJ007_yxNIrl1-W2BHIgb X-Proofpoint-ORIG-GUID: nIAT3YKYaTsYJ007_yxNIrl1-W2BHIgb X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-20_07,2023-02-17_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 clxscore=1015 lowpriorityscore=0 suspectscore=0 priorityscore=1501 malwarescore=0 adultscore=0 impostorscore=0 phishscore=0 spamscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302200088 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org * Srivatsa Vaddagiri [2023-02-20 14:45:55]: > * Elliot Berman [2023-02-14 13:24:26]: > > > static void gh_vm_free(struct work_struct *work) > > { > > struct gh_vm *ghvm = container_of(work, struct gh_vm, free_work); > > struct gh_vm_mem *mapping, *tmp; > > int ret; > > > > - mutex_lock(&ghvm->mm_lock); > > - list_for_each_entry_safe(mapping, tmp, &ghvm->memory_mappings, list) { > > - gh_vm_mem_reclaim(ghvm, mapping); > > - kfree(mapping); > > + switch (ghvm->vm_status) { > > +unknown_state: > > + case GH_RM_VM_STATUS_RUNNING: > > + gh_vm_stop(ghvm); > > + fallthrough; > > + case GH_RM_VM_STATUS_INIT_FAILED: > > + case GH_RM_VM_STATUS_LOAD: > > + case GH_RM_VM_STATUS_LOAD_FAILED: > > + mutex_lock(&ghvm->mm_lock); > > + list_for_each_entry_safe(mapping, tmp, &ghvm->memory_mappings, list) { > > + gh_vm_mem_reclaim(ghvm, mapping); > > + kfree(mapping); > > + } > > + mutex_unlock(&ghvm->mm_lock); > > + fallthrough; > > + case GH_RM_VM_STATUS_NO_STATE: > > + ret = gh_rm_dealloc_vmid(ghvm->rm, ghvm->vmid); > > + if (ret) > > + pr_warn("Failed to deallocate vmid: %d\n", ret); > > + > > + gh_rm_notifier_unregister(ghvm->rm, &ghvm->nb); > > + put_gh_rm(ghvm->rm); > > + kfree(ghvm); > > + break; > > + default: > > + pr_err("VM is unknown state: %d, assuming it's running.\n", ghvm->vm_status); > > + goto unknown_state; > > 'goto unknown_state' here leads to a infinite loop AFAICS. For example consider > the case where VM_START failed (due to mem_lend operation) causing VM state to > be GH_RM_VM_STATUS_RESET. A subsequent close(vmfd) can leads to that forever > loop. Hmm ..that's not a good example perhaps (VM state is set to GH_RM_VM_STATUS_INIT_FAILED in failed case). Nevertheless I think we should avoid the goto in case of unknown state. - vatsa From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2AEA8C636CC for ; Mon, 20 Feb 2023 09:56:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Reply-To:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version: References:Message-ID:Subject:CC:To:From:Date:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=tJraN2tdpyEld4eOPC0lWVJNUJ1zdqjsYPjn4Bqh3Wc=; b=CVswPE2K+dtVgx 7uNNWtvHGrjDQSDwc4goucW3Hr0jMB9u+yRE0tkerpKrkJGY8GQE7edZUOzaW0VgZI0MNVdweN1HR oq0Abivv8VSShJxAknaDlferUN8H5Xog6EIRjrVXuuQoATmVDiTAfrbbKsqHWE/J776M5gNfWJMk9 5KzI9zThj57tISz6cGub8Ne9hGXiWbEuYvqBEmV8U0xbolZMdwNN+t+F0mPIQPDmfWVuAzvPhi66J oMsdDxnX9l4W9qW406X51gPHcCu/wPabDzPaK/IMXJV5TkG3LF5eUWjvZ9Yd9qr3S1LylMGGXL9vA KIS2SjvFVLqtPBKrw6RA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pU2t7-003Z1v-Cb; Mon, 20 Feb 2023 09:55:13 +0000 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pU2t3-003Z14-HW for linux-arm-kernel@lists.infradead.org; Mon, 20 Feb 2023 09:55:11 +0000 Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31K5kGWl014593; Mon, 20 Feb 2023 09:54:54 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=date : from : to : cc : subject : message-id : reply-to : references : mime-version : content-type : in-reply-to; s=qcppdkim1; bh=ybKhwuDmZUHTj/uqJj1khzGF3Icxc2G5a4I1bJt4+xE=; b=XezZBHDh2SqPH7SJ4RKr5TC662RnebwnclVGhXUUnvVJfQVUf5eW+to+ir3n+70G4xJB HVM6xCKXsAWh1Wnd5Ggnwuc3cBCLQ5NHxlGcwNpcUDKGF+K3o71+LsGfobGrXfOL6RnS mZjfQ+lOLjPBrpUyfAEHLHpuqKiyq8s8UpCTdXrj2Y0yc/TPHYef08pa4KflVw+ynoeo jBMTC1AhdIrIw0P9eUU+sMIXeysEQhUVpI6HQzT1HC7pGBys10IVI7Cbyix3lWkfc5FS W0Wrpn0/lykgXfBEavbIDxFXCgnK6cTBu78nkY2iodg8yuoApQg9QCoToTp8gDTWOQSA 9g== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3ntps1cs5r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Feb 2023 09:54:54 +0000 Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 31K9srmV007829 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Feb 2023 09:54:53 GMT Received: from quicinc.com (10.80.80.8) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Mon, 20 Feb 2023 01:54:46 -0800 Date: Mon, 20 Feb 2023 15:24:42 +0530 From: Srivatsa Vaddagiri To: Elliot Berman CC: Alex Elder , Srinivas Kandagatla , Prakruthi Deepak Heragu , Murali Nalajala , Trilok Soni , Carl van Schaik , Dmitry Baryshkov , Bjorn Andersson , Konrad Dybcio , Arnd Bergmann , Greg Kroah-Hartman , Rob Herring , "Krzysztof Kozlowski" , Jonathan Corbet , Bagas Sanjaya , Catalin Marinas , Jassi Brar , , , , , Subject: Re: [PATCH v10 13/26] gunyah: vm_mgr: Add ioctls to support basic non-proxy VM boot Message-ID: <20230220095442.GA787573@quicinc.com> References: <20230214211229.3239350-1-quic_eberman@quicinc.com> <20230214212427.3316544-1-quic_eberman@quicinc.com> <20230220091544.GN332@quicinc.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230220091544.GN332@quicinc.com> X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: nIAT3YKYaTsYJ007_yxNIrl1-W2BHIgb X-Proofpoint-ORIG-GUID: nIAT3YKYaTsYJ007_yxNIrl1-W2BHIgb X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-20_07,2023-02-17_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 clxscore=1015 lowpriorityscore=0 suspectscore=0 priorityscore=1501 malwarescore=0 adultscore=0 impostorscore=0 phishscore=0 spamscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302200088 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230220_015509_717200_6DAFAA9B X-CRM114-Status: GOOD ( 15.96 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Srivatsa Vaddagiri Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org * Srivatsa Vaddagiri [2023-02-20 14:45:55]: > * Elliot Berman [2023-02-14 13:24:26]: > > > static void gh_vm_free(struct work_struct *work) > > { > > struct gh_vm *ghvm = container_of(work, struct gh_vm, free_work); > > struct gh_vm_mem *mapping, *tmp; > > int ret; > > > > - mutex_lock(&ghvm->mm_lock); > > - list_for_each_entry_safe(mapping, tmp, &ghvm->memory_mappings, list) { > > - gh_vm_mem_reclaim(ghvm, mapping); > > - kfree(mapping); > > + switch (ghvm->vm_status) { > > +unknown_state: > > + case GH_RM_VM_STATUS_RUNNING: > > + gh_vm_stop(ghvm); > > + fallthrough; > > + case GH_RM_VM_STATUS_INIT_FAILED: > > + case GH_RM_VM_STATUS_LOAD: > > + case GH_RM_VM_STATUS_LOAD_FAILED: > > + mutex_lock(&ghvm->mm_lock); > > + list_for_each_entry_safe(mapping, tmp, &ghvm->memory_mappings, list) { > > + gh_vm_mem_reclaim(ghvm, mapping); > > + kfree(mapping); > > + } > > + mutex_unlock(&ghvm->mm_lock); > > + fallthrough; > > + case GH_RM_VM_STATUS_NO_STATE: > > + ret = gh_rm_dealloc_vmid(ghvm->rm, ghvm->vmid); > > + if (ret) > > + pr_warn("Failed to deallocate vmid: %d\n", ret); > > + > > + gh_rm_notifier_unregister(ghvm->rm, &ghvm->nb); > > + put_gh_rm(ghvm->rm); > > + kfree(ghvm); > > + break; > > + default: > > + pr_err("VM is unknown state: %d, assuming it's running.\n", ghvm->vm_status); > > + goto unknown_state; > > 'goto unknown_state' here leads to a infinite loop AFAICS. For example consider > the case where VM_START failed (due to mem_lend operation) causing VM state to > be GH_RM_VM_STATUS_RESET. A subsequent close(vmfd) can leads to that forever > loop. Hmm ..that's not a good example perhaps (VM state is set to GH_RM_VM_STATUS_INIT_FAILED in failed case). Nevertheless I think we should avoid the goto in case of unknown state. - vatsa _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel