Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp39758iof; Wed, 8 Jun 2022 14:42:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwM2bBlmIuYDpdjTg9YfrurU463VSbNmUrMRbrwo8ktW2oUPoCb5vAH0CNIYnTFiK5hAJmV X-Received: by 2002:a17:90a:e642:b0:1e3:524e:4cb with SMTP id ep2-20020a17090ae64200b001e3524e04cbmr48755pjb.114.1654724535846; Wed, 08 Jun 2022 14:42:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654724535; cv=none; d=google.com; s=arc-20160816; b=nfBdPWBqavHWT+90ckCviJhLeH9hyu/JufY2ru1ifDGH1A9kycST6cTcETo1qFCQLN zLQ4Fwi47kpsK9nKjsTKzcvznfSWxoT0Nd0uS95zWLP4UJcONr6gXhGc/kFWJszaQWQR hCa1EofRi8bSutAWaNAHs3hPH7/YXPvLonRIKBXJhoedDBjAkU44pNtjXaaCRCGlITJw KDXeJpTcuM2Q8ku4YNYEbYj1BSCjsGAG9099xtfrUyFDjoy+oWE3+aF3L8HqyTiVrzAD im4hpnC1qhB9h0yHaA3tV76/jHEU4TPfeM6qqVu1taE3rnG9Cp5PWfg/ceeYUXor8qSv ec6Q== 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=1aA75xK9qAQzBCllcUuoOOyNNMGtWcE8UwGkQz93Ka4=; b=WFbSxl4+yrCA5LqhfbojAjAiRmqZZUONH4yU+ez0emyaknFGjr0OCficha6td3zMlU pEaIR5GotFRPHnwpjUhDl8BmYSr9cosmNL/FcVJ0GQlnWmd4YXkDwq6kOpSjpqrryaD9 7MWtUnqNEOEjiFX9SH1k13l7Kz7A8FIkOvxXnMQJ0b8lpYiEO96sSYMNTzrIAL/poovK 95bHrmqtVDwEGR5JdrilmvuQb1RfuiplpWQ3Yghh+F+KBYY5MXF/6S4snW0xAlUp4HwL etb52nfnBs+P1K00l84JfJfk7rBnMYlKuG61lIOkW/lEKoRbHAyRVDprTtX7uPJYLh7M MXSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Tg4iUn7w; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q23-20020a170902b11700b00167895f9696si10072408plr.210.2022.06.08.14.42.03; Wed, 08 Jun 2022 14:42:15 -0700 (PDT) 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=@gmail.com header.s=20210112 header.b=Tg4iUn7w; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236354AbiFHV3i (ORCPT + 99 others); Wed, 8 Jun 2022 17:29:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236293AbiFHV3b (ORCPT ); Wed, 8 Jun 2022 17:29:31 -0400 Received: from mail-oi1-x22b.google.com (mail-oi1-x22b.google.com [IPv6:2607:f8b0:4864:20::22b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05B714833F; Wed, 8 Jun 2022 14:29:25 -0700 (PDT) Received: by mail-oi1-x22b.google.com with SMTP id i66so29669817oia.11; Wed, 08 Jun 2022 14:29:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1aA75xK9qAQzBCllcUuoOOyNNMGtWcE8UwGkQz93Ka4=; b=Tg4iUn7wnvpBYXfPSbIfqDsrMztAR6dttfRp7HkHN+uZvw8azEXrwxXMpKe8cSkFUG n/nBJea3+ZtffFDGpRRxJyfAhEnNJt4X2Jrxd2attlzKUJWbbpDZc9ShjEt6/wSZb6nv Z9E0QHlMx2MvnE1dAqJS0DPJVPGL0nL5A92YPceBIDofdBaXOBfzEec0pThpgKO1HeDZ KDTRXpbPi1C9q0HpTyZke9i5GqAy4NuRgiV3ctU9SwhzWf83uKGluYzVQHUEFiw1UHTQ MIMR/ZryBihwc3kMD7OIVbNfFKdXCMR6oS7PXdIsspE24trmJaQKIC9UlmU2iPng2ogJ k4qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1aA75xK9qAQzBCllcUuoOOyNNMGtWcE8UwGkQz93Ka4=; b=qBCtBD6ZouwZ9/vMtxkUa8hGihGBuO2rTir7iw7UEvEsuwiFCVL0YJJHj+GvqI9wlh TT8TjKEixJttTcu0fe05lRvGa9C7j7SkdIcnN9IGNc2DGet3VGoVZpIRHvCwvpM7Bk2u XuapBziB5yM44Cp6cRj/LZw7fRipwDk6r/dr1SLvIh+Pjt3sydAiKvmv3zN+psjBlfdm UoutaZKRiFZrXYJJtOZ/4ZwuFjTUfaB0s8cD+dvLTL/lQwMK6s79NmSE23Ngcky4SCX7 MxlsB0IRuQguT25qbzjnFjeEK8HORezE0RsKrrN9jSoD8wVFbopfIBkaaraLTuIcgaRd CvFw== X-Gm-Message-State: AOAM533PXjOyBACKQio5q2lzccoKRID5Jq/vqcwVCO33uoEcr3e9a9HF HB4PSp1k/wqlajdN8lxjpqo= X-Received: by 2002:a05:6808:2196:b0:32e:e0b0:fe6c with SMTP id be22-20020a056808219600b0032ee0b0fe6cmr1195889oib.55.1654723765169; Wed, 08 Jun 2022 14:29:25 -0700 (PDT) Received: from grumpy-vm.hsd1.tx.comcast.net ([2601:2c3:480:7390:e5f7:48da:3306:a654]) by smtp.gmail.com with ESMTPSA id g22-20020a9d6c56000000b0060b128b935csm5393971otq.39.2022.06.08.14.29.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 14:29:24 -0700 (PDT) From: Jorge Lopez X-Google-Original-From: Jorge Lopez To: hdegoede@redhat.com, balalic.enver@gmail.com, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Cc: markgross@kernel.org Subject: [PATCH v3 1/1] Resolve WMI query failures on some devices Date: Wed, 8 Jun 2022 16:29:23 -0500 Message-Id: <20220608212923.8585-2-jorge.lopez2@hp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220608212923.8585-1-jorge.lopez2@hp.com> References: <20220608212923.8585-1-jorge.lopez2@hp.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 WMI queries fail on some devices where the ACPI method HWMC unconditionally attempts to create Fields beyond the buffer if the buffer is too small, this breaks essential features such as power profiles: CreateByteField (Arg1, 0x10, D008) CreateByteField (Arg1, 0x11, D009) CreateByteField (Arg1, 0x12, D010) CreateDWordField (Arg1, 0x10, D032) CreateField (Arg1, 0x80, 0x0400, D128) In cases where args->data had zero length, ACPI BIOS Error (bug): AE_AML_BUFFER_LIMIT, Field [D008] at bit offset/length 128/8 exceeds size of target Buffer (128 bits) (20211217/dsopcode-198) was obtained. ACPI BIOS Error (bug): AE_AML_BUFFER_LIMIT, Field [D009] at bit offset/length 136/8 exceeds size of target Buffer (136bits) (20211217/dsopcode-198) The original code created a buffer size of 128 bytes regardless if the WMI call required a smaller buffer or not. This particular behavior occurs in older BIOS and reproduced in OMEN laptops. Newer BIOS handles buffer sizes properly and meets the latest specification requirements. This is the reason why testing with a dynamically allocated buffer did not uncover any failures with the test systems at hand. This patch was tested on several OMEN, Elite, and Zbooks. It was confirmed the patch resolves HPWMI_FAN GET/SET calls in an OMEN Laptop 15-ek0xxx. No problems were reported when testing on several Elite and Zbooks notebooks. Signed-off-by: Jorge Lopez --- Based on the latest platform-drivers-x86.git/for-next --- drivers/platform/x86/hp-wmi.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c index 0e9a25b56e0e..d3540dd62d06 100644 --- a/drivers/platform/x86/hp-wmi.c +++ b/drivers/platform/x86/hp-wmi.c @@ -290,14 +290,16 @@ static int hp_wmi_perform_query(int query, enum hp_wmi_command command, struct bios_return *bios_return; union acpi_object *obj = NULL; struct bios_args *args = NULL; - int mid, actual_outsize, ret; + int mid, actual_insize, actual_outsize; size_t bios_args_size; + int ret; mid = encode_outsize_for_pvsz(outsize); if (WARN_ON(mid < 0)) return mid; - bios_args_size = struct_size(args, data, insize); + actual_insize = max(insize, 128); + bios_args_size = struct_size(args, data, actual_insize); args = kmalloc(bios_args_size, GFP_KERNEL); if (!args) return -ENOMEM; -- 2.25.1