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=-8.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 47849C4363A for ; Tue, 20 Oct 2020 17:47:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C804C22244 for ; Tue, 20 Oct 2020 17:47:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alien8.de header.i=@alien8.de header.b="dO0GaT60" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403909AbgJTRry (ORCPT ); Tue, 20 Oct 2020 13:47:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403854AbgJTRrx (ORCPT ); Tue, 20 Oct 2020 13:47:53 -0400 Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B1E9C0613CE for ; Tue, 20 Oct 2020 10:47:53 -0700 (PDT) Received: from zn.tnic (p200300ec2f1066001385d15f8339d059.dip0.t-ipconnect.de [IPv6:2003:ec:2f10:6600:1385:d15f:8339:d059]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 69AA51EC0286; Tue, 20 Oct 2020 19:47:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1603216071; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=jZY0cP9e2uOaVRaW2NKgi/EPOgHDQnS8s+rRzP+9cgU=; b=dO0GaT60tCuh0cqDjMBSpR++P64Cz8btck6Bv47g8wDgewa5NY7D+/4JYduqSxV3T8Jv/3 Gd9ljUNL5tgYyVr9O5Cwpqi77bR67FguipY3SfCqerI5YbhoncvgDNKBYtEiDGGEHMXcST KBoJagVdWpjhR5S+dqvpH+zVU0aSpZ4= Date: Tue, 20 Oct 2020 19:47:41 +0200 From: Borislav Petkov To: Srinivas Pandruvada Cc: Sultan Alsawaf , "Jason A. Donenfeld" , kitsunyan , "Brown, Len" , X86 ML , LKML , Linus Torvalds Subject: Re: [PATCH] x86/msr: do not warn on writes to OC_MAILBOX Message-ID: <20201020174741.GJ11583@zn.tnic> References: <20200908172558.GG25236@zn.tnic> <20200908173656.GI25236@zn.tnic> <20200908180112.GK25236@zn.tnic> <20200908191838.GA2014@sultan-box.localdomain> <20200908193029.GM25236@zn.tnic> <20201019171539.GF24325@zn.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 20, 2020 at 10:21:48AM -0700, Srinivas Pandruvada wrote: > These command id are model specific. There is no guarantee that even > meaning changes. So I don't think we should write any code in kernel > which can't stick. Ok, is there a common *set* of values present on all models? A common set which we can abstract out from the MSR and have userspace write them into sysfs and the kernel does the model-specific write? The sysfs interface should simply provide the functionality, like, for example say: "we have X valid undervolt indices, choose one". Userspace doesn't have to deal with *how* that write happens and which bits need to be set in the MSR and depend on the model - that's all abstracted away by the kernel. All userspace needs to care about is *what* it wants done to the hw. The *how exactly* is done by the kernel. And then the differences are done with x86 model tests. Does that make more sense? > May be something like this: > - Separate mailbox stuff from intel_turbo_max_3.c Yah, that makes sense. > - Create a standalone module which creates a debugfs interface > - This debugs interface takes one 64 bit value from user space and use > protocol to avoid contention We can't make debugfs an API - debugfs can change at any point in time. If you want an API, you put it in sysfs or in a separate fs. > - Warns users on writes via new interfaces you suggested above > > #define MSR_ADDR_TEMPERATURE 0x1a2 > Need to check use case for undervolt. throttled uses it too. I asked them today to talk to us to design a proper interface which satisfies their needs: https://github.com/erpalma/throttled/issues/215 > > #define MSR_ADDR_UNITS 0x606 > Why not reuse powercap rapl interface. That interface will take care of > units. Sure. Btw, you should have a look at those tools - they all poke at all kinds of MSRs and correcting that is like a whack-a-mole game... ;-\ Oh, and the kernel pokes at them too so imagine the surprise one would have when some kernel driver like drivers/thermal/intel/int340x_thermal/processor_thermal_device.c went and read some MSRs and then all of a sudden they changed because some userspace daemon wrote them underneath it. Not good. Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette