Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7504BC4363D for ; Fri, 2 Oct 2020 12:29:04 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1F50620665 for ; Fri, 2 Oct 2020 12:29:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="c2K4kOZv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1F50620665 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.2041.6118 (Exim 4.92) (envelope-from ) id 1kOKB9-0002fw-Vc; Fri, 02 Oct 2020 12:28:51 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 2041.6118; Fri, 02 Oct 2020 12:28:51 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kOKB9-0002fp-SA; Fri, 02 Oct 2020 12:28:51 +0000 Received: by outflank-mailman (input) for mailman id 2041; Fri, 02 Oct 2020 12:28:50 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kOKB8-0002fj-Li for xen-devel@lists.xenproject.org; Fri, 02 Oct 2020 12:28:50 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 7b1044f9-9a90-486c-9ed4-3b5089c75bc0; Fri, 02 Oct 2020 12:28:49 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id C1922AC6D; Fri, 2 Oct 2020 12:28:48 +0000 (UTC) Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kOKB8-0002fj-Li for xen-devel@lists.xenproject.org; Fri, 02 Oct 2020 12:28:50 +0000 X-Inumbo-ID: 7b1044f9-9a90-486c-9ed4-3b5089c75bc0 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 7b1044f9-9a90-486c-9ed4-3b5089c75bc0; Fri, 02 Oct 2020 12:28:49 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1601641728; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yYm16sD4KHefZ2j8SxaiXlxlMEdlEuTzKyyWhgvMbnE=; b=c2K4kOZvGetFDNSdJPBOtMLhEZpL7IJGEsL23DYXqmGx1Bb2pzv7hNqUVpeTh5flK+ur5J tKY4+sj3d2uwQAPwhKuRwUFoHTS2uj2i0rrG/HZaHwAVVm3VuIhGlwupBYvknxqoKClF0C 2Eq3Uk5puW/lVXVXQMIV7ZNrZrWWl4M= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id C1922AC6D; Fri, 2 Oct 2020 12:28:48 +0000 (UTC) Subject: Re: [PATCH 2/3] x86: fix resource leaks on arch_vcpu_create() error path To: Andrew Cooper Cc: "xen-devel@lists.xenproject.org" , Wei Liu , =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= References: <1a55f2f0-f0aa-4a33-1219-1091ed9150df@suse.com> <77106fd6-96c5-4a62-5eee-8a37660db550@suse.com> From: Jan Beulich Message-ID: <45c132b8-2a86-2e3b-6fe4-76041787d2d4@suse.com> Date: Fri, 2 Oct 2020 14:28:51 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit On 02.10.2020 13:13, Andrew Cooper wrote: > On 02/10/2020 11:30, Jan Beulich wrote: >> {hvm,pv}_vcpu_initialise() have always been meant to be the final >> possible source of errors in arch_vcpu_create(), hence not requiring >> any unrolling of what they've done on the error path. (Of course this >> may change once the various involved paths all have become idempotent.) > > I'd agree that the way the code was previously laid out expected > {hvm,pv}_vcpu_initialise() to be the final failing option. > > I don't think "has always meant to be" is reasonable, because where is > the code comment explaining this design choice? It's probably more a "happened to be that way and then it was easiest to keep it like this", but I recall the behavior having been the subject of discussions, with the outcome that it's at least "kind of" intended. Would adding "kind of" make things look better to you? >> But even beyond this aspect I think it is more logical to do policy >> initialization ahead of the calling of these two functions, as they may >> in principle want to access it. > > Not these MSRs.  They're currently a block of zeroes, and while that > will eventually change, it will still be a bunch of MSRs in their RESET > state. > > The interesting MSRs are the domain ones, not the vCPU ones. If you had said "The more interesting ...", I'd have agreed. What I was thinking of as possible uses (be it reading or writing) is e.g. reset state that may depend on certain further properties. Furthermore I was thinking of code paths that vCPU initialization simply may re-use, and which expect the policy to at least be available, irrespective of the individual MSRs' values still being their reset ones. >> Fixes: 4187f79dc718 ("x86/msr: introduce struct msr_vcpu_policy") >> Signed-off-by: Jan Beulich > > Reviewed-by: Andrew Cooper although I'd > prefer some adjustment to the commit message along the indicated lines. Thanks. As far as adjustments go, I don't really see how to better reflect what you want, considering my replies above. If you have any hints ... (I'll hold off committing this for a little while, but I think I'd like to put it in before I leave for weekend and vacation.) Jan