(no commit message)
[libreriscv.git] / x-list.mdwn
1 Hi All,
2
3 I think the time has come that someone constructs a list FAQ that we can
4 put on the footer of posts. I’m not the best person to write it as like
5 anyone I have unconscious biases that need to be moderated. It should be
6 moderated and edited by several people. Nevertheless, I’ve had a go at
7 a starting point. We need to put a stop to some of the recent behaviour
8 on the list. Misinformation, speculation, gossip and negativity towards
9 the current RISC-V standards track e.g. attacks on RISC-V suitability
10 for use in X are not appropriate. We need to move the discussion back to
11 purely technical issues, such as evolutionary and positive steps forward
12 vs revolutionary rhetoric that attacks towards RISC-V. This requires
13 some policy.
14
15 This starting point for the list FAQ has a number of list misdemeanours
16 including ones committed by me in the past, with lack of knowledge as a
17 newcomer. Recent list traffic has crowded out the largest contributors
18 to the specs and has made reading the list cringe material. The rhetoric
19 on the list is occupying the mental bandwidth of many readers to the
20 point where the list is becoming unreadable. This needs to stop. The
21 traffic doesn’t represent the track of the many people who have
22 contributed to the current base, which is the apex in which RISC-V
23 will evolve from. RISC-V is not intended to be revolutionary rather it
24 represents the next step in evolution from CISC, proprietary ISAs and
25 the expiration of patents that allow for the construction of a royalty
26 free open standard at the hardware level in a similar vain to what has
27 happened with Linux at the software level. This is an industry standard
28 group for an open standard.
29
30 I’m not apologising for my long email. I’ve added bullets so one can
31 skim through. I’m not apologising for my bias. I support the existing
32 RISC-V standards track and open tools which represents the huge amount
33 of work done by many contributors to date and I support the existing
34 standards and its careful quantitative evolution.
35
36 Work on a reference implementations for proposals and test them in RTL,
37 Gem5, QEMU, spike or other. Ideas are not the time-consuming work. Testing
38 them is…
39
40 My response mirrors the discourse. It is not technical, or when it is,
41 it is not consensus oriented. I find this difficult to digest. Particular
42 because my recent focus has been on a faithful and accurate representation
43 of the current specifications with a focus on backward and forward
44 binary compatibility.
45
46 -
47 https://www.sifive.com/blog/2018/04/25/risc-v-qemu-part-2-the-risc-v-qemu-port-is-upstream/
48
49 A lot of the recent discourse is at odds with the current standards
50 track and stated goals of the foundation, such as agnosticism towards
51 proprietary or open implementations. I believe the choice for openness
52 is out of pragmatism vs ideology. DRM is going to be one of those things
53 that gets implemented on RISC-V whether we personally agree with it or
54 not. We should refrain from attaching emotive language to implementation
55 choices that are legal for which we disagree with.
56
57 I tend towards consensus seeking behaviour. This list has become
58 somewhat exhausting to read and I can’t contribute to the current
59 style of discussions. It has occupied too much of my mental bandwidth
60 which compelled me to write this email, instead of working on what I’m
61 supposed to be working on. I do think we have a problem on this list
62 which we need to resolve.\
63
64 The founders of the ISA should be able to respond constructively and
65 positively to proposals on the list. The fact that they are not is an
66 indication that something is wrong.
67
68 This email is not intended to start a discussion. It’s more one of
69 despair. i.e. being nearly ready to hit “unsubscribe”.
70
71 Sincerely, X-Michael.
72
73
74
75 ## X-RISC-V ISA Development Mailing List FAQ
76
77
78 * Advocate for RISC-V on this mailing list
79
80 Constructive criticism is essential for evolution of the RISC-V
81 specifications, however opinions without quantitative assessment or that
82 contain a general disillusionment towards RISC-V are not in the spirit
83 of this list. Things can and will be improved as the specifications
84 evolve. Quirks exist. They can be ironed out. To improve the ISA we
85 need to maintain a generally positive attitude towards the evolution
86 of the specifications, keeping in mind binary compatibility with the
87 existing specifications. Editing the specifications is hard work. Gossip,
88 speculation and inaccurate accounts of computer history are not on topic.
89
90
91 * Read Computer Architecture, Sixth Edition: A Quantitative Approach
92
93 As we all know, this book contains the foundation of the RISC-V
94 quantitative design. Quoting Amazon: “Computer Architecture:
95 A Quantitative Approach, Sixth Edition has been considered essential
96 reading by instructors, students and practitioners of computer design for
97 over 20 years. The sixth edition of this classic textbook from Hennessy
98 and Patterson, winners of the 2017 ACM A.M. Turing Award recognizing
99 contributions of lasting and major technical importance to the computing
100 field, is fully revised with the latest developments in processor and
101 system architecture. The text now features examples from the RISC-V
102 (RISC Five) instruction set architecture, a modern RISC instruction set
103 developed and designed to be a free and openly adoptable standard. It
104 also includes a new chapter on domain-specific architectures and an
105 updated chapter on warehouse-scale computing that features the first
106 public information on Google’s newest WSC.”
107
108
109 * RISC origins at Berkeley
110
111 Rhetoric that compares RISC-V to a student project is defamatory and
112 belies the fact that there is widespread support and adoption for RISC-V
113 in the MCU space with companies committing to ship billions of RISC-V
114 processors in deeply embedded applications. The RISC-V Foundation
115 represents the apex of the academic-industrial complex and this is
116 shown by the Foundation membership. Please respect that this list is for
117 supporters of RISC-V and includes some of the most brilliant minds in the
118 industry. argumentum ad hominem and conspiracy theories should be avoided.
119
120
121 * The RISC-V Foundation has a large number of committed member companies.
122
123 There are newcomers on the list who are not aware that they are
124 broadcasting to a large Foundation of committed RISC-V member companies
125 who support the RISC-V standards. General rules for constructive
126 criticism and neutral discourse apply as indeed they would for any
127 industry working group.
128
129
130 * The privileged ISA is not a POSIX/Linux ISA
131
132 The only thing in the privileged specification that supports a
133 UNIX/POSIX-like OS is S-mode page based address translation and
134 the Supervisor mode / User mode privilege separation. These are
135 optional. These functions are not limited to POSIX. Windows NT with its
136 roots in VMS could use these facilities with PE/COFF and UEFI to run
137 ntoskrnl.exe on RISC-V. The System V ELF ABI and calling convention is
138 documented in a separate processor supplement ABI document. The Linux
139 ABI is not part of the ISA.
140
141
142 * Binary compatibility is important for MCUs
143
144 The machine mode registers should be consistent across
145 implementations. Binary compatibility for micro controllers is just
146 as important as OS level binary compatibility (which is distinct) as
147 it allows RISC-V system level code to be shared across heterogenous
148 implementations.
149
150
151 * Modularity makes small implementations easier
152
153 The modularity of the RISC-V specifications is very well thought
154 through and is one of its strengths; credit to the ISA designers. RVI
155 plus minimal M-mode is as easy to implement as one would expect for a
156 simple MCU with in the order of a few hundred bits for processor state
157 on top of the register file.
158
159
160 * A minimal M-mode implementation is not onerous
161
162 An M-mode only implementation requires approximately 11 CSRs (mcycle,
163 minstret, mstatus, misa, mie, mtvec, mscratch, mepc, mcause, mtval, mip)
164 out of a set of 18 CSRs. This is not onerous. Several only require 1
165 bit of state in a minimal configuration.
166
167 Below are the 18 CSRs with the minimal 11 identified which are necessary
168 to implement a processor confirming to the M-mode subset of the Privileged
169 ISA as distinct from the User-level ISA which only specifies the runtime
170 aspects of the ISA, versus privilege modes (M-mode is mandatory, S and U
171 are optional). An implementation with < 11 XLEN machine words is possible.
172
173 /* machine counters */ mcycle - (useful to implement) minstret -
174 (useful to implement)
175
176 /* machine information */ mvendorid - (can wire to 0) marchid -
177 (can wire to 0) mimplid - (can wire to 0) mhartid - (single core
178 can wire to 0)
179
180 /* machine trap setup */ mstatus - (requires MIE) 1-bit misa -
181 (1 bit: ‘E’ or ‘I’) 1-bit mideleg - (can wire to 0)
182 medeleg - (can wire to 0) mie - (require to enable external and
183 timer interrupts MEIE, MTIE) 2-bits mtvec - (required for ISR
184 entry, address, can be hardwired e.g to 0x10000) mcounteren -
185 (can wire to 0)
186
187 /* machine trap handling */ mscratch - (required register for
188 ISR stack pointer) mepc - (required register for ISR return
189 address) mcause - (required register for ISR cause: exception or
190 interrupt) mtval - (required register for ISR exception info) mip
191 - (required register for ISR to see which interrupts are pending)
192
193
194 * RISC-V Control and status registers are accessed with an immediate
195
196 Control and status registers are accessed via an instruction
197 immediate. This means there is no register read required to decode the
198 CSR. This makes pipelined and Out Of Order implementations easier to
199 implement. Thus it doesn’t favour one implementation style over the
200 other. CSRs could be present in an MMIO address space however the CSR
201 instructions are the interface, not loads or stores. The spec doesn’t
202 preclude the CSR instructions from fronting MMIO backed register space and
203 I believe it was a design considerations and a plausible implementation
204 choice. However, the specified instructions for accessing processor
205 state use an immediate. This simplifies implementation. Indirection of
206 access to CSRs via a register would remove the ability to rename and
207 force serialisation as CSRs can change the state of instructions before
208 and after them. This would be similar to loads and stores to IO space
209 which need to be ordered. The current design supports tiny MCUs up to
210 large multi-core OoO application processors.
211
212
213 * Micro controllers have different memory maps
214
215 The only thing limiting binary compatibility between bare metal apps are
216 typically a linker script because the “memory map” differs between
217 implementations and they require different device drivers. Bare metal apps
218 need to have custom chip bringup code for the MCU which is part of a BSP
219 (Board Support Package). Fortunately the privileged ISA is a constant
220 across implementations. Moving privileged ISA function into a memory map
221 won't improve this situation. It will worsen binary compatibility. Higher
222 level OSes like Linux have user level ABIs and virtual memory to hide the
223 physical memory map visible to the OS which makes binary portability
224 easier at higher layers in the application stack. Bare metal code
225 typically depends on a specific memory map but good design can factor
226 out the differences between different processors from different vendors.
227
228 Many RISC-V vendors are actively working on solutions to these
229 problems. For medium size systems there is even the possibility of
230 implementing arm’s EBBR standard which includes a cut down version of
231 UEFI designed to work with device-tree instead of ACPI. The interface
232 surface area is tractable for moderately sized embedded systems.
233
234 For smaller MCUs, the memory map and devices are likely to be unique.
235 Systems that have scratchpads that may be too small to hold device-tree
236 parser (like SiFive’s HiFive1) will of course need custom linker scripts
237 and custom BSPs. This is par for the course for the type of system that
238 when scaled may cost several cents and can be used on a smart conference
239 badge and in systems that are in the 1mm^2 range excluding packaging.
240
241
242 * Standard privilege status and control registers allow for portable
243 bare-metal code
244
245 The standard machine mode registers minimise friction when adapting code
246 to processors with different memory maps because developers can rely on
247 a standard control mechanism for traps (interrupts and exceptions).
248
249
250 * An ISA can’t disallow software, on the contrary it is designed to
251 support it
252
253 arm’s EBBR subset of UEFI is actually not that onerous and provides
254 a relatively clean interface for binary compatible booting on medium
255 size embedded devices. It is not appropriate for the smallest of
256 implementations that just depend on the presence of the 11 CRSs mentioned
257 above. But given RISC-V is an ISA, it can’t prevent someone from porting
258 UEFI, PE/COFF, coreboot, u-boot, or any OS for that matter. The ISA can
259 however enforce binary compatibility at the M-mode level.
260
261
262 * Secure implementations that support digital right management are
263 supported
264
265 Mask ROM code that verifies EEPROM payload with signature checks
266 using a public key in OTP are supported e.g. a Trusted Computing
267 Base. RISC-V member companies are actively working on boot integrity
268 across heterogenous RISC-V systems. Customers of chip vendors that have
269 intellectual property to protect are not excluded. RISC-V is agnostic
270 towards end-use and doesn’t have any restrictions on endeavours besides
271 compliance with the technical requirements of the ISA, for reasons of
272 binary compatibility.
273
274
275 * RISC-V has several ISA variants
276
277 At the moment MCUs and application processors with the same ISA share
278 the same calling convention, but there are several ISA variants with
279 different calling conventions in the RISC-V suite depending on the
280 presence of F, D, E. The C extension also creates an ISA variant (GC
281 code is not compatible with G), hence its presence in ‘misa’.
282
283
284 * MCUs don’t need to save/restore all registers
285
286 In the future, users of the open source tools will be able to do things
287 for the MCU profile like hide the ISR setup and entry assembly behind
288 C/C++ attributes, so programmers don’t need to worry about these
289 low-level details. It is possible, today, with existing tools, to model
290 an MCU ABI that has less register save restore overhead by compiling ISRs
291 (bottom half) with a different set of registers to top half code. It
292 is not necessary to make wholesale changes to the Privileged ISA to
293 achieve this. Optimising trap/entry exit clearly requires some thought
294 and using the standard C ABI may not be optimal. Luckily we can write
295 bare functions and use inline asm, etc.
296
297 Save/restore overhead can be reduced now with thoughtful use of compiler
298 flags (-ffixed-reg) or hand coded assembly. Special compiler support will
299 make this even easier in the future. Also, if code is purely interrupt
300 driven, then ISRs can also avoid save/restore alttogether. They are
301 many techniques to minimise interrupt overhead that don’t require ISA
302 changes. Recursive interrupts are of course a distinct issue that requires
303 thoughtful design… and I suspect will be addressed in a future version
304 of the spec, in an evolutionary vs revolutionary manner.
305
306 When a competitive RISC-V system can run at an order of magnitude faster
307 clock speed in the same process and area, then claims of these overheads
308 are “bunkem”
309
310
311 * Is forking the RISC-V ISA a good idea
312
313 Folk are free to fork the architecture , as it is CC licensed, and folk
314 can even call it RISC-V if they comply with the specifications and if
315 implementing a processor, an implementation need to implement the 11
316 or so M-mode registers (and several more wired to 0). The User-Level
317 ISA can only be used alone as part of an AEE. This is outlined in the
318 current specs. Custom additions have to follow the conventions set out
319 in the specification.
320
321
322 * Should RISC-V trademark rules should be enforced
323
324 Members could potentially be violating the RISC-V trademark usage
325 guidelines and I believe they should be enforced:
326
327 - https://riscv.org/risc-v-trademark-usage/
328
329 Example 1: https://emb-riscv.github.io/
330
331 Implementation proposal that does not comply with the minimal M mode
332 requirements and may not be RISC-V compliant. The “Embedded RISC-V”
333 initiative may very well comply with the Base ISA however as far as
334 I am aware, a complete processor must implement M mode unless it only
335 aims for AEE compliance. Use of the RISC-V logo in a way that suggests
336 endorsement from the foundation without explicit permission should be
337 questioned e.g. is “Embedded RISC-V” the official embedded working
338 group and who is the chair? Using something like X-Embedded might be
339 less risky assuming this may or may not be the Foundation’s official
340 Embedded Working Group? It is hard to tell. It is suggestive.
341
342 Example 2:
343 https://github.com/cliffordwolf/xbitmanip/blob/master/xbitmanip-draft.pdf
344
345 Uses X- prefix, extends the specifications, doesn’t modify the RISC-V
346 logo. Clearly fair use.
347
348
349 * Do we need an embedded working group.
350
351 I’d like to know more about the embedded working group. I think it would
352 be a disservice to the other foundation members if it was run by one
353 member acting without consideration of the existing specifications and
354 the needs of other members. I imagine minimising binary incompatibility
355 would be a mandate for the group with an objective to create “minimal”
356 differences or additions to the Privileged ISA versus a radical departure
357 that throws out the most minimal portion of the Privileged ISA.
358
359
360 * Folk should be free to experiment, within reasonable bounds
361
362 Certainly there needs to be a balance of freedom to experiment with the
363 RISC-V architecture i.e. academic or research use, versus commercial
364 implementations that would be subject to compliance assessment. Look at
365 how other commercial and individual members of the RISC-V Foundation
366 use the RISC-V logo and represent their custom “extensions”. Very
367 carefully. e.g. preceding specifications with X or noting said
368 specifications are “unofficial proposals”. My advice would be to avoid
369 wholesale replacement of portions of the specification and representing
370 it as “Industrial RISC-V” and the “RISC-V Industrial Profile”
371 versus “RISC-V X-Industrial Profile”. Someone could easily perceive
372 these as a projects that are endorsed by the foundation.
373
374 The mandatory portions for a minimal processor implementing M-mode and
375 RVI are indeed by all accounts small, so if an additive X-custom micro
376 controller profile is available, it may very well be accepted, assuming
377 it is compatible.
378
379
380 * RISC-V ISA is open but agnostic to free and open source versus
381 proprietary implementations alike
382
383 Regarding a Trusted Computing Base, RISC-V is available for use by
384 proprietary and open source implementations alike. This is clearly
385 stated on the foundation website. If implementations were restricted
386 to the hardware equivalent of GPL, then adoption in industry would be
387 very limited. The choice for on an open standard ISA is out of pragmatism
388 (cost reduction, shared common interest, industry competitive ISA that is
389 also a base for computer architecture research). It is not idealogical
390 (anti-DRM, tit-for-tat licensing schemes, prevents proprietary usage
391 or proprietary additions, or alternatively prevents open usage or open
392 additions). Many RISC-V Foundation members have intellectual property they
393 want to continue to protect and RISC-V is completely open to supporting
394 these implementations.
395
396
397 * RISC-V Base ISA requires 2-read ports 1-write port
398
399 Newcomers to the list might propose things that are inappropriate based
400 on design decisions that are already set in stone or frozen. We should
401 maintain a list FAQ for things that have already been discussed on the
402 list, such as instructions that require 3 read ports. FMA in F and D is
403 an exception and why. The Vector ISA allows for predicated operations
404 and the intent, as i’ve witnessed it, is to keep the implementation
405 requirements for the Base ISA to 2-read ports 1-write port. This means
406 two input operands. The Base ISA has no exceptions to this rule. F and
407 D which are optional extensions have some instructions with 3 input
408 operands and/or use implicit state. e.g. floating point instructions
409 read ‘frm’ and write to ‘fflags’. We can then simply reply with
410 a pointer to the FAQ.
411
412
413 * Inflammatory language vs neutral tone
414
415 Avoid inflammatory language and slang on the list. Words such as
416 “bunkem” and “treacherous” are examples of words that are not
417 appropriate for use on the list. “misinformation” is a more neutral
418 and correct. Avoid sensationalising issues and/or grandstanding.
419
420
421 * Long emails
422
423 If you want to send long emails, keep their frequency very low. I’ve
424 added bullets to this email so folk could skip ahead. i.e. “brevity
425 is the sole of wit”. A long email every few weeks is better than
426 occupying > 50% of the list bandwidth with distant goals when there are
427 more immediate and practical issues to solve. This involves discussing
428 and submitting edits to the “existing” specs versus occupying
429 the list with a deluge of radical departures from the current ISA
430 specifications. Post at a low frequency and gather feedback off list if
431 you write very long proposals, link to them
432
433
434 * Fragmentation, gossip, opinion and speculation
435
436 Fragmentation, gossip, opinion and speculation on this list is harmful. We
437 need to keep the discussions on this list technical and refrain from
438 industry gossip, fear mongering and opinion. Let’s keep things technical
439 and let’s focus this list on small incremental additions to the parts of
440 the ISA that are not frozen. I thought discussing something like a SELECT
441 instruction was quite controversial (3 operand form of conditional move
442 that requires a third bit-line read port and a zero comparator on each
443 physical register). Very uncontroversial in comparison to the recent
444 rampant expletive filled sagas on this list.
445
446
447 * Inclusivity and digesting
448
449 The list should remain open, inclusive and friendly towards newcomers. If
450 the discussion veers off topic, or becomes time consuming, point someone
451 to a book, FAQ or other material. Newcomers however should not post
452 material at a rate that a large number of members on the list can’t
453 possibly digest. Care for other peoples consciousness and their ability
454 to digest information. Its possible to overload people and occupy peoples
455 consciousness to their detriment if they are regular readers of this list.
456
457
458 * My own view. I’m not speaking on behalf of the foundation or my
459 employer
460
461 This should be implicit. This is a public list. I’m speaking in my
462 personal capacity. I would not dare to represent anything as RISC-V
463 without appropriate approval. Discussing the RISC-V ISA is on-topic on
464 this list. Proposing additions to the official specs via established
465 channels such as the working groups and this mailing list is on topic.