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 X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS autolearn=no 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 5701FC433E4 for ; Wed, 15 Jul 2020 12:31:26 +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 26C62206E9 for ; Wed, 15 Jul 2020 12:31:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ipC4LPP4" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 26C62206E9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jvgZ9-0004kw-Me; Wed, 15 Jul 2020 12:31:15 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jvgZ8-0004kq-Fo for xen-devel@lists.xenproject.org; Wed, 15 Jul 2020 12:31:14 +0000 X-Inumbo-ID: 12129312-c697-11ea-bb8b-bc764e2007e4 Received: from mail-wr1-x432.google.com (unknown [2a00:1450:4864:20::432]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 12129312-c697-11ea-bb8b-bc764e2007e4; Wed, 15 Jul 2020 12:31:13 +0000 (UTC) Received: by mail-wr1-x432.google.com with SMTP id f7so2516890wrw.1 for ; Wed, 15 Jul 2020 05:31:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:reply-to:to:cc:references:in-reply-to:subject:date:message-id :mime-version:content-transfer-encoding:content-language :thread-index; bh=QHdNXpa9mboIfnxcYiH8e2qwHoHgSHKSNZWbmNm5qN0=; b=ipC4LPP4kT51AjTBIodCMRGeY3wTja0cjvXAsJ3HgQ82OFikIQQ7esuamuqQkrkiT4 6S9dvbTnMZhwmI+m0mqIK9cYh+LlOOIYb5rMpZ4ioWzL5vncr9s8YLVp0WLcyyQv9sWl PYphrIrrgCPfcHBaKyeeHBzGAFzcoz4tb+djXVu3QzHXsY+g0Yr3U2g/rP8pnxPTsBgk FjCyzgHsly5QwCWX2N14iYXaHA/ugseFdSIIcfya6RH7Bkw291LRe4K3NQH8IkEbICHt P/h/x/OTDnsAwBbhoBKvvO2XCpjqxF19NuJaNqAHp2mlwl4MPCZ+yvecv11L4p4msq3P 0U2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:reply-to:to:cc:references:in-reply-to :subject:date:message-id:mime-version:content-transfer-encoding :content-language:thread-index; bh=QHdNXpa9mboIfnxcYiH8e2qwHoHgSHKSNZWbmNm5qN0=; b=elHhLhbq4hPOpzaJ3Dr1FjKMnEv4fVSnR6Ltaq/3j4SZJr5zTf7uJVDFVh/EdFtPH+ iKXC0qJaDVfHa+00ZDNPqWmebSZ61ZFySozTuLoStwGk9A9DIi+8ecjNp6Kj4/PbxDi3 o0qB+Brdf9jDnViSSgn0ZKAsZHWldH6t2Ub7z8VkHm0ZIVTSbmb5c7SEFKAxWAvPI6pq tJCIB+G3xgyDHTdNup9V5pqbuKEhcSKKhsUUe64/vASg6r+gMBbnVh1zij36ANyc+IQj uwnsnSApWXI4x066uB7KCBfz0xqsCaFfjiSbZzb3BYSc23ogAuKBMnCjFgeXCGCUPB6x 3inw== X-Gm-Message-State: AOAM532JOg5x1BloHPccDnbUjGOKroR5RnG4xC4qSKC0i98iMLBQjPmo 4T/snA56qxPMNwp7H/+h9SY= X-Google-Smtp-Source: ABdhPJw8zYWZhX7NAipuS5bEckvfBxCavsC8toIZHKTV9Q40oKjTlUkMUEUo7ORbqhNghQTX5czLdg== X-Received: by 2002:adf:fd8e:: with SMTP id d14mr11202870wrr.202.1594816272940; Wed, 15 Jul 2020 05:31:12 -0700 (PDT) Received: from CBGR90WXYV0 (54-240-197-235.amazon.com. [54.240.197.235]) by smtp.gmail.com with ESMTPSA id j145sm3424894wmj.7.2020.07.15.05.31.11 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Jul 2020 05:31:12 -0700 (PDT) From: Paul Durrant X-Google-Original-From: "Paul Durrant" To: "'Jan Beulich'" , References: <5426dd6f-50cd-dc23-5c6b-0ab631d98d38@suse.com> <7dd4b668-06ca-807a-9cc1-77430b2376a8@suse.com> In-Reply-To: <7dd4b668-06ca-807a-9cc1-77430b2376a8@suse.com> Subject: RE: [PATCH v3 1/2] x86: restore pv_rtc_handler() invocation Date: Wed, 15 Jul 2020 13:31:11 +0100 Message-ID: <001801d65aa3$d33bd090$79b371b0$@xen.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 16.0 Content-Language: en-gb Thread-Index: AQJIM2WedjUkwpXeO7NSr7H9rPuYmAKgm2H4qA/b1LA= X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Reply-To: paul@xen.org Cc: 'Andrew Cooper' , 'Wei Liu' , =?utf-8?Q?'Roger_Pau_Monn=C3=A9'?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" > -----Original Message----- > From: Jan Beulich > Sent: 15 July 2020 12:57 > To: xen-devel@lists.xenproject.org > Cc: Andrew Cooper ; Paul Durrant = ; Wei Liu ; > Roger Pau Monn=C3=A9 > Subject: [PATCH v3 1/2] x86: restore pv_rtc_handler() invocation >=20 > This was lost when making the logic accessible to PVH Dom0. >=20 > While doing so make the access to the global function pointer safe > against races (as noticed by Roger): The only current user wants to be > invoked just once (but can tolerate to be invoked multiple times), > zapping the pointer at that point. >=20 > Fixes: 835d8d69d96a ("x86/rtc: provide mediated access to RTC for PVH = dom0") > Signed-off-by: Jan Beulich > --- > v3: Latch pointer under lock. > v2: New. >=20 > --- a/xen/arch/x86/time.c > +++ b/xen/arch/x86/time.c > @@ -1148,6 +1148,8 @@ void rtc_guest_write(unsigned int port, >=20 > switch ( port ) > { > + typeof(pv_rtc_handler) hook; > + > case RTC_PORT(0): > /* > * All PV domains (and PVH dom0) are allowed to write to the = latched > @@ -1160,6 +1162,14 @@ void rtc_guest_write(unsigned int port, > case RTC_PORT(1): > if ( !ioports_access_permitted(currd, RTC_PORT(0), = RTC_PORT(1)) ) > break; > + > + spin_lock_irqsave(&rtc_lock, flags); > + hook =3D pv_rtc_handler; > + spin_unlock_irqrestore(&rtc_lock, flags); > + > + if ( hook ) > + hook(currd->arch.cmos_idx & 0x7f, data); > + > spin_lock_irqsave(&rtc_lock, flags); > outb(currd->arch.cmos_idx & 0x7f, RTC_PORT(0)); > outb(data, RTC_PORT(1)); LGTM.. Release-acked-by: Paul Durrant