[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 1/2] x86/time: use fake read_tsc()


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 1 Mar 2022 12:05:47 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • 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=yVhh9raFqY1k1mmmz8RZiJfkzqL7jHEKprsJSfJ+qW8=; b=jWCBziFs9DYO4cOpBFWd56R5GdRyQDRW0Ktv1A7qpK25XnhBlHOPKPbo6GKtL0giyHF6jjVmKngksQnWxvS+mOY1ocbO7j39TKlihvpQDs23SKJkW3RAFAW/gJORS4iW4umlQ+MDLF5yEjBvGOYWks+VoOEhIODaOJTPCssLnIqt8WZP3p/2q+/PLG8wnnnDZa84KvMwk7CDmTN3WfAehU7b72mZorgSxwAN8RZb9WsqDj2CRxydXwx7y3Bsrp4tjx3xc+z8Bafkc43K5oj5tbvxMs41pKid5EN/Sdf2iPQ2ZGuGTHwIZEssPeBrJicOg46O7yaDlCOeIbbMS1dNSw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZRdmnOnjSJ2Uvo98Tm4jPYGnspuBqOptTwVzWy63A5oEvqHELWgEHrrBuhhH26TOBO5dYNO56E6XVoW1n+l4Ovkp93471Y7WgMtI2vlYfySZOk2oZiQSZtohFjNMvxZYUhXiTaGI9AeZ5EqQeowoAzhX5TAm8/eax3C0pq3QRPGULmBS2okUxcZD0/pFZjjCPUK54HnMkNF0ABwMqYsA4Gizai7yPoACVHYE2VpyCpwpsZXsAmlZn43Tg2EDeXgXhasKFQUl4x0J+HsKvSHLWHCpIuQC0HpTVdBf/Cu6cvubKZxMPEds8hlSWBbLmhIRWU5HsvUpJV8ULfQlsTwVDQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Tue, 01 Mar 2022 11:05:57 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Go a step further than bed9ae54df44 ("x86/time: switch platform timer
hooks to altcall") did and eliminate the "real" read_tsc() altogether:
It's not used except in pointer comparisons, and hence it looks overall
more safe to simply poison plt_tsc's read_counter hook.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---
I wasn't really sure whether it would be better to use simply void * for
the type of the expression, resulting in an undesirable data -> function
pointer conversion, but making it impossible to mistakenly try and call
the (fake) function directly.

--- a/xen/arch/x86/time.c
+++ b/xen/arch/x86/time.c
@@ -585,10 +585,12 @@ static s64 __init cf_check init_tsc(stru
     return ret;
 }
 
-static uint64_t __init cf_check read_tsc(void)
-{
-    return rdtsc_ordered();
-}
+/*
+ * plt_tsc's read_counter hook is (and should not be) invoked via the struct
+ * field. To avoid carrying an unused, indirectly reachable function, poison
+ * the field with an easily identifiable non-canonical pointer.
+ */
+#define read_tsc ((uint64_t(*)(void))0x75C75C75C75C75C0ul)
 
 static struct platform_timesource __initdata plt_tsc =
 {




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.