From patchwork Sat Jan 21 21:35:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ashok Raj X-Patchwork-Id: 46888 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp887995wrn; Sat, 21 Jan 2023 13:37:27 -0800 (PST) X-Google-Smtp-Source: AMrXdXuE1K/AUYd0H102aAEscTO+/mhFQ/WhygWYJ98KE7BIpCajurURFokEPxgP5vzvcyzLuGDO X-Received: by 2002:a05:6a00:1887:b0:58c:b0a:e504 with SMTP id x7-20020a056a00188700b0058c0b0ae504mr27385053pfh.18.1674337047297; Sat, 21 Jan 2023 13:37:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674337047; cv=none; d=google.com; s=arc-20160816; b=fjqpyL0iQjkiIgNhBtcAI6KqaMxjJymNbTbdClgV5ktIoKwPK2kNVtLxLlgQlGnlDi eO3Oz3S6h2NERNZfB/9Hn1jt6494xvO1/9wow0+GIIl+VFu0JmNP491FPB5DXWpt42K9 tonzP/NIq3fjJw5VXLnlGSY9hcPCfuNvqvvQHqGBpB6S75FTC5v/ybuYOgIFp1QRPJoi f/mT2aXv6j/Ge9fkSP7L02qbJVaOwlu1DPoq5K7IG7+HQ3jxdlRkUwZdpnpOhL4/hDUV 6CRKA+cS9hIYXa4EeKlAL1mU9haAA/dC/rTWK0+ZLZrib2W93zSpBvpXLu79zd8QZB1f PDUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=TX4IBgpOxu5zTgv0JjYNtlPaJO25OFfzgjlxwm6GkW4=; b=LFLxUIbNpJVA6WdMVEPRhv4Z0l7t0pEW+/oaYD+bYulgloO7xDQBI6Iz2DxoMElBTQ rz2iBUWUP9NiaLSJdtK5usK3RGdcXgA3gEPyaP18H/4mXuYHl4IM1FJxackV2WKf1DgA 7wwE2HbQ+BoVAWtksy3LfalLyyhvi/TIfJJdbts3nAFf0QyhKyEkBAgsZeVcH/kWTlOQ ohmxacRLgE25/6At8cLbZ/WqP7IT4p6gZADHUS1q+OwATeu03ankefLqlxUeGBVclygF gWK8syQEPVIr8VVHyFofVHQHLshseidtJqXT0yg3rg4+ZhHO3sJRVwUrhj1XDxayh9wH v54Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=kVpRG872; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f2-20020a056a0022c200b0058bc7462962si26160202pfj.80.2023.01.21.13.37.15; Sat, 21 Jan 2023 13:37:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=kVpRG872; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229841AbjAUVfa (ORCPT + 99 others); Sat, 21 Jan 2023 16:35:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229814AbjAUVfZ (ORCPT ); Sat, 21 Jan 2023 16:35:25 -0500 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86CA723DA1 for ; Sat, 21 Jan 2023 13:35:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1674336924; x=1705872924; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=U7lNHeyeMGQVevEMDm/Srbh6wwfqpxVEAKNnbxAm03o=; b=kVpRG872jpQcz4m3cRh4WeVW7ZDoC8GojixXb8CEjN+D2uS9CcqMMcuP +D1VEsVAV2EEjfPam79nXd3L9p8VngdjViTQCtoSNhS5agoMNg3aY+c6B VFHzcFqvCyFkn021SpsoL1KNtA0qQMMLHkr4yJccXhiHlR2/w/OpmjlMT 9S4ttwdAAHdexXuFQsLPGshnjZRiM3SxgZ3W5wcsMgQszv2sT2vsKaUGP 34B1btdGPz0ndPjSoxTggRPAoxJBdgkfCDKg7z0Ol4hdc5sAShjq6zA2k m2bMvoyxSx/nNxAXnLDU/vXxFjicKvxYI/kuVFq2CVVChmrByQrYuQcXF w==; X-IronPort-AV: E=McAfee;i="6500,9779,10597"; a="412066320" X-IronPort-AV: E=Sophos;i="5.97,235,1669104000"; d="scan'208";a="412066320" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jan 2023 13:35:22 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10597"; a="784946313" X-IronPort-AV: E=Sophos;i="5.97,235,1669104000"; d="scan'208";a="784946313" Received: from araj-ucode.jf.intel.com ([10.23.0.19]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jan 2023 13:35:21 -0800 From: Ashok Raj To: Thomas Gleixner , Borislav Petkov Cc: Ashok Raj , LKML , x86 , Ingo Molnar , Tony Luck , Dave Hansen , Alison Schofield , Reinette Chatre , Tom Lendacky , Stefan Talpalaru , David Woodhouse , Benjamin Herrenschmidt , Jonathan Corbet , "Rafael J . Wysocki" , Peter Zilstra , Andy Lutomirski , Andrew Cooper , Boris Ostrovsky , Martin Pohlack Subject: [Part 2 v2[cleanup] 2/4] x86/microcode: Report invalid writes to reload sysfs file Date: Sat, 21 Jan 2023 13:35:10 -0800 Message-Id: <20230121213512.251578-3-ashok.raj@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230121213512.251578-1-ashok.raj@intel.com> References: <87y1pygiyf.ffs@tglx> <20230121213512.251578-1-ashok.raj@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755669643822003968?= X-GMAIL-MSGID: =?utf-8?q?1755669643822003968?= Currently microcode reload sysfs file only accepts a value of 1. But when user writes other values we don't report error, but just treat them as silent success without performing a load. Report those erroneous writes back to user. Suggested-by: Thomas Gleixner Signed-off-by: Ashok Raj Cc: LKML Cc: x86 Cc: Ingo Molnar Cc: Tony Luck Cc: Dave Hansen Cc: Alison Schofield Cc: Reinette Chatre Cc: Thomas Gleixner (Intel) Cc: Tom Lendacky Cc: Stefan Talpalaru Cc: David Woodhouse Cc: Benjamin Herrenschmidt Cc: Jonathan Corbet Cc: Rafael J. Wysocki Cc: Peter Zilstra (Intel) Cc: Andy Lutomirski Cc: Andrew Cooper Cc: Boris Ostrovsky Cc: Martin Pohlack --- arch/x86/kernel/cpu/microcode/core.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c index c5d80ff00b4e..6ade3d59c404 100644 --- a/arch/x86/kernel/cpu/microcode/core.c +++ b/arch/x86/kernel/cpu/microcode/core.c @@ -479,11 +479,8 @@ static ssize_t reload_store(struct device *dev, ssize_t ret = 0; ret = kstrtoul(buf, 0, &val); - if (ret) - return ret; - - if (val != 1) - return size; + if (ret || val != 1) + return -EINVAL; cpus_read_lock();