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] [day] [month] [year] [list]
Date:	Mon, 11 May 2015 20:26:15 +1000 (AEST)
From:	Michael Ellerman <mpe@...erman.id.au>
To:	Sukadev Bhattiprolu <sukadev@...ux.vnet.ibm.com>,
	Paul Mackerras <paulus@...ba.org>
Cc:	gusld@...ibm.com, linuxppc-dev@...ts.ozlabs.org, dev@...yps.com,
	linux-kernel@...r.kernel.org
Subject: Re: [1/1] powerpc/hv-24x7: Check support before registering PMU

On Thu, 2015-30-04 at 03:04:51 UTC, Sukadev Bhattiprolu wrote:
> We currently try to register the 24x7 PMU unconditionally. Not all
> Power systems support 24x7 counters (eg: Power7). On these systems
> we get a backtrace during boot when trying to register the 24x7 PMU.
> 
> Check if the hypervisor supports 24x7 counters before attempting to
> register the 24x7 PMU.

The concept is good, but ..

> diff --git a/arch/powerpc/perf/hv-24x7.c b/arch/powerpc/perf/hv-24x7.c
> index ec2eb20..19a59a3 100644
> --- a/arch/powerpc/perf/hv-24x7.c
> +++ b/arch/powerpc/perf/hv-24x7.c
> @@ -1268,12 +1268,44 @@ static struct pmu h_24x7_pmu = {
>  	.read        = h_24x7_event_read,
>  };
>  
> +/*
> + * Return 1 if we can access the 24x7 counter catalog from the hypervisor.
> + * Return 0 otherwise.
> + */
> +static int hv_has_24x7(void)

bool please

> +{
> +	int page_size = 4096;
> +	unsigned long hret;
> +	void *page;
> +	struct hv_24x7_catalog_page_0 *page_0;
> +
> +	page_0 = kmalloc(page_size*2, GFP_KERNEL);
> +	if (!page_0)
> +		return 0;
> +
> +	/* buffer for catalog needs to be 4K-aligned */
> +	page = (void *)((long)page_0 & (~page_size-1)) + page_size;
> +	hret = h_get_24x7_catalog_page(page, 0, 0);
> +	kfree(page_0);


It shouldn't need to be this complicated.

You should just be able to do the hcall with bogus args and if you get
H_FUNCTION then 24x7 is not supported.

cheers
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ