Commit Graph

12897 Commits

Author SHA1 Message Date
Shwartsman
5103d97ece mask use of CUT_OPMASK_TO macro instead of magic arithmetic 2023-10-19 16:59:32 +03:00
Shwartsman
63286528b5 take axv512 masted read/write helpers to separate file 2023-10-19 16:52:55 +03:00
Stanislav Shwartsman
e0cc12471c
fixed issue #95 port_e9_hack (#101)
refactoring of port_e9_hack configuration options
do not allow port e9 access for all rings if port_e9_hack is not enabled

Co-authored-by: Stanislav Shwartsman <sshwarts@users.sourceforge.net>
2023-10-18 08:19:33 +03:00
Shwartsman
2b873eb665 reapply PR #98 Hid register state fix 2023-10-17 15:10:28 +03:00
Shwartsman
f605dba487 remove duplicate option from configure scripts 2023-10-17 09:42:35 +03:00
Shwartsman
133144ae41 update include dependencies for CPU, MEMORY and BX_DBG folders 2023-10-16 19:42:44 +03:00
Shwartsman
d6c3ac641e fix compilation with mingw which has READLINE but doesn't have READLINE_HISTORY 2023-10-16 17:13:17 +03:00
Shwartsman
daa0e4506d add more features to configure scripts in repo (they are used for building release)
add SVM, EVEX, CET

reduce compilation dependencies
remove paramtree.h from bochs.h so many modules won't include it anymore

indentation fixes
2023-10-16 16:40:05 +03:00
Shwartsman
221cac7972 fixed compilation with no EVEX 2023-10-16 08:14:03 +03:00
Stanislav Shwartsman
a3d2fec111 Merge branch 'master' of https://github.com/bochs-emu/Bochs 2023-10-16 00:19:45 +03:00
Stanislav Shwartsman
035695f73c define CPU feature's enum together with feature name in one place 2023-10-15 23:56:11 +03:00
Stanislav Shwartsman
8e6bdcb4d9 define CPU feature's enum together with feature name in one place 2023-10-15 23:43:14 +03:00
Benjamin David Lunt
e7910a30a0
Xhci options (#92)
This adds a "hint" to the xHCI port configuration "option" entries,
hinting that the port number must or must not be super-speed.
2023-10-15 21:47:24 +03:00
Stanislav Shwartsman
8316d7698f
implemented Linear Address Separation extension (LASS) (#90)
Co-authored-by: Stanislav Shwartsman <sshwarts@users.sourceforge.net>
2023-10-15 14:32:01 +03:00
Benjamin David Lunt
b0dbbe884a
Misc uasp (#93)
Update the CHANGES file.
Syntax changes in uasp as requested a while back.
2023-10-15 10:26:43 +03:00
Stanislav Shwartsman
08d44208fc update and reorg CHANGES 2023-10-15 08:02:06 +03:00
Benjamin David Lunt
bcbe5da030
Usb compliance (#91)
Made all devices pass USB 2.0 Compliance on WinXP (old version of the
compliance test).
USB Hub still needs a little work to be in complete compliance.
Fixed potential bug in EHCI to UHCI hand-off.
Fixed compilation error with Floppy CB/CBI emulation.
Minor syntax fixes (tabulation, old irrelevant comments)
MSD serial numbers must be 12 chars.
Added to CHANGES file
2023-10-15 07:23:18 +03:00
Stanislav Shwartsman
ffa64461ab
implementation of AVX-NE-CONVERT ISA (#89)
Co-authored-by: Stanislav Shwartsman <sshwarts@users.sourceforge.net>
2023-10-14 14:55:12 +03:00
Stanislav Shwartsman
52d57a422c add VMEXIT reasons to enum, they not supported by Bochs but better to be listed for completion 2023-10-13 21:04:43 +03:00
Stanislav Shwartsman
9917227a56 enable CPUID reporting for recently added ISA extensions
more steps towards more generic CPUID code
2023-10-12 21:48:09 +03:00
Stanislav Shwartsman
dd7d4dbd82 implement SERIALIZE instruction
enable CPUID reporting for all recently added ISA extensions
2023-10-12 14:46:27 +03:00
Stanislav Shwartsman
4a309478f9
SHA512 instructions implemented (#88)
Co-authored-by: Stanislav Shwartsman <sshwarts@users.sourceforge.net>
2023-10-10 21:33:16 +03:00
Stanislav Shwartsman
3234e9b88e
implemented AVX VNNI INT16 ISA extension (#87)
Co-authored-by: Stanislav Shwartsman <sshwarts@users.sourceforge.net>
2023-10-10 20:22:07 +03:00
Stanislav Shwartsman
32b3f65d34 update CHANGES 2023-10-10 20:06:48 +03:00
Stanislav Shwartsman
3a21782840 fix copy/paste induced bug in ROR64 2023-10-08 08:10:54 +03:00
Stanislav Shwartsman
44eea71f37
implemented SM3 instructions (#84)
add rol/ror methods to scalar_arith.h and use in more places

---------

Co-authored-by: Stanislav Shwartsman <sshwarts@users.sourceforge.net>
2023-10-07 21:34:04 +03:00
Stanislav Shwartsman
841bc5a543 cleanup generic_cpuid.* 2023-10-07 18:24:47 +03:00
Stanislav Shwartsman
7e909a6fa5 rename CPUID flags to match leaf numbers 2023-10-07 18:10:20 +03:00
Stanislav Shwartsman
d4eea1d130 Remerge Fix OHCI Toggle function (#82)
This fixes the toggle bit check in the OHCI.
Tested Guests: WinXP, Win7
Tested devices: HID, HUB, DISK, CD-ROM
2023-10-07 10:15:18 +03:00
Shwartsman
6307786ded automatically determine MCE/MCA CPUID flags 2023-10-07 01:51:18 +03:00
Shwartsman
6d83b5239e another code duplication fix in CPUDB code 2023-10-07 01:36:05 +03:00
Shwartsman
20dfe7c7d0 improve comment 2023-10-07 01:09:22 +03:00
Shwartsman
672c93c7c4 reduce code duplication using new CPUID methods 2023-10-07 01:02:39 +03:00
Shwartsman
5fc6302b1b add one more CPUID method for future use + fix compilation after prev commit 2023-10-07 00:10:18 +03:00
Shwartsman
f50419429d Fix code duplication for CPUID ECX leaf 0x1, implement with common function for all CPUs 2023-10-06 22:53:30 +03:00
Shwartsman
c043d0ce0f initialize boolean with true/false instead of '0' or '1' 2023-10-01 13:23:53 +03:00
Benjamin David Lunt
7abed66ae5
Add minimal support for MMC command 0xAC (#80)
This changes a BX_INFO to a BX_DEBUG. It does not needed to be a
BX_INFO.

Second, this adds (very) minimal support for SCSI command 0xAC.
When emulating a .iso image via USB CD-ROM on Win10, without this
command, the emulation freezes when trying to access the CD-ROM. I don't
know if it is Bochs or Win10. I think Win10 expects the command to work,
or Bochs is not failing correctly.

This PR simply adds code to acknowledge the command and returns a zero
length report. This SCSI (MMC) specification states that a zero length
report is allowed.
The 8 byte header is returned, but the header indicates a zero byte
return: No report segments returned.
This seems to keep Win10 from freezing at USB CD-ROM device access time.

The code also BX_DEBUG's the command sent to the "controller", for
future use when adding the actual support of the command.
2023-09-26 07:55:29 +03:00
Benjamin David Lunt
74ed550334
Allow large VHD files (#79)
This PR allows larger VHD image files. The size in question doesn't
necessarily mean the size of the VHD file on disk. The size is the total
size of the image emulated. This total size is in question.

Without this patch, the total size allowed is 65535 * 16 * 255, or
roughly 32gig.
With this patch, the total size is calculated by who the creator of the
image is, what the CHS values are, and possibly a total size of up to a
limit of 2TB.

Since the original code was ported from QEMU, I ported an updated QEMU
code snippet.

https://gitlab.com/qemu-project/qemu/-/blob/master/block/vpc.c?ref_type=heads#L305

This PR now allows VHD image files with a total size emulated less than
or equal to 2TB.
2023-09-19 08:04:32 +03:00
Benjamin David Lunt
b46fc681d2
Improve default device detection (#77)
This improves the detection of the default speed of a device when given
in bochsrc.

It will first get the max speed of the port given. For example, uhci and
ohci will return FULL, ehci will return HIGH.
xHCI will return SUPER if the port is a super-speed port, else it will
return HIGH.

Then it will compare this with the max speed allowed for that device,
returning the highest common speed.

Of course, if the speed option is given, the above is overwritten by the
specified speed.

Both checks are still performed on the result.
1) does device allow the result speed?
2) does the controller allow the result speed?
2023-09-14 07:30:26 +03:00
Benjamin David Lunt
fae8e698c7
Usb common (#75)
This catches (possible) errors in the Bochrc file when declaring USB
port options.
The first catches when the user defines a port twice.  This will PANIC.
```
usb_ohci: port1=mouse, options1="speed:low, model:m228"
usb_ohci: port1=keyboard, options1="speed:low"
```
The second catches a possible error if the user copy/pastes a line and
forgets to update the options# part as in the example below.
```
usb_ohci: port1=tablet, options1="speed:low"
usb_ohci: port2=disk, options1="speed:full, path:hdd.img"
```
However, this will not PANIC since the following is completely legal:
```
usb_ohci: port2=disk
usb_ohci: options2="speed:full"
usb_ohci: options2="path:hdd.img"
```
This will simply display an error on the Bochs console window.
2023-09-09 07:46:43 +03:00
Benjamin David Lunt
b2a44e2284
Additional controller checks (#74)
This adds three additional checks to make sure the Guest is working
correctly.
- checks that the guest allocated the Scratchpad Area. If left zero
(NULL) the controller may access low memory.
- checks that the guest uses correct segment sizes in the interrupter
ring(s)
- checks the burst size value given to be within normal range

This also adds an internal register value for the HcCrcr (Command Ring
Control) register. Since this register reads zero by the Guest, we keep
an internal value so that the emulation can read the value, internally.
This is for features soon to be released.

Minor other syntax/comment changes (misspelled word, etc)

Checked with WinXP, Win7, and Win10
2023-09-08 08:44:56 +03:00
Benjamin David Lunt
43dd4164fe
Fix zero length packet handling (#73)
This fixes zero length packet handling.
See the following example that requests 128 bytes:

```
SETUP(8)
IN(64)
IN(64)
STATUS(0)
```

The current code erroneously assumes that there are no more IN packets
after the first two 64-byte packets.

However, what happens with the following:

```
SETUP(8)
IN(64)
IN(64)
IN(64)    <--- current code assumes this will be, and expects a STATUS packet
STATUS(0)
```

Currently, the third IN(64) above will result in a coding error because
the code is expecting the STATUS packet, not another IN packet.

The "controller" must allow for more packets than expected, returning a
short packet detect on the third IN(64) packet shown above, actually
returning zero bytes, hence the Short Packet Detect.

This patch was tested on WinXP, Win7, and Win10.
2023-09-07 08:04:10 +03:00
Benjamin David Lunt
0d48349a60
fixed bandwidth overage detection (#71)
The check for the amount of byte transferred in one frame time was done
before the update of the vertical pointer in the current Queue of the
last executed TD. Therefore, on the next frame time, the last executed
TD was being "executed" again. The check has now been moved to the top
of the loop.
2023-09-05 08:12:42 +03:00
Stanislav Shwartsman
fe53752ddf
rename USE_RAW_SERIAL -> BX_USE_RAW_SERIAL (#70) 2023-09-04 20:21:37 +03:00
Shwartsman
46f435e3f5 fixes for compilation without BX_LARGE_RAMFILE 2023-09-04 20:01:49 +03:00
Dreg
86eff7597d
add iodebug support for all rings complement #64 (#66)
This PR is for "I/O Interface to Bochs Debugger" from ring3 (port range:
**0x8A00 - 0x8A01**)

PR #64 was for E9 HACK (port **0xE9**)

By enabling the iodebug's 'all_rings' option, you can utilize the port
I/O Interface to Bochs Debugger from ring3. This PR allows the code
running inside Bochs (ring3) to monitor memory ranges, trace individual
instructions, and observe register values during execution.


https://bochs.sourceforge.io/doc/docbook/development/debugger-advanced.html

IMO very useful for:

- user-mode sandbox (ex Cuckoo)
- malware analysis
- API/SYSCALL hook/monitor from ring3
- automation + instrumentation from user mode code
...

A complement for PR #64

**This PR is 100% backward compatibility**

![IODEBUG ALL
RINGS](https://github.com/bochs-emu/Bochs/assets/9882181/6308ad0f-c189-43f3-a92b-dccde3542ad6)

btw, @stlintel I'm not certain about:
- if misc is the ideal location for this.. should I create a new
iodebug-option for this?
- should I remove the #if in 'new bx_param_bool_c'?
- the new .bochsrc entry makes sense for you?
2023-08-27 18:34:01 +02:00
Dreg
da43cc4580
add port e9 hack support for all rings (#64)
By enabling the 'all_rings' option, you can utilize the port e9 hack
from ring3

IMO very useful for:
- user-mode sandbox (ex Cuckoo)
- malware analysis
- API/SYSCALL logger with a simple hook from ring3
- automation + instrumentation from user mode code
- ...

So yes, from this PR a user-mode-sandbox can display on the console of
the system running Bochs anything that is written to 0xE9 port


![porte9hackallrings](https://github.com/bochs-emu/Bochs/assets/9882181/ddbca3fa-729b-4a3e-95ad-078e44c7a17a)

**This PR is 100% backward compatibility**

btw, @stlintel I'm not certain if **bochs/config.cc** is the ideal
location to define **bool port_e9_hack_all_rings** (unmapped io/dev is
better?)
2023-08-26 18:37:55 +03:00
Stanislav Shwartsman
253882589d extend cpuid enums with new bits announced in Intel SDM 2023-08-20 20:30:01 +03:00
Stanislav Shwartsman
1dcae848d7 change nullptr to NULL to help some old hosts not supporting C++ standard 2023-08-20 19:40:08 +03:00
Stanislav Shwartsman
6481d24e06 Another cleaner way to implemented fix by rei141
from Fixes in VM Entry Checks for Guest Segment Registers #51

Correction in checks for Code Segment (CS):
Previously, the DPL of CS was incorrectly compared with its own RPL.
According to Intel SDM, Vol. 3C, Chapter 27.3.1.2, for non-conforming code segments (type 9 or 11), the DPL of CS should be equal to the DPL of SS.
And for conforming code segments (type 13 or 15), the DPL of CS cannot be greater than the DPL of SS.

This way VMCS is not accessed multiple times which is important for some usages
2023-08-20 19:33:37 +03:00