From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.linutronix.de (193.142.43.55:993) by crypto-ml.lab.linutronix.de with IMAP4-SSL for ; 07 Oct 2019 18:41:17 -0000 Received: from mga09.intel.com ([134.134.136.24]) by Galois.linutronix.de with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1iHXwZ-0002cZ-IL for speck@linutronix.de; Mon, 07 Oct 2019 20:41:16 +0200 Date: Mon, 7 Oct 2019 11:35:25 -0700 From: Pawan Gupta Subject: [MODERATED] Re: [PATCH v5 09/11] TAAv5 9 Message-ID: <20191007183525.GC5154@guptapadev.amr> References: <5d983ad2.1c69fb81.63edd.6575SMTPIN_ADDED_BROKEN@mx.google.com> MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit To: speck@linutronix.de List-ID: > > +static void tsx_update_this_cpu(void *arg) > > +{ > > + struct cpuinfo_x86 *c = &cpu_data(smp_processor_id()); > > + unsigned long enable = (unsigned long)arg; > > + > > + if (enable) { > > + tsx_enable(); > > + set_cpu_cap(c, X86_FEATURE_RTM); > > + setup_force_cpu_cap(X86_FEATURE_RTM); > > + } else { > > + tsx_disable(); > > + clear_cpu_cap(c, X86_FEATURE_RTM); > > + setup_clear_cpu_cap(X86_FEATURE_RTM); > > + } > > +} > > You can't use these setup_... functions after boot like this. Also, I'm > not sure you can safely even set_cpu_cap(...) after boot. The only reason they are there is because guests started after changing the TSX state from sysfs don't get the correct X86_FEATURE_RTM(with qemu option "-cpu host") . Perhaps there needs to be a fix in qemu/KVM to read the cpuid and export the correct X86_FEATURE_RTM bit. > > > + > > +static void tsx_update_on_each_cpu(bool val) > > +{ > > + get_online_cpus(); > > + on_each_cpu(tsx_update_this_cpu, (void *)val, 1); > > + put_online_cpus(); > > I sure hope that on_each_cpu() is sensible enough to automatically do > the get_online_cpus() thing. Is it not? I dont see cpu_hotplug_lock being taken by on_each_cpu(), which get_online_cpus() does. This prevents cpus to go down/up when we are writing to MSR. Thanks, Pawan