diff options
| author | Madhavan Srinivasan <maddy@linux.vnet.ibm.com> | 2013-10-01 15:04:10 -0400 |
|---|---|---|
| committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2013-10-03 03:22:53 -0400 |
| commit | d1211af3049f4c9c1d8d4eb8f8098cc4f4f0d0c7 (patch) | |
| tree | e7dedb4f171f28b2a07f4fc759a5a7de6fc1d1e1 | |
| parent | 8f21bd0090052e740944f9397e2be5ac7957ded7 (diff) | |
powerpc/sysfs: Disable writing to PURR in guest mode
arch/powerpc/kernel/sysfs.c exports PURR with write permission.
This may be valid for kernel in phyp mode. But writing to
the file in guest mode causes crash due to a priviledge violation
Signed-off-by: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: <stable@vger.kernel.org>
| -rw-r--r-- | arch/powerpc/kernel/sysfs.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c index 27a90b99ef67..b4e667663d9b 100644 --- a/arch/powerpc/kernel/sysfs.c +++ b/arch/powerpc/kernel/sysfs.c | |||
| @@ -17,6 +17,7 @@ | |||
| 17 | #include <asm/machdep.h> | 17 | #include <asm/machdep.h> |
| 18 | #include <asm/smp.h> | 18 | #include <asm/smp.h> |
| 19 | #include <asm/pmc.h> | 19 | #include <asm/pmc.h> |
| 20 | #include <asm/firmware.h> | ||
| 20 | 21 | ||
| 21 | #include "cacheinfo.h" | 22 | #include "cacheinfo.h" |
| 22 | 23 | ||
| @@ -179,15 +180,25 @@ SYSFS_PMCSETUP(spurr, SPRN_SPURR); | |||
| 179 | SYSFS_PMCSETUP(dscr, SPRN_DSCR); | 180 | SYSFS_PMCSETUP(dscr, SPRN_DSCR); |
| 180 | SYSFS_PMCSETUP(pir, SPRN_PIR); | 181 | SYSFS_PMCSETUP(pir, SPRN_PIR); |
| 181 | 182 | ||
| 183 | /* | ||
| 184 | Lets only enable read for phyp resources and | ||
| 185 | enable write when needed with a separate function. | ||
| 186 | Lets be conservative and default to pseries. | ||
| 187 | */ | ||
| 182 | static DEVICE_ATTR(mmcra, 0600, show_mmcra, store_mmcra); | 188 | static DEVICE_ATTR(mmcra, 0600, show_mmcra, store_mmcra); |
| 183 | static DEVICE_ATTR(spurr, 0400, show_spurr, NULL); | 189 | static DEVICE_ATTR(spurr, 0400, show_spurr, NULL); |
| 184 | static DEVICE_ATTR(dscr, 0600, show_dscr, store_dscr); | 190 | static DEVICE_ATTR(dscr, 0600, show_dscr, store_dscr); |
| 185 | static DEVICE_ATTR(purr, 0600, show_purr, store_purr); | 191 | static DEVICE_ATTR(purr, 0400, show_purr, store_purr); |
| 186 | static DEVICE_ATTR(pir, 0400, show_pir, NULL); | 192 | static DEVICE_ATTR(pir, 0400, show_pir, NULL); |
| 187 | 193 | ||
| 188 | unsigned long dscr_default = 0; | 194 | unsigned long dscr_default = 0; |
| 189 | EXPORT_SYMBOL(dscr_default); | 195 | EXPORT_SYMBOL(dscr_default); |
| 190 | 196 | ||
| 197 | static void add_write_permission_dev_attr(struct device_attribute *attr) | ||
| 198 | { | ||
| 199 | attr->attr.mode |= 0200; | ||
| 200 | } | ||
| 201 | |||
| 191 | static ssize_t show_dscr_default(struct device *dev, | 202 | static ssize_t show_dscr_default(struct device *dev, |
| 192 | struct device_attribute *attr, char *buf) | 203 | struct device_attribute *attr, char *buf) |
| 193 | { | 204 | { |
| @@ -394,8 +405,11 @@ static void register_cpu_online(unsigned int cpu) | |||
| 394 | if (cpu_has_feature(CPU_FTR_MMCRA)) | 405 | if (cpu_has_feature(CPU_FTR_MMCRA)) |
| 395 | device_create_file(s, &dev_attr_mmcra); | 406 | device_create_file(s, &dev_attr_mmcra); |
| 396 | 407 | ||
| 397 | if (cpu_has_feature(CPU_FTR_PURR)) | 408 | if (cpu_has_feature(CPU_FTR_PURR)) { |
| 409 | if (!firmware_has_feature(FW_FEATURE_LPAR)) | ||
| 410 | add_write_permission_dev_attr(&dev_attr_purr); | ||
| 398 | device_create_file(s, &dev_attr_purr); | 411 | device_create_file(s, &dev_attr_purr); |
| 412 | } | ||
| 399 | 413 | ||
| 400 | if (cpu_has_feature(CPU_FTR_SPURR)) | 414 | if (cpu_has_feature(CPU_FTR_SPURR)) |
| 401 | device_create_file(s, &dev_attr_spurr); | 415 | device_create_file(s, &dev_attr_spurr); |
