From: Borislav Petkov <bp@amd64.org>
To: Ingo Molnar <mingo@elte.hu>, "H. Peter Anvin" <hpa@zytor.com>
Cc: Greg Kroah-Hartman <greg@kroah.com>,
Randy Dunlap <rdunlap@xenotime.net>,
Frank Arnold <farnold@amd64.org>, X86-ML <x86@kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
Frank Arnold <frank.arnold@amd.com>,
Borislav Petkov <borislav.petkov@amd.com>
Subject: [PATCH 2/3] x86, AMD, cacheinfo: Fix L3 cache index disable checks
Date: Mon, 16 May 2011 15:39:47 +0200 [thread overview]
Message-ID: <1305553188-21061-3-git-send-email-bp@amd64.org> (raw)
In-Reply-To: <1305553188-21061-1-git-send-email-bp@amd64.org>
From: Frank Arnold <frank.arnold@amd.com>
We provide two slots to disable cache indices, and have a check to
prevent both slots to be used for the same index.
If the user disables the same index on different subcaches, both slots
will hold the same index, e.g.
$ echo 2047 > /sys/devices/system/cpu/cpu0/cache/index3/cache_disable_0
$ cat /sys/devices/system/cpu/cpu0/cache/index3/cache_disable_0
2047
$ echo 1050623 > /sys/devices/system/cpu/cpu0/cache/index3/cache_disable_1
$ cat /sys/devices/system/cpu/cpu0/cache/index3/cache_disable_1
2047
due to the fact that the check was looking only at index bits [11:0]
and was ignoring writes to bits outside that range. The more correct
fix is to simply check whether the index is within the bounds of
[0..l3->indices].
While at it, cleanup comments and drop now-unused local macros.
Signed-off-by: Frank Arnold <frank.arnold@amd.com>
Signed-off-by: Borislav Petkov <borislav.petkov@amd.com>
---
arch/x86/kernel/cpu/intel_cacheinfo.c | 19 ++++---------------
1 files changed, 4 insertions(+), 15 deletions(-)
diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
index 31590a0..c105c53 100644
--- a/arch/x86/kernel/cpu/intel_cacheinfo.c
+++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
@@ -453,27 +453,16 @@ int amd_set_l3_disable_slot(struct amd_l3_cache *l3, int cpu, unsigned slot,
{
int ret = 0;
-#define SUBCACHE_MASK (3UL << 20)
-#define SUBCACHE_INDEX 0xfff
-
- /*
- * check whether this slot is already used or
- * the index is already disabled
- */
+ /* check if @slot is already used or the index is already disabled */
ret = amd_get_l3_disable_slot(l3, slot);
if (ret >= 0)
return -EINVAL;
- /*
- * check whether the other slot has disabled the
- * same index already
- */
- if (index == amd_get_l3_disable_slot(l3, !slot))
+ if (index > l3->indices)
return -EINVAL;
- /* do not allow writes outside of allowed bits */
- if ((index & ~(SUBCACHE_MASK | SUBCACHE_INDEX)) ||
- ((index & SUBCACHE_INDEX) > l3->indices))
+ /* check whether the other slot has disabled the same index already */
+ if (index == amd_get_l3_disable_slot(l3, !slot))
return -EINVAL;
amd_l3_disable_index(l3, cpu, slot, index);
--
1.7.4.rc2
next prev parent reply other threads:[~2011-05-16 13:40 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-16 13:39 [PATCH 0/3] x86, AMD, cacheinfo: L3 CID fixes Borislav Petkov
2011-05-16 13:39 ` [PATCH 1/3] x86, AMD, cacheinfo: Fix fallout caused by max3 conversion Borislav Petkov
2011-05-16 17:31 ` Greg KH
2011-05-16 17:38 ` Borislav Petkov
2011-05-16 17:42 ` H. Peter Anvin
2011-05-16 17:47 ` Borislav Petkov
2011-05-16 18:00 ` H. Peter Anvin
2011-05-16 18:19 ` Borislav Petkov
2011-05-16 18:45 ` Hagen Paul Pfeifer
2011-05-16 21:22 ` [tip:x86/cpu] " tip-bot for Borislav Petkov
2011-05-16 13:39 ` Borislav Petkov [this message]
2011-05-16 21:22 ` [tip:x86/cpu] x86, AMD, cacheinfo: Fix L3 cache index disable checks tip-bot for Frank Arnold
2011-05-16 13:39 ` [PATCH 3/3] Documentation, ABI: Update L3 cache index disable text Borislav Petkov
2011-05-16 17:30 ` Greg KH
2011-05-16 21:22 ` [tip:x86/cpu] " tip-bot for Borislav Petkov
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=1305553188-21061-3-git-send-email-bp@amd64.org \
--to=bp@amd64.org \
--cc=borislav.petkov@amd.com \
--cc=farnold@amd64.org \
--cc=frank.arnold@amd.com \
--cc=greg@kroah.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=rdunlap@xenotime.net \
--cc=x86@kernel.org \
/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
all inboxes | Powered by JetHome®