Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp646076lqo; Thu, 16 May 2024 18:17:59 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXrimE0r8Bz+XTcAC3kVhI9HQ69lrqOBGpv98wBqBzkx8WMSpUwbs31S1r+XlPhlmnOL96LymsSDDE0SV1kEiGUwpbCxpVL9X7KP+nz6g== X-Google-Smtp-Source: AGHT+IEfZwZwCLlmVLQZVglRAjzdKqqIedVruwpym+tDZGehcTytqkeqUsPrcL+YjBpatKYC8Pzt X-Received: by 2002:a05:6a20:d707:b0:1b0:2cae:4622 with SMTP id adf61e73a8af0-1b02cae4802mr3100428637.42.1715908679322; Thu, 16 May 2024 18:17:59 -0700 (PDT) Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2b67158a109si16872561a91.142.2024.05.16.18.17.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 18:17:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-181671-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b="PCBlgm/J"; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-181671-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-181671-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id E4172282753 for ; Fri, 17 May 2024 01:17:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 18E48818; Fri, 17 May 2024 01:17:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="PCBlgm/J" Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2041.outbound.protection.outlook.com [40.107.243.41]) (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 35432622 for ; Fri, 17 May 2024 01:17:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.41 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715908672; cv=fail; b=OdjDc+0dH5Vc9FKoT1/L/zCzmt9BqJ/u9RgHdXBjWbqKlr7axwUM1Tk9hvXm4nIePvUYxCjpIOkIWPS8ss/M9FVPq4etA1wHxp4fUsZLpSKo7e22AI0i/1zxEGUARAKTqZcHCcAKfZogTaU/eIB3Mdi4idIgNrNj6GqCi1OIl0A= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715908672; c=relaxed/simple; bh=hp66MI3b6CgocvoNRNC7EwGyC6SgM8LqbD9Ao+g8mB4=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=Yoa/1n4WkMeVjs8U0MCCz6IK/fI+Aj11jngYwdnL9Bv7IHFIzxN9xEaacEz5gNAw52Znj7tictE2e1WVd1lXGoalnEVLcEo4g6X8SDqIR/h/whhKoUS+ZjLZR4S+asol9cf4JH5amTDAY9W5GoGXIAUh5yjCW/eAQfjeNeTgZOM= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=PCBlgm/J; arc=fail smtp.client-ip=40.107.243.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Bs/Q2jv0yG8Cn7b+ptGujytF/rTmER1KRPEPyDGmxgmaNf8utFBfLzP+zhX6knag0xmb5L/cZ0xVIp5z15HKxC5uZuaZd2R5PhVPHx3ztQNLSG/tnWmUQQAV3qHQLnmwFPUGqJvB3MXENzoqro9I6JkYkcAfo8GZwSR9SJHPk2wcV8I0KFw+lB0cihQyc0jqhMZUSCiKryeHmFK93dRBYy48NsfY5jlermTP5lP4HjhlsCeJyDYVq1lUVRIy9mmhpea1vUn4w+ecZ0Sdznie/KYVwPz86L50tI5Nxl7gynSP1VthMpbKgjPkvUWaBjqUhNP664R+GzrkYycVKioe8Q== 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=Kp85KC0psuXALGt1cPe+mlXd7lcMqilrHi8mw7kjljQ=; b=PeEQBbpWtWNRLigApQDsH77U5eonflQ7bbYX++NCiWED+FRfsC/1OpNdA2DyQ4zPVVNPwgtw/Kt6vqkXRlV7RsXA+0f/Kn+SuXydLXTDYQxzVo56pbmFkc7hoiSH7YC8AH1CjhUOrIfA70tsZKmwFq6+4kpc5G0KuTXYwP9oort+RRdXOHxmOIK+zqDGul4hTbND/WpAitWW+1n5nd0xgqaJBbJVqgjLwwRGNLzitw8Cx5isSiSUUFWEK4/k5x8hWj+m3dMw1lo+JyT4JHv/rwAcf0tyGwqz17gHbv8OAdHyVoI4KV8ezAQm4rph49dccgir4zLiTfPM9+3mtFK2gg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Kp85KC0psuXALGt1cPe+mlXd7lcMqilrHi8mw7kjljQ=; b=PCBlgm/JytrDJ/4YOM67Mu/tTNpBvhOpYuiLekWU15SMbdKp/HWRyilW/kj8uvHjISrKw2fQruigUbpY4orYgncI8rp/YpKcLOoLP+AcC+nteKWzdPmOE8kbYzzU/uaQUzV7s5c2WfDDFPi8gweGyL5RkjT2dxuPue0zMrkpEVE= Received: from BN9PR03CA0709.namprd03.prod.outlook.com (2603:10b6:408:ef::24) by MW5PR12MB5599.namprd12.prod.outlook.com (2603:10b6:303:194::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.27; Fri, 17 May 2024 01:17:47 +0000 Received: from BN3PEPF0000B074.namprd04.prod.outlook.com (2603:10b6:408:ef:cafe::68) by BN9PR03CA0709.outlook.office365.com (2603:10b6:408:ef::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.28 via Frontend Transport; Fri, 17 May 2024 01:17:47 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by BN3PEPF0000B074.mail.protection.outlook.com (10.167.243.119) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7587.21 via Frontend Transport; Fri, 17 May 2024 01:17:46 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 16 May 2024 20:17:46 -0500 Received: from [172.31.124.47] (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Thu, 16 May 2024 20:17:44 -0500 Message-ID: <1539e7ab-f27f-4cea-bb79-4c341bb3c69c@amd.com> Date: Fri, 17 May 2024 09:17:43 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] drivers/xen: Improve the late XenStore init protocol To: Stefano Stabellini CC: , , "Juergen Gross" , Oleksandr Tyshchenko , Michal Orzel References: <20240515014330.1044617-1-xin.wang2@amd.com> <028f29be-0393-4a57-83e2-ea27fe0320d5@amd.com> Content-Language: en-US From: Henry Wang In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit Received-SPF: None (SATLEXMB03.amd.com: xin.wang2@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN3PEPF0000B074:EE_|MW5PR12MB5599:EE_ X-MS-Office365-Filtering-Correlation-Id: 2b122ba2-0dff-4fa6-5dea-08dc760f293e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|36860700004|376005|82310400017;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lzdXNUWGs3RkhsZGJ5SU1QeVliSG5PU0hRQm5yYlFZVnBl?= =?utf-8?B?Ump0ajlHdnVFcVNBUmxvaGVUd3dGS2tONDNSMWZOVE0xRG1iN2tKTHIxQzcw?= =?utf-8?Q?UG2kNWVV4kE6b?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(1800799015)(36860700004)(376005)(82310400017);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 May 2024 01:17:46.7839 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2b122ba2-0dff-4fa6-5dea-08dc760f293e X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN3PEPF0000B074.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW5PR12MB5599 Hi Stefano, On 5/17/2024 8:52 AM, Stefano Stabellini wrote: > On Thu, 16 May 2024, Henry Wang wrote: >>>> enum xenstore_init xen_store_domain_type; >>>> EXPORT_SYMBOL_GPL(xen_store_domain_type); >>>> @@ -751,9 +755,10 @@ static void xenbus_probe(void) >>>> { >>>> xenstored_ready = 1; >>>> - if (!xen_store_interface) { >>>> - xen_store_interface = memremap(xen_store_gfn << >>>> XEN_PAGE_SHIFT, >>>> - XEN_PAGE_SIZE, MEMREMAP_WB); >>>> + if (!xen_store_interface || XS_INTERFACE_READY) { >>>> + if (!xen_store_interface) >>> These two nested if's don't make sense to me. If XS_INTERFACE_READY >>> succeeds, it means that ((xen_store_interface != NULL) && >>> (xen_store_interface->connection == XENSTORE_CONNECTED)). >>> >>> So it is not possible that xen_store_interface == NULL immediately >>> after. Right? >> I think this is because we want to free the irq for the late init case, >> otherwise the init-dom0less will fail. For the xenstore PFN allocated case, >> the connection is already set to CONNECTED when we execute init-dom0less. But >> I agree with you, would below diff makes more sense to you? >> >> diff --git a/drivers/xen/xenbus/xenbus_probe.c >> b/drivers/xen/xenbus/xenbus_probe.c >> index 8aec0ed1d047..b8005b651a29 100644 >> --- a/drivers/xen/xenbus/xenbus_probe.c >> +++ b/drivers/xen/xenbus/xenbus_probe.c >> @@ -76,6 +76,8 @@ EXPORT_SYMBOL_GPL(xen_store_interface); >>         ((xen_store_interface != NULL) && \ >>          (xen_store_interface->connection == XENSTORE_CONNECTED)) >> >> +static bool xs_late_init = false; >> + >>  enum xenstore_init xen_store_domain_type; >>  EXPORT_SYMBOL_GPL(xen_store_domain_type); >> >> @@ -755,7 +757,7 @@ static void xenbus_probe(void) >>  { >>         xenstored_ready = 1; >> >> -       if (!xen_store_interface || XS_INTERFACE_READY) { >> +       if (xs_late_init) { >>                 if (!xen_store_interface) >>                         xen_store_interface = memremap(xen_store_gfn << > > I would just remove the outer 'if' and do this: > > > if (!xen_store_interface) > xen_store_interface = memremap(xen_store_gfn << XEN_PAGE_SHIFT, > XEN_PAGE_SIZE, MEMREMAP_WB); > /* > * Now it is safe to free the IRQ used for xenstore late > * initialization. No need to unbind: it is about to be > * bound again from xb_init_comms. Note that calling > * unbind_from_irqhandler now would result in xen_evtchn_close() > * being called and the event channel not being enabled again > * afterwards, resulting in missed event notifications. > */ > if (xs_init_irq > 0) > free_irq(xs_init_irq, &xb_waitq); > > > I think this should work fine in all cases. Thanks. I followed your suggestion in v2. > I am unsure if > xs_init_irq==0 is possible valid value for xs_init_irq. If it is not, > then we are fine. If 0 is a possible valid irq number, then we should > initialize xs_init_irq to -1, and here check for xs_init_irq >= 0. Yeah the xs_init_irq==0 is a valid value. I followed your latter comment to init it to -1 and check it >=0. Kind regards, Henry