Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > alt.folklore.computers > #234519
| From | cross@spitfire.i.gajendra.net (Dan Cross) |
|---|---|
| Newsgroups | alt.folklore.computers |
| Subject | Re: Self-hosting and the 6502 |
| Date | 2026-03-31 23:05 +0000 |
| Organization | PANIX Public Access Internet and UNIX, NYC |
| Message-ID | <10qhjuu$o4f$1@reader2.panix.com> (permalink) |
| References | <10qcitr$22aag$1@dont-email.me> <10qe0je$aq3$1@reader2.panix.com> <10qe1n9$2han9$1@dont-email.me> |
In article <10qe1n9$2han9$1@dont-email.me>,
Peter Flass <Peter@Iron-Spring.com> wrote:
>On 3/30/26 07:16, Dan Cross wrote:
>[snip]
>>
>> It depends on what you mean by, "running machines inside
>> machines". There are two primary methods: emulation, in which
>> one machine completely emulates another in software; people have
>> been doing that since, probably, the 50s; perhaps earlier.
>>
>> Then there is virtualization, in which the "virtual mchine" is
>> primarily running directly on the underlying hardware, in which
>> case AFAIK IBM was the first with CP/40, which evolved into
>> VM/370.
>
>The difference here is clear. My question is, what's the difference
>between emulation and simulation? Is there a difference, even if only in
>connotation. I'm never quite clear on whether to call something an
>emulator or a simulator.
I guess I think of "simulation" as being e.g. a model of a thing
whereas "emulation" is attempting to replicate the behavior of
the thing itself. So for example a CPU might emulate the
behavior of an earlier version of its architecture, in such a
way that all observable behavior is preserved; a simulator on
the other hand will produce the main effects, but not (perhaps)
the timing.
I guess that's one way to think about it, anyway.
Actually, here's an example vis virtualization: many operations
are trapped on x86, and emulated, but there are times when you
_cannot deterministically get it right_: for example, suppose a
virtual machine attempts to execute an IO instruction; usually,
this will trap back to the host hypervisor for emulation.
But in order to understand what the guest was doing at the time
it trapped, so as to faithfully emulate the IO, you have to
fetch the bytes of the trapping instruction from guest memory
and interpret them. On e.g., Intel x86_64, the hardware saves
the guest's instruction pointer into a data structure called the
VMCS; the hypervisor reads that using a special `VMREAD`
instruction and retrieve the trapping instruction from guest
memory for interpretation.
But what if the guest is a) multiprocessing, and b) using virtual
memory, and c) sharing a page table between multiple VCPUs. In
this scenario, it is possible that the mappings for the page(s:
x86 instructions can span multiple pages) holding the
instruction bytes were overwritten by another VCPU, but that
that had not yet been reflected in the TLB of the trapping VCPU:
that is, the VCPU that trapped hadn't flushed its TLB, and is
operating against an old mapping that no longer exists in the
guest's page tables. The hypervisor has no way of knowing this,
since by the time it takes over, that part of the
microarchitectural state has been lost. Thus, what it reads
from guest memory may not be the trapping instruction at all;
for that matter, it may not even been an instruction. So the
best that the host can do is try to read _an_ instruction at
that location and try to execute whatever it finds. If that
instruction faults or isn't valid? Inject an exception into the
guest and restart it. Here, we can try and simulate the
behavior, but perfect emulation is impossible (they Intel didn't
just bank the instruction bytes themselves in the VMCS is a
legitimate question).
And it's even worse than that: if you read the Intel SDM
carefully, it says that when an instruction is fetched from
paged memory, the A/D bits on the page tables corresponding to
the instruction's location are set atomically ("as if under lock
cycles...", IIRC, though I don't have the document to hand at
the moment). That is, an external observer should not be to see
the bits change on the tables as the CPU walks them to fetch an
instruction.
But the host is walking those tables itself, manually, and may
be racing against other VCPUs that are running simultaneously,
giving them an opportunity to see an intermediate state. Here
we _might_ be able to stop them while we fetch the trapping
instruction from guest memory, but the performance impact would
be non-trivial (and likely unacceptable). So again we can
simulate, and in this case, we choose not to emulate.
- Dan C.
Back to alt.folklore.computers | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Self-hosting and the 6502 Lev <thresh3@fastmail.com> - 2026-03-30 01:16 +0000
Re: Self-hosting and the 6502 Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-03-30 06:12 +0000
Re: Self-hosting and the 6502 thresh3@fastmail.com (Lev) - 2026-03-30 07:07 +0000
Re: Self-hosting and the 6502 Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-03-30 08:13 +0000
Re: Self-hosting and the 6502 thresh3@fastmail.com (Lev) - 2026-03-30 13:11 +0000
Re: Self-hosting and the 6502 cross@spitfire.i.gajendra.net (Dan Cross) - 2026-03-30 14:25 +0000
Re: Self-hosting and the 6502 Peter Flass <Peter@Iron-Spring.com> - 2026-03-30 07:40 -0700
Re: Self-hosting and the 6502 Bob Eager <news0009@eager.cx> - 2026-03-30 17:02 +0000
Re: Self-hosting and the 6502 cross@spitfire.i.gajendra.net (Dan Cross) - 2026-03-31 21:35 +0000
Re: Self-hosting and the 6502 Bob Eager <news0009@eager.cx> - 2026-03-31 22:31 +0000
Re: Self-hosting and the 6502 cross@spitfire.i.gajendra.net (Dan Cross) - 2026-04-01 10:44 +0000
Re: Self-hosting and the 6502 Bob Eager <news0009@eager.cx> - 2026-04-01 10:47 +0000
Re: Self-hosting and the 6502 cross@spitfire.i.gajendra.net (Dan Cross) - 2026-04-01 13:57 +0000
Re: Self-hosting and the 6502 cross@spitfire.i.gajendra.net (Dan Cross) - 2026-03-31 21:34 +0000
Re: PC/IX, was Self-hosting and the 6502 John Levine <johnl@taugh.com> - 2026-04-01 02:01 +0000
Re: Self-hosting and the 6502 "Kurt Weiske" <kurt.weiske@realitycheckbbs.org.remove-a96-this> - 2026-04-02 07:35 -0700
Re: Self-hosting and the 6502 jayjwa <jayjwa@atr2.ath.cx.invalid> - 2026-04-01 18:14 -0400
Re: Self-hosting and the 6502 cross@spitfire.i.gajendra.net (Dan Cross) - 2026-04-01 22:56 +0000
Re: Self-hosting and the 6502 Rich Alderson <news@alderson.users.panix.com> - 2026-04-01 21:44 -0400
Re: Self-hosting and the 6502 Peter Flass <Peter@Iron-Spring.com> - 2026-04-01 21:35 -0700
Re: Self-hosting and the 6502 Nuno Silva <nunojsilva@invalid.invalid> - 2026-03-30 15:25 +0100
Re: Self-hosting and the 6502 Peter Flass <Peter@Iron-Spring.com> - 2026-03-30 07:42 -0700
Re: Self-hosting and the 6502 Gordon Henderson <gordon+usenet@drogon.net> - 2026-04-01 11:43 +0000
Self-hosting and the PDP-10 [was Re: Self-hosting and the 6502] Rich Alderson <news@alderson.users.panix.com> - 2026-04-01 15:41 -0400
Re: Self-hosting and the PDP-10 [was Re: Self-hosting and the 6502] cross@spitfire.i.gajendra.net (Dan Cross) - 2026-04-01 22:16 +0000
Re: Self-hosting and the PDP-10 [was Re: Self-hosting and the 6502] Rich Alderson <news@alderson.users.panix.com> - 2026-04-01 21:51 -0400
Re: Self-hosting and the PDP-10 [was Re: Self-hosting and the 6502] Peter Flass <Peter@Iron-Spring.com> - 2026-04-01 21:37 -0700
Re: Self-hosting and the PDP-10 [was Re: Self-hosting and the 6502] cross@spitfire.i.gajendra.net (Dan Cross) - 2026-04-02 10:50 +0000
Re: Self-hosting and the PDP-10 [was Re: Self-hosting and the 6502] Rich Alderson <news@alderson.users.panix.com> - 2026-04-02 15:18 -0400
Re: Self-hosting and the PDP-10 [was Re: Self-hosting and the 6502] cross@spitfire.i.gajendra.net (Dan Cross) - 2026-04-03 13:13 +0000
Re: Self-hosting and the PDP-10 [was Re: Self-hosting and the 6502] cross@spitfire.i.gajendra.net (Dan Cross) - 2026-04-02 10:58 +0000
Re: Self-hosting and the PDP-10 [was Re: Self-hosting and the 6502] Peter Flass <Peter@Iron-Spring.com> - 2026-04-02 07:32 -0700
Re: Self-hosting and the PDP-10 [was Re: Self-hosting and the 6502] cross@spitfire.i.gajendra.net (Dan Cross) - 2026-04-02 18:23 +0000
Re: virtualization, Self-hosting and the 6502 John Levine <johnl@taugh.com> - 2026-03-30 16:28 +0000
Re: Self-hosting and the 6502 Bill Findlay <findlaybill@blueyonder.co.uk> - 2026-03-30 17:59 +0100
Re: Self-hosting and the 6502 Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-03-30 21:24 +0000
Re: Self-hosting and the 6502 cross@spitfire.i.gajendra.net (Dan Cross) - 2026-03-30 14:16 +0000
Re: Self-hosting and the 6502 Peter Flass <Peter@Iron-Spring.com> - 2026-03-30 07:35 -0700
Re: emulation, virtualization, Self-hosting and the 6502 John Levine <johnl@taugh.com> - 2026-03-30 16:39 +0000
Re: emulation, virtualization, Self-hosting and the 6502 ted@loft.tnolan.com (Ted Nolan <tednolan>) - 2026-03-30 17:20 +0000
Re: emulation, virtualization, Self-hosting and the 6502 cross@spitfire.i.gajendra.net (Dan Cross) - 2026-03-31 23:39 +0000
Re: emulation, virtualization, Self-hosting and the 6502 scott@slp53.sl.home (Scott Lurndal) - 2026-04-02 14:57 +0000
Re: emulation, virtualization, Self-hosting and the 6502 rbowman <bowman@montana.com> - 2026-04-02 18:04 +0000
Re: emulation, virtualization, Self-hosting and the 6502 scott@slp53.sl.home (Scott Lurndal) - 2026-04-02 18:45 +0000
Re: Self-hosting and the 6502 David Wade <g4ugm@dave.invalid> - 2026-03-30 18:03 +0100
Re: Self-hosting and the 6502 Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-03-30 21:23 +0000
Re: Self-hosting and the 6502 cross@spitfire.i.gajendra.net (Dan Cross) - 2026-03-31 23:05 +0000
Re: Self-hosting and the 6502 John Ames <commodorejohn@gmail.com> - 2026-03-30 07:57 -0700
Re: Self-hosting and the 6502 cross@spitfire.i.gajendra.net (Dan Cross) - 2026-03-30 22:19 +0000
Re: Self-hosting and the 6502 Nuno Silva <nunojsilva@invalid.invalid> - 2026-03-31 00:18 +0100
Re: Self-hosting and the 6502 cross@spitfire.i.gajendra.net (Dan Cross) - 2026-03-31 22:04 +0000
Re: Self-hosting and the 6502 Bob Eager <news0009@eager.cx> - 2026-03-30 17:07 +0000
Re: Self-hosting and the 6502 antispam@fricas.org (Waldek Hebisch) - 2026-03-31 03:34 +0000
Re: Self-hosting and the 6502 Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-03-31 03:54 +0000
Re: Self-hosting and the 6502 antispam@fricas.org (Waldek Hebisch) - 2026-03-31 05:01 +0000
Re: Self-hosting and the 6502 Lev <thresh3@fastmail.com> - 2026-03-31 05:26 +0000
Re: Self-hosting and the 6502 Peter Flass <Peter@Iron-Spring.com> - 2026-03-31 07:48 -0700
Re: machine simulation, Self-hosting and the 6502 John Levine <johnl@taugh.com> - 2026-03-31 18:06 +0000
Re: Self-hosting and the 6502 scott@slp53.sl.home (Scott Lurndal) - 2026-03-31 15:03 +0000
Re: Self-hosting and the 6502 Bill Findlay <findlaybill@blueyonder.co.uk> - 2026-03-31 18:23 +0100
Re: Self-hosting and the 6502 Peter Flass <Peter@Iron-Spring.com> - 2026-03-31 13:04 -0700
csiph-web