public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Mark Langsdorf <mark.langsdorf@amd.com>
Cc: linux-kernel@vger.kernel.org, tglx@linutronix.de, mingo@redhat.com
Subject: Re: [PATCH] Conform L3 Cache Index Disable to Linux standards
Date: Thu, 19 Feb 2009 02:24:30 -0800	[thread overview]
Message-ID: <20090219022430.3c682a93.akpm@linux-foundation.org> (raw)
In-Reply-To: <200902181604.26991.mark.langsdorf@amd.com>

On Wed, 18 Feb 2009 16:04:26 -0600 Mark Langsdorf <mark.langsdorf@amd.com> wrote:

> The L3 Cache Index Disable feature to arch/x86/kernel/cpu/intel_cacheinfo.c
> accepted in 2.6.28 was inadvertently a preliminary version of the patch
> that should not have been accepted.  It did not include ABI documentation
> and did not meet the usage standards of a /sys file.
> 
> This patch changes that code to use a proposed patch that had the
> maintainer's approval but was accidentally not accepted.
> 
> It also corrects prevents the patch from being used on AMD processors
> that do not currently support L3 Cache Index Disable.
> 
> ...
>
> +show_cache_disable_##index(struct _cpuid4_info *this_leaf, char *buf)  	\
> +{									\
> +	return show_cache_disable(this_leaf, buf, index);		\
> +}
> +
> +static ssize_t
> +store_cache_disable(struct _cpuid4_info *this_leaf, const char *buf,
> +		 size_t count, unsigned int index)
> +{
> +	int node = cpu_to_node(first_cpu(this_leaf->shared_cpu_map));
> +	struct pci_dev *dev = k8_northbridges[node];
> +	ssize_t ret = 0;
> +	unsigned int val;
> +
> +	if (!this_leaf->can_disable)
> +		return -EINVAL;
> +
> +	ret = sscanf(buf, "%x", &val);

We permit used input suzh as `42foo'?

strict_strtoul() would fix that.

> +	if (ret != 1)
> +		return -EINVAL;
> +
> +	if (!capable(CAP_SYS_ADMIN))
> +		return -EPERM;

It would make sense to do this earlier in the function.

Do we need to do it at all?  File permissions do not suffice?

> +	val |= 0xc0000000;
> +	pci_write_config_dword(dev, 0x1BC + index * 4, val & ~0x40000000);
> +	wbinvd();
> +	pci_write_config_dword(dev, 0x1BC + index * 4, val);
> +	return count;
> +}
> +


      reply	other threads:[~2009-02-19 10:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-18 22:04 [PATCH] Conform L3 Cache Index Disable to Linux standards Mark Langsdorf
2009-02-19 10:24 ` Andrew Morton [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090219022430.3c682a93.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.langsdorf@amd.com \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox