Skip to content

Commit 5148408

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mattst88/alpha
Pull alpha updates from Matt Turner: "A few small changes for alpha" * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mattst88/alpha: alpha: io: reorder barriers to guarantee writeX() and iowriteX() ordering alpha: Implement CPU vulnerabilities sysfs functions. alpha: rtc: stop validating rtc_time in .read_time alpha: rtc: remove unused set_mmss ops
2 parents becdce1 + cd0e00c commit 5148408

File tree

5 files changed

+55
-108
lines changed

5 files changed

+55
-108
lines changed

arch/alpha/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ config ALPHA
1818
select ARCH_HAVE_NMI_SAFE_CMPXCHG
1919
select AUDIT_ARCH
2020
select GENERIC_CLOCKEVENTS
21+
select GENERIC_CPU_VULNERABILITIES
2122
select GENERIC_SMP_IDLE_THREAD
2223
select GENERIC_STRNCPY_FROM_USER
2324
select GENERIC_STRNLEN_USER

arch/alpha/include/asm/io.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -341,14 +341,14 @@ extern inline unsigned int ioread16(void __iomem *addr)
341341

342342
extern inline void iowrite8(u8 b, void __iomem *addr)
343343
{
344-
IO_CONCAT(__IO_PREFIX,iowrite8)(b, addr);
345344
mb();
345+
IO_CONCAT(__IO_PREFIX, iowrite8)(b, addr);
346346
}
347347

348348
extern inline void iowrite16(u16 b, void __iomem *addr)
349349
{
350-
IO_CONCAT(__IO_PREFIX,iowrite16)(b, addr);
351350
mb();
351+
IO_CONCAT(__IO_PREFIX, iowrite16)(b, addr);
352352
}
353353

354354
extern inline u8 inb(unsigned long port)
@@ -382,8 +382,8 @@ extern inline unsigned int ioread32(void __iomem *addr)
382382

383383
extern inline void iowrite32(u32 b, void __iomem *addr)
384384
{
385-
IO_CONCAT(__IO_PREFIX,iowrite32)(b, addr);
386385
mb();
386+
IO_CONCAT(__IO_PREFIX, iowrite32)(b, addr);
387387
}
388388

389389
extern inline u32 inl(unsigned long port)
@@ -434,14 +434,14 @@ extern inline u16 readw(const volatile void __iomem *addr)
434434

435435
extern inline void writeb(u8 b, volatile void __iomem *addr)
436436
{
437-
__raw_writeb(b, addr);
438437
mb();
438+
__raw_writeb(b, addr);
439439
}
440440

441441
extern inline void writew(u16 b, volatile void __iomem *addr)
442442
{
443-
__raw_writew(b, addr);
444443
mb();
444+
__raw_writew(b, addr);
445445
}
446446
#endif
447447

@@ -482,14 +482,14 @@ extern inline u64 readq(const volatile void __iomem *addr)
482482

483483
extern inline void writel(u32 b, volatile void __iomem *addr)
484484
{
485-
__raw_writel(b, addr);
486485
mb();
486+
__raw_writel(b, addr);
487487
}
488488

489489
extern inline void writeq(u64 b, volatile void __iomem *addr)
490490
{
491-
__raw_writeq(b, addr);
492491
mb();
492+
__raw_writeq(b, addr);
493493
}
494494
#endif
495495

arch/alpha/kernel/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ccflags-y := -Wno-sign-compare
99

1010
obj-y := entry.o traps.o process.o osf_sys.o irq.o \
1111
irq_alpha.o signal.o setup.o ptrace.o time.o \
12-
systbls.o err_common.o io.o
12+
systbls.o err_common.o io.o bugs.o
1313

1414
obj-$(CONFIG_VGA_HOSE) += console.o
1515
obj-$(CONFIG_SMP) += smp.o

arch/alpha/kernel/bugs.c

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
2+
#include <asm/hwrpb.h>
3+
#include <linux/device.h>
4+
5+
6+
#ifdef CONFIG_SYSFS
7+
8+
static int cpu_is_ev6_or_later(void)
9+
{
10+
struct percpu_struct *cpu;
11+
unsigned long cputype;
12+
13+
cpu = (struct percpu_struct *)((char *)hwrpb + hwrpb->processor_offset);
14+
cputype = cpu->type & 0xffffffff;
15+
/* Include all of EV6, EV67, EV68, EV7, EV79 and EV69. */
16+
return (cputype == EV6_CPU) || ((cputype >= EV67_CPU) && (cputype <= EV69_CPU));
17+
}
18+
19+
ssize_t cpu_show_meltdown(struct device *dev,
20+
struct device_attribute *attr, char *buf)
21+
{
22+
if (cpu_is_ev6_or_later())
23+
return sprintf(buf, "Vulnerable\n");
24+
else
25+
return sprintf(buf, "Not affected\n");
26+
}
27+
28+
ssize_t cpu_show_spectre_v1(struct device *dev,
29+
struct device_attribute *attr, char *buf)
30+
{
31+
if (cpu_is_ev6_or_later())
32+
return sprintf(buf, "Vulnerable\n");
33+
else
34+
return sprintf(buf, "Not affected\n");
35+
}
36+
37+
ssize_t cpu_show_spectre_v2(struct device *dev,
38+
struct device_attribute *attr, char *buf)
39+
{
40+
if (cpu_is_ev6_or_later())
41+
return sprintf(buf, "Vulnerable\n");
42+
else
43+
return sprintf(buf, "Not affected\n");
44+
}
45+
#endif

arch/alpha/kernel/rtc.c

Lines changed: 1 addition & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ alpha_rtc_read_time(struct device *dev, struct rtc_time *tm)
9797
tm->tm_year = year;
9898
}
9999

100-
return rtc_valid_tm(tm);
100+
return 0;
101101
}
102102

103103
static int
@@ -114,83 +114,6 @@ alpha_rtc_set_time(struct device *dev, struct rtc_time *tm)
114114
return mc146818_set_time(tm);
115115
}
116116

117-
static int
118-
alpha_rtc_set_mmss(struct device *dev, time64_t nowtime)
119-
{
120-
int retval = 0;
121-
int real_seconds, real_minutes, cmos_minutes;
122-
unsigned char save_control, save_freq_select;
123-
124-
/* Note: This code only updates minutes and seconds. Comments
125-
indicate this was to avoid messing with unknown time zones,
126-
and with the epoch nonsense described above. In order for
127-
this to work, the existing clock cannot be off by more than
128-
15 minutes.
129-
130-
??? This choice is may be out of date. The x86 port does
131-
not have problems with timezones, and the epoch processing has
132-
now been fixed in alpha_set_rtc_time.
133-
134-
In either case, one can always force a full rtc update with
135-
the userland hwclock program, so surely 15 minute accuracy
136-
is no real burden. */
137-
138-
/* In order to set the CMOS clock precisely, we have to be called
139-
500 ms after the second nowtime has started, because when
140-
nowtime is written into the registers of the CMOS clock, it will
141-
jump to the next second precisely 500 ms later. Check the Motorola
142-
MC146818A or Dallas DS12887 data sheet for details. */
143-
144-
/* irq are locally disabled here */
145-
spin_lock(&rtc_lock);
146-
/* Tell the clock it's being set */
147-
save_control = CMOS_READ(RTC_CONTROL);
148-
CMOS_WRITE((save_control|RTC_SET), RTC_CONTROL);
149-
150-
/* Stop and reset prescaler */
151-
save_freq_select = CMOS_READ(RTC_FREQ_SELECT);
152-
CMOS_WRITE((save_freq_select|RTC_DIV_RESET2), RTC_FREQ_SELECT);
153-
154-
cmos_minutes = CMOS_READ(RTC_MINUTES);
155-
if (!(save_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD)
156-
cmos_minutes = bcd2bin(cmos_minutes);
157-
158-
real_seconds = nowtime % 60;
159-
real_minutes = nowtime / 60;
160-
if (((abs(real_minutes - cmos_minutes) + 15) / 30) & 1) {
161-
/* correct for half hour time zone */
162-
real_minutes += 30;
163-
}
164-
real_minutes %= 60;
165-
166-
if (abs(real_minutes - cmos_minutes) < 30) {
167-
if (!(save_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {
168-
real_seconds = bin2bcd(real_seconds);
169-
real_minutes = bin2bcd(real_minutes);
170-
}
171-
CMOS_WRITE(real_seconds,RTC_SECONDS);
172-
CMOS_WRITE(real_minutes,RTC_MINUTES);
173-
} else {
174-
printk_once(KERN_NOTICE
175-
"set_rtc_mmss: can't update from %d to %d\n",
176-
cmos_minutes, real_minutes);
177-
retval = -1;
178-
}
179-
180-
/* The following flags have to be released exactly in this order,
181-
* otherwise the DS12887 (popular MC146818A clone with integrated
182-
* battery and quartz) will not reset the oscillator and will not
183-
* update precisely 500 ms later. You won't find this mentioned in
184-
* the Dallas Semiconductor data sheets, but who believes data
185-
* sheets anyway ... -- Markus Kuhn
186-
*/
187-
CMOS_WRITE(save_control, RTC_CONTROL);
188-
CMOS_WRITE(save_freq_select, RTC_FREQ_SELECT);
189-
spin_unlock(&rtc_lock);
190-
191-
return retval;
192-
}
193-
194117
static int
195118
alpha_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
196119
{
@@ -210,7 +133,6 @@ alpha_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
210133
static const struct rtc_class_ops alpha_rtc_ops = {
211134
.read_time = alpha_rtc_read_time,
212135
.set_time = alpha_rtc_set_time,
213-
.set_mmss64 = alpha_rtc_set_mmss,
214136
.ioctl = alpha_rtc_ioctl,
215137
};
216138

@@ -225,7 +147,6 @@ static const struct rtc_class_ops alpha_rtc_ops = {
225147

226148
union remote_data {
227149
struct rtc_time *tm;
228-
unsigned long now;
229150
long retval;
230151
};
231152

@@ -267,29 +188,9 @@ remote_set_time(struct device *dev, struct rtc_time *tm)
267188
return alpha_rtc_set_time(NULL, tm);
268189
}
269190

270-
static void
271-
do_remote_mmss(void *data)
272-
{
273-
union remote_data *x = data;
274-
x->retval = alpha_rtc_set_mmss(NULL, x->now);
275-
}
276-
277-
static int
278-
remote_set_mmss(struct device *dev, time64_t now)
279-
{
280-
union remote_data x;
281-
if (smp_processor_id() != boot_cpuid) {
282-
x.now = now;
283-
smp_call_function_single(boot_cpuid, do_remote_mmss, &x, 1);
284-
return x.retval;
285-
}
286-
return alpha_rtc_set_mmss(NULL, now);
287-
}
288-
289191
static const struct rtc_class_ops remote_rtc_ops = {
290192
.read_time = remote_read_time,
291193
.set_time = remote_set_time,
292-
.set_mmss64 = remote_set_mmss,
293194
.ioctl = alpha_rtc_ioctl,
294195
};
295196
#endif

0 commit comments

Comments
 (0)