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=-3.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,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 190CEC433E1 for ; Mon, 20 Jul 2020 13:22:51 +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 DAF1820729 for ; Mon, 20 Jul 2020 13:22:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="EPz9JdkP" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DAF1820729 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.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 1jxVkU-00012K-PT; Mon, 20 Jul 2020 13:22:30 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jxVkT-00011o-H3 for xen-devel@lists.xenproject.org; Mon, 20 Jul 2020 13:22:29 +0000 X-Inumbo-ID: 0e2f93c9-ca8c-11ea-848e-bc764e2007e4 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 0e2f93c9-ca8c-11ea-848e-bc764e2007e4; Mon, 20 Jul 2020 13:22:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1595251348; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=rWX7UgQLWphzCpDeE9TH91eyyN4ef7p3oiKbTx8bXGQ=; b=EPz9JdkPznULBDIRL1KZ8SndXh3QlflXtdu4uoG509t7Sxg0iqfQS3ys auJIse6qVU5TMjd3jIL2XKiNR9IKC0rmlTr8drfgDJ3dNnwGyPGhwKV2b dB6V1cJ9O4Gc1DhMzGojAoP9geufdhwofKBlMao8wZjmSNl1BqvfQegMp A=; Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: JSc1KxCDMqwgE350jYVkc/thdFnuFjAul1kIhutLHrFGFEDANkexuSOA36gQXjddgIDy0KW4Qf XcmQzqw6iz0blI6b0dZYR3gxZK5HcOdY1G0FbNBP/7jEUqfz0vv3J5SEfXWZKFq8ytyhYpeh8t ha8iTqLjkQ0hC9Y/7omqNNQ+cwlvQ2p/4xgkpSBIcWFBkCVdlkUqGDXlywxgrDr0psZtvmzCpA raNj+4vvEpmOGoK+M0SAgXwQsgnhzrWNk047SNaw3GW8PFX8TKaHmmpTVk9yB/Hds1mGe6Qnl8 uAE= X-SBRS: 2.7 X-MesageID: 23077979 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.75,375,1589256000"; d="scan'208";a="23077979" Date: Mon, 20 Jul 2020 15:22:19 +0200 From: Roger Pau =?utf-8?B?TW9ubsOp?= To: Jan Beulich Subject: Re: [PATCH] x86: guard against port I/O overlapping the RTC/CMOS range Message-ID: <20200720132219.GL7191@Air-de-Roger> References: <38c73e17-30b8-27b4-bc7c-e6ef7817fa1e@suse.com> <20200720105213.GI7191@Air-de-Roger> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-ClientProxiedBy: AMSPEX02CAS01.citrite.net (10.69.22.112) To AMSPEX02CL02.citrite.net (10.69.22.126) 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: , Cc: "xen-devel@lists.xenproject.org" , Wei Liu , Andrew Cooper Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" On Mon, Jul 20, 2020 at 01:58:40PM +0200, Jan Beulich wrote: > On 20.07.2020 12:52, Roger Pau Monné wrote: > > On Fri, Jul 17, 2020 at 03:10:43PM +0200, Jan Beulich wrote: > >> Since we intercept RTC/CMOS port accesses, let's do so consistently in > >> all cases, i.e. also for e.g. a dword access to [006E,0071]. To avoid > >> the risk of unintended impact on Dom0 code actually doing so (despite > >> the belief that none ought to exist), also extend > >> guest_io_{read,write}() to decompose accesses where some ports are > >> allowed to be directly accessed and some aren't. > > > > Wouldn't the same apply to displaced accesses to port 0xcf8? > > No, CF8 is special - partial accesses have no meaning as to the > index selection for subsequent CFC accesses. Or else CF9 > couldn't be a standalone port with entirely different > functionality.. Right: Reviewed-by: Roger Pau Monné See below. > >> @@ -373,25 +384,31 @@ static int read_io(unsigned int port, un > >> return X86EMUL_OKAY; > >> } > >> > >> +static void _guest_io_write(unsigned int port, unsigned int bytes, > >> + uint32_t data) > > > > There's nothing guest specific about this function I think? If so you > > could drop the _guest_ prefix and just name it io_write? > > Hmm, when choosing the name I decided that (a) it's a helper of > the other function and (b) it's still guest driven data that we > output. Well, the fact that it's guest driven data shouldn't matter much, because there are no guest-specific checks in the function anyway - it might as well be used for non-guest driven data AFAICT? (even if it's not the case ATM). It's likely that if I have to change code here in the future I will drop such prefix, but the change is correct regardless of the naming, so I'm not going to insist. > >> +{ > >> + switch ( bytes ) > >> + { > >> + case 1: > >> + outb((uint8_t)data, port); > >> + if ( amd_acpi_c1e_quirk ) > >> + amd_check_disable_c1e(port, (uint8_t)data); > >> + break; > >> + case 2: > >> + outw((uint16_t)data, port); > >> + break; > >> + case 4: > >> + outl(data, port); > >> + break; > >> + } > > > > Newlines after break statements would be nice, and maybe add a > > default: ASSERT_UNREACHABLE() case to be on the safe side? > > Well, yes, I guess I should. But then if I edit this moved code, > I guess I'll also get rid of the stray casts. Was going to also ask for that, but I assumed there might we some value in making the truncations explicit here. Feel free to drop those also if you end up making the above adjustments. Thanks, Roger.