Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp6046389rwn; Mon, 12 Sep 2022 20:03:28 -0700 (PDT) X-Google-Smtp-Source: AA6agR5yLOsG0M/aEfkyuFLTDR8RXL0DvpvylsB5eUZzdLEe34rnDPtG+sBhKlzj95IXm6XK4E7x X-Received: by 2002:a05:6402:e94:b0:443:e3fe:7c87 with SMTP id h20-20020a0564020e9400b00443e3fe7c87mr25047718eda.144.1663038208154; Mon, 12 Sep 2022 20:03:28 -0700 (PDT) Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id en22-20020a056402529600b004513abe8f74si7339194edb.249.2022.09.12.20.03.02; Mon, 12 Sep 2022 20:03:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=EZz6a0uP; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230072AbiIMC5o (ORCPT + 99 others); Mon, 12 Sep 2022 22:57:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229567AbiIMC5m (ORCPT ); Mon, 12 Sep 2022 22:57:42 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D11194F658; Mon, 12 Sep 2022 19:57:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1663037861; x=1694573861; h=message-id:date:subject:to:cc:references:from: in-reply-to:content-transfer-encoding:mime-version; bh=wBP2v4zuxOp2NJesL1LEfHEjOEdS6mjK6+UppkxDQKU=; b=EZz6a0uP4/myEAZzwEk+6bHVR73tKrTqJVhkDCFeIWMLI807RAoAQ8e4 EXB5VwZEsDlQyK/NC14PyWJjS6sN383wOOA3k7KAi0NKOqtYgHdJcRjeu M0yNeD+RPcb/VV56KEaI91gCdYETFvUqfcuMc4LVKBEuctDE5KZudi0TN iPR4iX6f4An2S7OTIwMAamfP3R0i+4g1ehFvBhnrMTnnvjpuyBcg8MqJp agIyGwDAp68T4yErlKVw3CZBhCQleHmy4CEd+Rf0buhrK2zXQWYtz91mY lDKp/CIwW+0974JLTv2KJGX2ccdlJ3XQQT6KDcNuRT1rH4SlfUycUxUtG A==; X-IronPort-AV: E=McAfee;i="6500,9779,10468"; a="295608655" X-IronPort-AV: E=Sophos;i="5.93,311,1654585200"; d="scan'208";a="295608655" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2022 19:57:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,311,1654585200"; d="scan'208";a="593750764" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by orsmga006.jf.intel.com with ESMTP; 12 Sep 2022 19:57:40 -0700 Received: from fmsmsx609.amr.corp.intel.com (10.18.126.89) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 12 Sep 2022 19:57:39 -0700 Received: from fmsmsx608.amr.corp.intel.com (10.18.126.88) by fmsmsx609.amr.corp.intel.com (10.18.126.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 12 Sep 2022 19:57:39 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx608.amr.corp.intel.com (10.18.126.88) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31 via Frontend Transport; Mon, 12 Sep 2022 19:57:39 -0700 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (104.47.51.44) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2375.31; Mon, 12 Sep 2022 19:57:39 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OZRijBENKDUdwH6MQ9kmMz5wtE+1sdY6azkQX8+Uwk0aKPPSBO95b6laD9LpafWbfezRqj1zuIyvkN2BL7P95st+oIETxl4vEVlPj4Yr41453tl35O+bUDbtrXQie6gcvfWGdK7dMLS17NzjSXFK9nHLfH3xYxcsGrP1TxwEb9ng2MEzDv6YED9jk6PdP7GHXVHQghTBeyHv8Lk74TTUmR8NQzD/PGlGAMfR21WkM2xmxgH5S4WzllSZyleEx54lUpj+70lnAyyC7JJTSjaYCZa+pgPnJ5/wZuYghmIMMxeQbxyZynQVoI9uQAPQHCXyD0ZAArAPRBy7mX6uPrV8CA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=RK+IE4VIaEQZ2RYO3nfysp8YsnQocSPco12qfB8e6Kw=; b=VgUrKNqPB/De6P+OlJdypn3ye09UrtCbLwrmxHcl0Dv6oU/FRXb9fbMdmX7x5+UffsYbsEge8rb1GFrwte8+fQB0va35zXAUxRNMPANe6VW/wIuJEYOnueStriPfLKn3wA48VGlBkiqtnbMTdfl/iweYRNn7HGkh40P1mKreVGeFuHgZgWGVPQUoQDzo+VnQ8bSHt1z1bF148r+i4E2cYJjgeC5wIofWF6brMEqF61h2I6oqtmlRrAY94IfVjM/Ya0j2kYKCZ34E8LMjAUSw0/sUIT2//5wK5sy7Op3uUBS09SNu1WMExtyda+2RasRcjWspBjPna1IzAYd6gvd05w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from PH0PR11MB4965.namprd11.prod.outlook.com (2603:10b6:510:34::7) by MN0PR11MB5986.namprd11.prod.outlook.com (2603:10b6:208:371::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5612.22; Tue, 13 Sep 2022 02:57:33 +0000 Received: from PH0PR11MB4965.namprd11.prod.outlook.com ([fe80::ddb:2488:14dd:3751]) by PH0PR11MB4965.namprd11.prod.outlook.com ([fe80::ddb:2488:14dd:3751%9]) with mapi id 15.20.5612.022; Tue, 13 Sep 2022 02:57:33 +0000 Message-ID: <9fcd1d25-ec4d-eebe-623f-cfeb48b6656f@intel.com> Date: Tue, 13 Sep 2022 10:56:13 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.13.0 Subject: Re: [RFC PATCH 5/9] kvm_main.c: split __kvm_set_memory_region logic in kvm_check_mem and kvm_prepare_batch Content-Language: en-US To: Emanuele Giuseppe Esposito CC: Paolo Bonzini , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , David Hildenbrand , "Maxim Levitsky" , , "H. Peter Anvin" , , "kvm@vger.kernel.org" References: <20220909104506.738478-1-eesposit@redhat.com> <20220909104506.738478-6-eesposit@redhat.com> From: "Yang, Weijiang" In-Reply-To: <20220909104506.738478-6-eesposit@redhat.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: SG2PR01CA0174.apcprd01.prod.exchangelabs.com (2603:1096:4:28::30) To PH0PR11MB4965.namprd11.prod.outlook.com (2603:10b6:510:34::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR11MB4965:EE_|MN0PR11MB5986:EE_ X-MS-Office365-Filtering-Correlation-Id: 4423e2e8-f06d-4dc4-614b-08da9533b4a0 X-LD-Processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: d7EXYOW3riubqYN4SDEdfWSuyCLL0m//Ql4pa/mFJ7dsON5gY+J8eBDKdzrGAkUxShaoPrmjv3N4tffywc4urET8gdfrG1FTrotOt2mqatTjNyuGw5S1c6G7cgyOA6gEUwLhT9tpG+qRZXG6ieBj50jI999qPxyNUqmZ5qYoVWZqR+d+FnKgLRpowCVb0AAdzXjcIDefnZUQNOQ/F6+nmvhqplvh9myWDX8vKWIGFIrtuusGwnvP4VKNKfIL1NgF0oYS+j4I8st4bkH9EPi4yBK0Df2xjJPDTC0HYWd1kPpOqXbsGnV0W83a/TAJ83ZCRX6jowwnughAsfJV7dzp89iJbjEIdShAjVdqN9wZIUHz7MV1uQwAUf7jDjaHMIpNDkHQ0UY7By+RrSZYAwhznXpnn06XB3WyJO0MCcw8FWHURbJBDXj9DUtU/cg7F8hcyt+2sazbwFaLFFaLqw6Pr/GleoyV5E29eHCsWN6TdVKAEw1rh30Jg1GuK2lRmXanvFB8qR+EWdEBmDga2XpxS29VBqKQnhF2R0+oo6lC/7SMErhDFrLi2Nty8p+FwJJbG29CRVK3wyLgOa5qi1EZ50hqd+RWzfTdzWvNquxYX7cvrTd1Sb1px3x8UfTHSDBex2VikDvlqbnzEM+dGUOHFteGt5BixvGbBx8GVn+rNL7WUe6BlLdYVHVprx9+PbBZKXlpt1f725RkbYpzFIKai4OTFNnxebB4GGxVj2e7aZZ/Sq0QjPd7+yAotzbrzoVWQt5kQN5NeLHPpWyFF0kcVeH/VYOZwoy0+CHBykUP21k= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR11MB4965.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(366004)(136003)(376002)(39860400002)(396003)(346002)(451199015)(66946007)(6666004)(38100700002)(82960400001)(4744005)(6916009)(2906002)(8936002)(4326008)(7416002)(6512007)(83380400001)(41300700001)(186003)(31696002)(53546011)(478600001)(5660300002)(66556008)(8676002)(66476007)(6506007)(26005)(6486002)(2616005)(31686004)(36756003)(54906003)(316002)(86362001)(45980500001)(43740500002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?MGVuVnFhUmlRbVUra0VOdFZTS2FwbmhrbUROYlNsbExza2ZhenRjdFgrT1NO?= =?utf-8?B?QXkyUVBYeXRUMW1vbkRSSkR4bUJsWWhrMWhuQ1d1S3NKeTRhYzh5R012UExl?= =?utf-8?B?Y1hLZy8rWXJGaTdFYU5FMkpJY0wwNmlRYW9LVFg2TCtMU25Kd1RLREl6Mlda?= =?utf-8?B?a3gvWGhhSk41NW1uelo4enRZdlVxNmR3TFNrdUJqZkt4aFRmTGRWaTFJZXNJ?= =?utf-8?B?S20yMGxiVGJWRWJucWtQLzg1RS9oQk1jVmhONU9GS1pvZGRzdEVIN1Z0Qnhw?= =?utf-8?B?MjgvTEloRWphQkdEcUF0ZWczNWU3bXdjQlRMKzJtRXl2N2N2R2FsbEoraThL?= =?utf-8?B?WjVCaWxLa0cyYkRhNlZ5ZGxOYWV2ME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cGVn?= =?utf-8?B?a2c9PQ==?= X-MS-Exchange-CrossTenant-Network-Message-Id: 4423e2e8-f06d-4dc4-614b-08da9533b4a0 X-MS-Exchange-CrossTenant-AuthSource: PH0PR11MB4965.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2022 02:57:33.3719 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: t1t8+u3mxn9HmtFS8fhWmkkqqjjOHeC8IXkI/MwDPdyvvKbPrcIeWJ5MepWo27WXLWmz9DksKjMd0ipk3v9HiQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR11MB5986 X-OriginatorOrg: intel.com X-Spam-Status: No, score=-9.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/9/2022 6:45 PM, Emanuele Giuseppe Esposito wrote: > Just a function split. No functional change intended, > except for the fact that kvm_prepare_batch() does not > immediately call kvm_set_memslot() if batch->change is > KVM_MR_DELETE, but delegates the caller (__kvm_set_memory_region). > > > +static int kvm_check_memory_region(struct kvm *kvm, > + const struct kvm_userspace_memory_region *mem, > + struct kvm_internal_memory_region_list *batch) > +{ > + int r; > + > + r = check_memory_region_flags(mem); > + if (r) > + return r; > > - r = kvm_set_memslot(kvm, batch); > + r = kvm_check_mem(mem); > if (r) > - kfree(new); > + return r; > + > + r = kvm_prepare_batch(kvm, mem, batch); > + if (r && batch->new) > + kfree(batch->new); From the patch, r !=0 and batch->new !=NULL are exclusive, so free() here is not reachable. > + > return r; > } [...] >