lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <7ad305d4-3acb-1447-bdbe-077c83972978@redhat.com>
Date:   Wed, 12 Jul 2023 16:47:28 +0200
From:   Hans de Goede <hdegoede@...hat.com>
To:     "Luke D. Jones" <luke@...nes.dev>
Cc:     corentin.chary@...il.com, acpi4asus-user@...ts.sourceforge.net,
        platform-driver-x86@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-hwmon@...r.kernel.org, markgross@...nel.org,
        jdelvare@...e.com, linux@...ck-us.net
Subject: Re: [PATCH v2 6/8] platform/x86: asus-wmi: add safety checks to gpu
 switching

Hi,

On 6/30/23 07:35, Luke D. Jones wrote:
> Add safety checking to dgpu_disable, egpu_enable, gpu_mux_mode.
> 
> These checks prevent users from doing such things as:
> - disabling the dGPU while is muxed to drive the internal screen
> - enabling the eGPU which also disables the dGPU, while muxed to
>   the internal screen
> - switching the MUX to dGPU while the dGPU is disabled
> 
> Signed-off-by: Luke D. Jones <luke@...nes.dev>
> ---
>  drivers/platform/x86/asus-wmi.c | 50 ++++++++++++++++++++++++++++++++-
>  1 file changed, 49 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
> index 821addb284d7..602426a7fb41 100644
> --- a/drivers/platform/x86/asus-wmi.c
> +++ b/drivers/platform/x86/asus-wmi.c
> @@ -645,6 +645,18 @@ static ssize_t dgpu_disable_store(struct device *dev,
>  	if (disable > 1)
>  		return -EINVAL;
>  
> +	if (asus->gpu_mux_mode_available) {
> +		result = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_GPU_MUX);
> +		if (result < 0)
> +			/* An error here may signal greater failure of GPU handling */
> +			return result;
> +		if (!result && disable) {
> +			err = -ENODEV;
> +			pr_warn("Can not disable dGPU when the MUX is in dGPU mode: %d\n", err);
> +			return err;
> +		}
> +	}
> +
>  	err = asus_wmi_set_devstate(ASUS_WMI_DEVID_DGPU, disable, &result);
>  	if (err) {
>  		pr_warn("Failed to set dgpu disable: %d\n", err);
> @@ -693,7 +705,7 @@ static ssize_t egpu_enable_store(struct device *dev,
>  	if (enable > 1)
>  		return -EINVAL;
>  
> -	err = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_EGPU_CONNECTED);
> +	result = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_EGPU_CONNECTED);
>  	if (err < 0)
>  		return err;
>  	if (err < 1) {

This seems like a stray and undesired change. I'll drop this err -> result change
when merging this.

Otherwise looks good to me:

Reviewed-by: Hans de Goede <hdegoede@...hat.com>

Regards,

Hans





> @@ -702,6 +714,18 @@ static ssize_t egpu_enable_store(struct device *dev,
>  		return err;
>  	}
>  
> +	if (asus->gpu_mux_mode_available) {
> +		result = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_GPU_MUX);
> +		if (result < 0)
> +			/* An error here may signal greater failure of GPU handling */
> +			return result;
> +		if (!result && enable) {
> +			err = -ENODEV;
> +			pr_warn("Can not enable eGPU when the MUX is in dGPU mode: %d\n", err);
> +			return err;
> +		}
> +	}
> +
>  	err = asus_wmi_set_devstate(ASUS_WMI_DEVID_EGPU, enable, &result);
>  	if (err) {
>  		pr_warn("Failed to set egpu disable: %d\n", err);
> @@ -764,6 +788,30 @@ static ssize_t gpu_mux_mode_store(struct device *dev,
>  	if (optimus > 1)
>  		return -EINVAL;
>  
> +	if (asus->dgpu_disable_available) {
> +		result = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_DGPU);
> +		if (result < 0)
> +			/* An error here may signal greater failure of GPU handling */
> +			return result;
> +		if (result && !optimus) {
> +			err = -ENODEV;
> +			pr_warn("Can not switch MUX to dGPU mode when dGPU is disabled: %d\n", err);
> +			return err;
> +		}
> +	}
> +
> +	if (asus->egpu_enable_available) {
> +		result = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_EGPU);
> +		if (result < 0)
> +			/* An error here may signal greater failure of GPU handling */
> +			return result;
> +		if (result && !optimus) {
> +			err = -ENODEV;
> +			pr_warn("Can not switch MUX to dGPU mode when eGPU is enabled: %d\n", err);
> +			return err;
> +		}
> +	}
> +
>  	err = asus_wmi_set_devstate(ASUS_WMI_DEVID_GPU_MUX, optimus, &result);
>  	if (err) {
>  		dev_err(dev, "Failed to set GPU MUX mode: %d\n", err);

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ