From nobody Fri May 17 06:07:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1702910872; cv=none; d=zohomail.com; s=zohoarc; b=L0Xp8eNoCLXOE4aVXkko7pg2iWkRa05mhpIaKn1opfGyM3NYdaR0Z6cgQuwqsygjk/wGh30t5A7AjmUzXltTsli+miURHqMK8P+z7jrUfuInI6yenSHFgL+ru1oAO5efkjP6pWZIq7uTeiEqFB71BIDTfPk9EDA8YgoldserkiY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702910872; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=/fMlAv9ea8KmO95h1rEr/bKlXlzXc/GyAyAyQRSshWQ=; b=N1BxXnZ4RGqWjGZJfjlFaNNwis49jWJqxfz+xRQ8FmZ6u1kgF+hmmtVJqothO2AtRXRmac3iHTF/I87YXBJ2Ow6MRwhBJ5zh8lukBgoV97G7Thbom7chbNV29iVrCBEFc+7zR3jWv6kTYtTIufjXUwaQP//dUONTfVLkUT0lz60= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1702910872518166.33710011229755; Mon, 18 Dec 2023 06:47:52 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.656094.1024064 (Exim 4.92) (envelope-from ) id 1rFEty-0007NK-E9; Mon, 18 Dec 2023 14:47:26 +0000 Received: by outflank-mailman (output) from mailman id 656094.1024064; Mon, 18 Dec 2023 14:47:26 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rFEty-0007ND-B5; Mon, 18 Dec 2023 14:47:26 +0000 Received: by outflank-mailman (input) for mailman id 656094; Mon, 18 Dec 2023 14:47:25 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rFEtx-0007N3-53 for xen-devel@lists.xenproject.org; Mon, 18 Dec 2023 14:47:25 +0000 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [2a00:1450:4864:20::434]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 5af23cc0-9db4-11ee-98eb-6d05b1d4d9a1; Mon, 18 Dec 2023 15:47:24 +0100 (CET) Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-336668a5a8dso1348899f8f.1 for ; Mon, 18 Dec 2023 06:47:24 -0800 (PST) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id j29-20020a5d6e5d000000b003364e437577sm10175351wrz.84.2023.12.18.06.47.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 18 Dec 2023 06:47:23 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version 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" X-Inumbo-ID: 5af23cc0-9db4-11ee-98eb-6d05b1d4d9a1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1702910843; x=1703515643; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=/fMlAv9ea8KmO95h1rEr/bKlXlzXc/GyAyAyQRSshWQ=; b=K9ndiHpo/nJKD3gSh9ZRw7a4F4sHUiXYc4ZOWIhLtvgJJLdDjgsbWRdE0Zo7ca9o+j xqBEcHHJ+yunc/Jadgf66ppkFQx+PhDwmDGaVkJVVc39YZCGld+HXtxeMXYSovpiBoEz Hv5ApNGpHyjhM+OXQreRbqtThpSk6CRtuqI9HDVqyOQhTZrONLHxFfFiX04TdIiKiNvN hR8kxfxZhZzicHbRIs2Lm0YtfnuJ+F82hI6fCCUIYuezS2xTlyM7OJTc4O6/aeLHZccR bKL7tcJCKn5FZsWxPZjgs6tt5GSoooUgo43bxTox2UYaVDheb5nbze68zXwrg0lhzb3H at4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702910843; x=1703515643; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=/fMlAv9ea8KmO95h1rEr/bKlXlzXc/GyAyAyQRSshWQ=; b=kNL7tQaauYg6UUgt5m3KveWg9DqUpgdxFCLPI/tom7E/RZMe+R0M/kreJ2nQudJ7EK WsX9SQuI8UkEdESo5aNX3Mq/7Qkoc26MhbzDzla+NaTkTFj+2xGKrf4p5xV6vvSS8Z5X QUH3ECPzPtGZtMIZ77dz+sp2i0UX8HTSMN5LZ0Piwdmw0AIieqnemokb9Yf+98BvoJUE KCrmVwRax5zQJ9/Lcfaq2QuCfO49JGukSxXHvSrrDHn+UO6VH2I5d5hFx3Fn72BW46rY nmtH1044/EA6OsNM9LQuvKm2F14eMjbOgd6y+9JSEn1rObkYRKiSb7SAWWYTfhAFi7QS b6fg== X-Gm-Message-State: AOJu0Yxc7ruYyZdAG/xq9uSSRZhjqCA93yMR2I6STPtpIK8ivoSBk0H7 JQkqXkEYSM0VrDLvPcrjwg2mhlEWfFyarvakhKJm X-Google-Smtp-Source: AGHT+IEEWLq7N/yo94hEvikQL8/wPkeWEXKD8oVGf1W5HpGeD4qe37bbrWxPQNmlpNA+UW9AGlaq0A== X-Received: by 2002:a5d:55c6:0:b0:336:6e7d:3aff with SMTP id i6-20020a5d55c6000000b003366e7d3affmr185148wrw.37.1702910843678; Mon, 18 Dec 2023 06:47:23 -0800 (PST) Message-ID: Date: Mon, 18 Dec 2023 15:47:23 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH v2 1/3] x86: allow to suppress port-alias probing Content-Language: en-US From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= References: <0c45155a-2beb-4e69-bca3-cdf42ba22f2b@suse.com> Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: <0c45155a-2beb-4e69-bca3-cdf42ba22f2b@suse.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1702910873863100001 By default there's already no use for this when we run in shim mode. Plus there may also be a need to suppress the probing in case of issues with it. Before introducing further port alias probing, introduce a command line option allowing to bypass it, default it to on when in shim mode, and gate RTC/CMOS port alias probing on it. Requested-by: Roger Pau Monn=C3=A9 Signed-off-by: Jan Beulich Reviewed-by: Jason Andryuk --- While "probe-port-aliases" is longish, shorter forms (e.g. "port-probe") partially lose the intended meaning. --- v2: New. --- a/docs/misc/xen-command-line.pandoc +++ b/docs/misc/xen-command-line.pandoc @@ -2000,6 +2000,17 @@ INVPCID is supported and not disabled vi This is a mask of C-states which are to be used preferably. This option is applicable only on hardware were certain C-states are exclusive of one ano= ther. =20 +### probe-port-aliases (x86) +> `=3D ` + +> Default: `true` outside of shim mode, `false` in shim mode + +Certain devices accessible by I/O ports may be accessible also through "al= ias" +ports (originally a result of incomplete address decoding). When such dev= ices +are solely under Xen's control, Xen disallows even Dom0 access to the "pri= mary" +ports. When alias probing is active and aliases are detected, "alias" por= ts +would then be treated similar to the "primary" ones. + ### psr (Intel) > `=3D List of ( cmt: | rmid_max: | cat: | cos_= max: | cdp: )` =20 --- a/xen/arch/x86/include/asm/setup.h +++ b/xen/arch/x86/include/asm/setup.h @@ -47,6 +47,7 @@ extern unsigned long highmem_start; #endif =20 extern int8_t opt_smt; +extern int8_t opt_probe_port_aliases; =20 #ifdef CONFIG_SHADOW_PAGING extern bool opt_dom0_shadow; --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -75,6 +75,9 @@ static bool __initdata opt_invpcid =3D tru boolean_param("invpcid", opt_invpcid); bool __read_mostly use_invpcid; =20 +int8_t __initdata opt_probe_port_aliases =3D -1; +boolean_param("probe-port-aliases", opt_probe_port_aliases); + /* Only used in asm code and within this source file */ unsigned long asmlinkage __read_mostly cr4_pv32_mask; =20 @@ -1844,6 +1847,9 @@ void asmlinkage __init noreturn __start_ /* Low mappings were only needed for some BIOS table parsing. */ zap_low_mappings(); =20 + if ( opt_probe_port_aliases < 0 ) + opt_probe_port_aliases =3D !pv_shim; + init_apic_mappings(); =20 normalise_cpu_order(); --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -1253,7 +1253,8 @@ static int __init cf_check probe_cmos_al { unsigned int offs; =20 - if ( acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_CMOS_RTC ) + if ( (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_CMOS_RTC) || + !opt_probe_port_aliases ) return 0; =20 for ( offs =3D 2; offs < 8; offs <<=3D 1 ) From nobody Fri May 17 06:07:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1702910904; cv=none; d=zohomail.com; s=zohoarc; b=h6nygwBORdYmoPPGUxH8FsNivR/GyMGZGqRJMt8Hhi9XW5rIyhk1wU0r48LcMiKTTXgO/IiJVilNlAAGa1XNnL+YXTFsgLKkzfK6FT6OZarN9x+XK81tgkBEemZrByujZkUM+Ht3Hj509YM8uk7MkiUIikKzsk8S8x/iDBKFDmI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702910904; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=LjS7V6KKmRJM6g/C5tVk+zV0y+JdDW9hCdqYHqXgGAA=; b=BgdXl+Mzfz5BEBJ+InVLfNjMxQajzb3TYn0gHCJwFHOIFhxdIatOs3jFPeBKQfqawpuDwsvK7bbX2jvd8zahnYYh1xfrcNQbPFqjl/OM5g7xOUL8W8aLsaflSDRF36EG3mY4oKKlmWHe8SQDCFXssox6aVwlS/khnU//P/mVfSA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1702910904961146.8849045400483; Mon, 18 Dec 2023 06:48:24 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.656096.1024074 (Exim 4.92) (envelope-from ) id 1rFEue-0007rr-Mw; Mon, 18 Dec 2023 14:48:08 +0000 Received: by outflank-mailman (output) from mailman id 656096.1024074; Mon, 18 Dec 2023 14:48:08 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rFEue-0007rk-K7; Mon, 18 Dec 2023 14:48:08 +0000 Received: by outflank-mailman (input) for mailman id 656096; Mon, 18 Dec 2023 14:48:07 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rFEud-0007qP-BB for xen-devel@lists.xenproject.org; Mon, 18 Dec 2023 14:48:07 +0000 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [2a00:1450:4864:20::435]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 73f7efaa-9db4-11ee-98eb-6d05b1d4d9a1; Mon, 18 Dec 2023 15:48:06 +0100 (CET) Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-33662243274so779396f8f.1 for ; Mon, 18 Dec 2023 06:48:06 -0800 (PST) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id j29-20020a5d6e5d000000b003364e437577sm10175351wrz.84.2023.12.18.06.48.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 18 Dec 2023 06:48:05 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version 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" X-Inumbo-ID: 73f7efaa-9db4-11ee-98eb-6d05b1d4d9a1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1702910885; x=1703515685; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=LjS7V6KKmRJM6g/C5tVk+zV0y+JdDW9hCdqYHqXgGAA=; b=FbYzuQUIIHvdA3CGkCns8uLTNiPTowQFyqbOBLCm/jxcXmbYDku8kbQfeTAqPoqtME vJQDJWu6d7L2XesjaUoTktbscpPmtPCkrDdpo+vh3cqRQnNRY2iQnqIZlA6DOTZMVWQZ oR4/f8vzEpkY3prt7LJdd8s9cvR/gtEpvuoFeCQRP8WbujOfa5ffzH1ATi81tpK5RqvC y91qHHf95v2Cgo5JP48o4/nvqYXvTehFYzOuD391IJ3dMTBLONe1piu0qGdPr1Rx+QO4 +OBcw7htrZ3YoTH10S9QCbDE3BUA9vwyV9M229Wpm4zxbcxdbVNSfuPIOwMEAQXMy5Ml B1Qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702910885; x=1703515685; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=LjS7V6KKmRJM6g/C5tVk+zV0y+JdDW9hCdqYHqXgGAA=; b=OjFilTTFjqKOwqGiaQLnXYPtTabxXUMNd0pkpmQzYHIPwIXonq6HRH6E7EAexIAB/q 68bkpNjdVTMv+yztdZABK63m+75KP0WXPXdPTpr6Ofx0hjmAbFaGl4lj5SYPGN6fs6II KLJQc2UkXQsDV+0ckEZtqfShxFIJcyAZsZD1m5McZ9bEtqcvuJjkUjzvAPtJiyoqYC42 dGzQpLSryb5udjFkZoq2L8Wco4/pHjCx+8gjacyNMa3jcEJAtjzYtI/K8L4/gIkz6tYM q0NsmOY+6kAN4Ao+IKkq1mI5r8c9IQBP9riypIDPqOFA+V/2786yrtHSpln21FZgJfxx 7pxg== X-Gm-Message-State: AOJu0YxF74i+LfVwHT4KzFIFPpVkrpXHAGsIpRVXf9JbaZujpFCKoakW pCx/Vx88rmQEWf7QdtoG6lE8KydkvylZ06p1JgcN X-Google-Smtp-Source: AGHT+IFTEIXHMTkzeOPQVN+hq1bcbwiIh1yeEabfPyUbLyuJEBXjuuc0f/sxATGC1mw+eCEKiIWZEw== X-Received: by 2002:a05:600c:46c3:b0:40c:6e98:7c50 with SMTP id q3-20020a05600c46c300b0040c6e987c50mr2713037wmo.165.1702910885553; Mon, 18 Dec 2023 06:48:05 -0800 (PST) Message-ID: Date: Mon, 18 Dec 2023 15:48:05 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH v2 2/3] x86: detect PIC aliasing on ports other than 0x[2A][01] Content-Language: en-US From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= References: <0c45155a-2beb-4e69-bca3-cdf42ba22f2b@suse.com> Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: <0c45155a-2beb-4e69-bca3-cdf42ba22f2b@suse.com> Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1702910905840100001 Content-Type: text/plain; charset="utf-8" ... in order to also deny Dom0 access through the alias ports. Without this it is only giving the impression of denying access to both PICs. Unlike for CMOS/RTC, do detection very early, to avoid disturbing normal operation later on. Like for CMOS/RTC a fundamental assumption of the probing is that reads from the probed alias port won't have side effects in case it does not alias the respective PIC's one. Signed-off-by: Jan Beulich Reviewed-by: Jason Andryuk --- v2: Use new command line option. s/pic/8252A/. Re-base over new earlier patch. Use ISOLATE_LSB(). --- a/xen/arch/x86/dom0_build.c +++ b/xen/arch/x86/dom0_build.c @@ -467,7 +467,7 @@ static void __init process_dom0_ioports_ int __init dom0_setup_permissions(struct domain *d) { unsigned long mfn; - unsigned int i; + unsigned int i, offs; int rc; =20 if ( pv_shim ) @@ -480,10 +480,16 @@ int __init dom0_setup_permissions(struct =20 /* Modify I/O port access permissions. */ =20 - /* Master Interrupt Controller (PIC). */ - rc |=3D ioports_deny_access(d, 0x20, 0x21); - /* Slave Interrupt Controller (PIC). */ - rc |=3D ioports_deny_access(d, 0xA0, 0xA1); + for ( offs =3D 0, i =3D ISOLATE_LSB(i8259A_alias_mask) ?: 2; + offs <=3D i8259A_alias_mask; offs +=3D i ) + { + if ( offs & ~i8259A_alias_mask ) + continue; + /* Master Interrupt Controller (PIC). */ + rc |=3D ioports_deny_access(d, 0x20 + offs, 0x21 + offs); + /* Slave Interrupt Controller (PIC). */ + rc |=3D ioports_deny_access(d, 0xA0 + offs, 0xA1 + offs); + } =20 /* ELCR of both PICs. */ rc |=3D ioports_deny_access(d, 0x4D0, 0x4D1); --- a/xen/arch/x86/i8259.c +++ b/xen/arch/x86/i8259.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include =20 @@ -333,6 +334,58 @@ void __init make_8259A_irq(unsigned int irq_to_desc(irq)->handler =3D &i8259A_irq_type; } =20 +unsigned int __initdata i8259A_alias_mask; + +static void __init probe_8259A_alias(void) +{ + unsigned int mask =3D 0x1e; + uint8_t val =3D 0; + + if ( !opt_probe_port_aliases ) + return; + + /* + * The only properly r/w register is OCW1. While keeping the master + * fully masked (thus also masking anything coming through the slave), + * write all possible 256 values to the slave's base port, and check + * whether the same value can then be read back through any of the + * possible alias ports. Probing just the slave of course builds on t= he + * assumption that aliasing is identical for master and slave. + */ + + outb(0xff, 0x21); /* Fully mask master. */ + + do { + unsigned int offs; + + outb(val, 0xa1); + + /* Try to make sure we're actually having a PIC here. */ + if ( inb(0xa1) !=3D val ) + { + mask =3D 0; + break; + } + + for ( offs =3D ISOLATE_LSB(mask); offs <=3D mask; offs <<=3D 1 ) + { + if ( !(mask & offs) ) + continue; + if ( inb(0xa1 + offs) !=3D val ) + mask &=3D ~offs; + } + } while ( mask && (val +=3D 0x0d) ); /* Arbitrary uneven number. */ + + outb(cached_A1, 0xa1); /* Restore slave IRQ mask. */ + outb(cached_21, 0x21); /* Restore master IRQ mask. */ + + if ( mask ) + { + dprintk(XENLOG_INFO, "PIC aliasing mask: %02x\n", mask); + i8259A_alias_mask =3D mask; + } +} + static struct irqaction __read_mostly cascade =3D { no_action, "cascade", = NULL}; =20 void __init init_IRQ(void) @@ -343,6 +396,8 @@ void __init init_IRQ(void) =20 init_8259A(0); =20 + probe_8259A_alias(); + for (irq =3D 0; platform_legacy_irq(irq); irq++) { struct irq_desc *desc =3D irq_to_desc(irq); =20 --- a/xen/arch/x86/include/asm/setup.h +++ b/xen/arch/x86/include/asm/setup.h @@ -46,6 +46,8 @@ extern uint8_t kbd_shift_flags; extern unsigned long highmem_start; #endif =20 +extern unsigned int i8259A_alias_mask; + extern int8_t opt_smt; extern int8_t opt_probe_port_aliases; From nobody Fri May 17 06:07:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1702910928; cv=none; d=zohomail.com; s=zohoarc; b=mzoJC6+iY+kCDu6dYk5oV+mMvSV29iQ/EI5Q+SFORlSMJyZswnho+tXxMPPz3j/DzR5AheS8alKp0vQAKHdTYu7dTVz4ox5Po4liKEonLndy+iGW40ae8AqMnHEnapoE8wI2NCoMXJwQ0WSWgCGtQjuTRh16JhLlKA3MsLdhVv4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702910928; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=fdAJveYHqA2g4CKa3+3oW3cyM7mNTxYeZr4t06ZVD3M=; b=JV2PvaqCYuCFuKDKEULH6tNbx/ZZNKMHAKzJOHgcJYuOLzNRG4l9hhQC1aZaSBvILqX9CtFLi50DQluC/hgTUb92NNOk8BPTu5cZ9/Gw5S9WAQ0ox0Vk6d7yVfPxtpoV/9In+TYoSt5ymo1SVXwWlt93bZGj1jJkGP6D8QpptVo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1702910928157717.208765453013; Mon, 18 Dec 2023 06:48:48 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.656099.1024084 (Exim 4.92) (envelope-from ) id 1rFEv3-0008KX-UK; Mon, 18 Dec 2023 14:48:33 +0000 Received: by outflank-mailman (output) from mailman id 656099.1024084; Mon, 18 Dec 2023 14:48:33 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rFEv3-0008KQ-Rj; Mon, 18 Dec 2023 14:48:33 +0000 Received: by outflank-mailman (input) for mailman id 656099; Mon, 18 Dec 2023 14:48:32 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rFEv2-0007qP-QL for xen-devel@lists.xenproject.org; Mon, 18 Dec 2023 14:48:32 +0000 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [2a00:1450:4864:20::42b]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 83794f5b-9db4-11ee-98eb-6d05b1d4d9a1; Mon, 18 Dec 2023 15:48:32 +0100 (CET) Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-336668a5a8dso1352427f8f.1 for ; Mon, 18 Dec 2023 06:48:32 -0800 (PST) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id j29-20020a5d6e5d000000b003364e437577sm10175351wrz.84.2023.12.18.06.48.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 18 Dec 2023 06:48:31 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version 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" X-Inumbo-ID: 83794f5b-9db4-11ee-98eb-6d05b1d4d9a1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1702910911; x=1703515711; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=fdAJveYHqA2g4CKa3+3oW3cyM7mNTxYeZr4t06ZVD3M=; b=Q/j86XPWaYLHKQRauVym+6lRndWRgfI8qqTdUPFPIn/wJas9mBxMUbOiiCDebpJKcX mwuoXou8c68OVtBB0emsmonX0tt+YSLVQOSmxuARXAU6h6I/MIl6pJmvYA3SPP57AIbq u4riZHKShXFfUFwisjR840MczpziBdFMyWZ1Hta0DgKUtHDoUbR7ReN4AxOooS3WjWTU Cf4cKKQUXClFSOieq1ytslMK7kjtNp9NGeYBhFmmzWv6RaDV7G45KiFcQnRrPpBpf+E9 x03To/tzMnrnm3SjgoYW/BH1QnLScEuwEFAvdepMsBisKsV3SGSrib7IDlc6DukEsyyG 4cww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702910911; x=1703515711; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=fdAJveYHqA2g4CKa3+3oW3cyM7mNTxYeZr4t06ZVD3M=; b=i6KLnbGjxhElRyr8IgfO+ViMUWfa0CrpN78y7wJjGoauHKUyGaIw2oNRf9OUgOGJTp iDGeedSSYIpEjT491rkZxalU7LXBdn86RPzL3Z/4R43IvuJQgSrpdXJk2knHSWdvJUIY Qaqs+Cjccca3jmpV58FHb9jc4iCZkI3CKejAYT1yT07K23VBCLi0SDhV6y+l13o99k+x a+Xu30fwpA75E103EhNwSo7xIPcgQLMksI1F96hOZN91MTerrke5qTBQAZwiNnXtdrLc WfU0hQ0BwgmgWL9aq5CCGzSMIZjgy5Qc7YtA8J+gpeEl1ECA0f+ix4P0t1fZABYP5bUm WIFQ== X-Gm-Message-State: AOJu0Yz3O6g1l7gnxGvgWjN2NE9VOI3nBzMwmkMLPhV3REsh0AfrUXFy n0ZHEaFLkcUjFZ3FbclqhkiC0t3SEJuOCqbiWyrY X-Google-Smtp-Source: AGHT+IEcRm1OlYQRw4waYkgXv26JzJWDtoeZ7XB0p/wpHi2fh7f4AW0IzQg5clA/hSFMznmjF6/EAA== X-Received: by 2002:a05:6000:1201:b0:336:4e26:f7e5 with SMTP id e1-20020a056000120100b003364e26f7e5mr3068903wrx.110.1702910911614; Mon, 18 Dec 2023 06:48:31 -0800 (PST) Message-ID: <039b9ceb-4862-4e26-a344-e47fc04bd979@suse.com> Date: Mon, 18 Dec 2023 15:48:31 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH v2 3/3] x86: detect PIT aliasing on ports other than 0x4[0-3] Content-Language: en-US From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= References: <0c45155a-2beb-4e69-bca3-cdf42ba22f2b@suse.com> Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: <0c45155a-2beb-4e69-bca3-cdf42ba22f2b@suse.com> Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1702910929943100001 Content-Type: text/plain; charset="utf-8" ... in order to also deny Dom0 access through the alias ports. Without this it is only giving the impression of denying access to PIT. Unlike for CMOS/RTC, do detection pretty early, to avoid disturbing normal operation later on (even if typically we won't use much of the PIT). Like for CMOS/RTC a fundamental assumption of the probing is that reads from the probed alias port won't have side effects (beyond such that PIT reads have anyway) in case it does not alias the PIT's. At to the port 0x61 accesses: Unlike other accesses we do, this masks off the top four bits (in addition to the bottom two ones), following Intel chipset documentation saying that these (read-only) bits should only be written with zero. Signed-off-by: Jan Beulich --- If Xen was running on top of another instance of itself (in HVM mode, not PVH, i.e. not as a shim), prior to 14f42af3f52d ('x86/vPIT: account for "counter stopped" time') I'm afraid our vPIT logic would not have allowed the "Try to further make sure ..." check to pass in the Xen running on top: We don't respect the gate bit being clear when handling counter reads. (There are more unhandled [and unmentioned as being so] aspects of PIT behavior though, yet it's unclear in how far addressing at least some of them would be useful.) --- v2: Use new command line option. Re-base over changes to earlier patches. Use ISOLATE_LSB(). --- a/xen/arch/x86/dom0_build.c +++ b/xen/arch/x86/dom0_build.c @@ -495,7 +495,11 @@ int __init dom0_setup_permissions(struct rc |=3D ioports_deny_access(d, 0x4D0, 0x4D1); =20 /* Interval Timer (PIT). */ - rc |=3D ioports_deny_access(d, 0x40, 0x43); + for ( offs =3D 0, i =3D ISOLATE_LSB(pit_alias_mask) ?: 4; + offs <=3D pit_alias_mask; offs +=3D i ) + if ( !(offs & ~pit_alias_mask) ) + rc |=3D ioports_deny_access(d, 0x40 + offs, 0x43 + offs); + /* PIT Channel 2 / PC Speaker Control. */ rc |=3D ioports_deny_access(d, 0x61, 0x61); =20 --- a/xen/arch/x86/include/asm/setup.h +++ b/xen/arch/x86/include/asm/setup.h @@ -47,6 +47,7 @@ extern unsigned long highmem_start; #endif =20 extern unsigned int i8259A_alias_mask; +extern unsigned int pit_alias_mask; =20 extern int8_t opt_smt; extern int8_t opt_probe_port_aliases; --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -425,6 +425,72 @@ static struct platform_timesource __init .resume =3D resume_pit, }; =20 +unsigned int __initdata pit_alias_mask; + +static void __init probe_pit_alias(void) +{ + unsigned int mask =3D 0x1c; + uint8_t val =3D 0; + + if ( !opt_probe_port_aliases ) + return; + + /* + * Use channel 2 in mode 0 for probing. In this mode even a non-initi= al + * count is loaded independent of counting being / becoming enabled. = Thus + * we have a 16-bit value fully under our control, to write and then c= heck + * whether we can also read it back unaltered. + */ + + /* Turn off speaker output and disable channel 2 counting. */ + outb(inb(0x61) & 0x0c, 0x61); + + outb((2 << 6) | (3 << 4) | (0 << 1), PIT_MODE); /* Mode 0, LSB/MSB. */ + + do { + uint8_t val2; + unsigned int offs; + + outb(val, PIT_CH2); + outb(val ^ 0xff, PIT_CH2); + + /* Wait for the Null Count bit to clear. */ + do { + /* Latch status. */ + outb((3 << 6) | (1 << 5) | (1 << 3), PIT_MODE); + + /* Try to make sure we're actually having a PIT here. */ + val2 =3D inb(PIT_CH2); + if ( (val2 & ~(3 << 6)) !=3D ((3 << 4) | (0 << 1)) ) + return; + } while ( val2 & (1 << 6) ); + + /* + * Try to further make sure we're actually having a PIT here. + * + * NB: Deliberately |, not ||, as we always want both reads. + */ + val2 =3D inb(PIT_CH2); + if ( (val2 ^ val) | (inb(PIT_CH2) ^ val ^ 0xff) ) + return; + + for ( offs =3D ISOLATE_LSB(mask); offs <=3D mask; offs <<=3D 1 ) + { + if ( !(mask & offs) ) + continue; + val2 =3D inb(PIT_CH2 + offs); + if ( (val2 ^ val) | (inb(PIT_CH2 + offs) ^ val ^ 0xff) ) + mask &=3D ~offs; + } + } while ( mask && (val +=3D 0x0b) ); /* Arbitrary uneven number. */ + + if ( mask ) + { + dprintk(XENLOG_INFO, "PIT aliasing mask: %02x\n", mask); + pit_alias_mask =3D mask; + } +} + /************************************************************ * PLATFORM TIMER 2: HIGH PRECISION EVENT TIMER (HPET) */ @@ -2414,6 +2480,8 @@ void __init early_time_init(void) } =20 preinit_pit(); + probe_pit_alias(); + tmp =3D init_platform_timer(); plt_tsc.frequency =3D tmp;